first commit

This commit is contained in:
Roman Pyrih
2023-07-24 08:30:51 +02:00
commit c2e100a763
7128 changed files with 1622619 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die();
}
if ( ( defined( 'FW' ) ) && ! ( class_exists( 'Solarify_Widget_Contacts' ) ) ) :
class Solarify_Widget_Contacts extends WP_Widget {
/**
* Widget constructor.
*/
private $options;
private $prefix;
function __construct() {
$widget_ops = array(
'classname' => 'widget_contacts',
'description' => esc_html__( 'Add company logo with contacts', 'solarify' ),
);
parent::__construct( false, esc_html__( 'Theme - Contacts', 'solarify' ), $widget_ops );
//Create our options by using Unyson option types
$this->options = array(
'title' => array(
'type' => 'text',
'label' => esc_html__( 'Widget Title', 'solarify' ),
),
'contacts' => array(
'type' => 'addable-box',
'value' => array(
array(
'contact_info' => 'contact info',
),
),
'label' => esc_html__('Contact item', 'solarify'),
'desc' => esc_html__('Media element with contact info and related icon', 'solarify'),
'help' => esc_html__('Enter contact info and choose icon', 'solarify'),
'box-options' => array(
'contact_info' => array( 'type' => 'textarea' ),
'link' => array(
'type' => 'text',
'value' => '',
'label' => esc_html__('Link address', 'solarify'),
'desc' => esc_html__('Fill this field only if you want it to be a link', 'solarify'),
),
'icon' => array(
'type' => 'icon-v2',
'label' => esc_html__( 'Choose an Icon', 'solarify' )
),
),
'template' => esc_html__( 'Contact Item', 'solarify' ), // box title
'add-button-text' => esc_html__('Add', 'solarify'),
'sortable' => true,
)
);
$this->prefix = 'widget_contacts';
}
function widget( $args, $instance ) {
extract( wp_parse_args( $args ) );
$title = esc_attr( $instance['title'] );
$title = $before_title . $title . $after_title;
$params = array();
foreach ( $instance as $key => $value ) {
$params[ $key ] = $value;
}
$instance = $params;
$filepath = SOLARIFY_THEME_PATH . '/inc/widgets/contacts/views/widget.php';
if ( file_exists( $filepath ) ) {
include( $filepath );
} else {
esc_html_e( 'View not found', 'solarify' );
}
}
function update( $new_instance, $old_instance ) {
return fw_get_options_values_from_input(
$this->options,
FW_Request::POST( fw_html_attr_name_to_array_multi_key( $this->get_field_name( $this->prefix ) ), array() )
);
}
function form( $values ) {
$prefix = $this->get_field_id( $this->prefix ); // Get unique prefix, preventing duplicated key
$id = 'fw-widget-options-' . $prefix;
// Print our options
echo '<div class="fw-force-xs fw-theme-admin-widget-wrap fw-framework-widget-options-widget" data-fw-widget-id="' . esc_attr( $id ) . '" id="' . esc_attr( $id ) . '">';
echo fw()->backend->render_options( $this->options, $values, array(
'id_prefix' => $prefix . '-',
'name_prefix' => $this->get_field_name( $this->prefix ),
) );
echo '</div>';
return $values;
}
}
endif;

View File

@@ -0,0 +1,44 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die();
}
if ( ! defined( 'FW' ) ) {
return;
}
/**
* @var string $before_widget
* @var string $after_widget
* @var array $params
* @var $title
*/
$unique_id = uniqid();
echo wp_kses_post( $before_widget );
echo wp_kses_post( $title );
?>
<ul class="list-unstyled greylinks">
<?php foreach ( $params['contacts'] as $contact ) : ?>
<li>
<div class="media small-media">
<?php if ( !empty( $contact['icon'] ) ) : ?>
<div class="media-left media-middle">
<?php if ( $contact['icon']['type'] === 'icon-font') : ?>
<i class="<?php echo esc_attr( $contact['icon']['icon-class'] ); ?> highlight fontsize_24 cons-width"></i>
<?php else:
echo wp_get_attachment_image( $contact['icon']['attachment-id'] );
endif; ?>
</div>
<?php endif; ?>
<div class="media-body media-middle greylinks">
<?php if ( !empty( $contact['link'] ) ) : ?>
<a href="<?php echo esc_attr( $contact['link'] ); ?>">
<?php endif;
echo nl2br( esc_html( $contact['contact_info'] ) );
if ( !empty( $contact['link'] ) ) : ?>
</a>
<?php endif; ?>
</div>
</div>
</li>
<?php endforeach; ?>
</ul>
<?php echo wp_kses_post( $after_widget );