HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/button-grid.tar
assets/banner.svg000064400000003174151541756610010054 0ustar00<svg fill="none" height="120" viewBox="0 0 120 120" width="120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><clipPath id="a"><path d="m0 0h120v120h-120z"/></clipPath><g clip-path="url(#a)"><path d="m0 0h120v120h-120z" fill="#1880b6"/><g stroke="#324249" stroke-linecap="round" stroke-width="2"><path d="m51.375 56.0179h-18.5714c-2.5642 0-4.6429 2.0786-4.6429 4.6428v9.2857c0 2.5642 2.0787 4.6429 4.6429 4.6429h18.5714c2.5642 0 4.6428-2.0787 4.6428-4.6429v-9.2857c0-2.5642-2.0786-4.6428-4.6428-4.6428z" fill="#8cdaf0" stroke-linejoin="round"/><path d="m86.1964 56.0179h-18.5714c-2.5642 0-4.6429 2.0786-4.6429 4.6428v9.2857c0 2.5642 2.0787 4.6429 4.6429 4.6429h18.5714c2.5642 0 4.6429-2.0787 4.6429-4.6429v-9.2857c0-2.5642-2.0787-4.6428-4.6429-4.6428z" fill="#f0eed5" stroke-linejoin="round"/><path d="m69.9464 65.3036h13.9286"/><path d="m35.125 65.3036h13.9286"/><path d="m86.1964 30.4821h-18.5714c-2.5642 0-4.6429 2.0787-4.6429 4.6429v9.2857c0 2.5642 2.0787 4.6429 4.6429 4.6429h18.5714c2.5642 0 4.6429-2.0787 4.6429-4.6429v-9.2857c0-2.5642-2.0787-4.6429-4.6429-4.6429z" fill="#f0eed5" stroke-linejoin="round"/><path d="m69.9464 39.7679h13.9286"/><path d="m51.375 30.4821h-18.5714c-2.5642 0-4.6429 2.0787-4.6429 4.6429v9.2857c0 2.5642 2.0787 4.6429 4.6429 4.6429h18.5714c2.5642 0 4.6428-2.0787 4.6428-4.6429v-9.2857c0-2.5642-2.0786-4.6429-4.6428-4.6429z" fill="#f0eed5" stroke-linejoin="round"/><path d="m35.125 39.7679h13.9286"/><path d="m64.1428 78.0714-18.3881-7.2438c-.4637-.1826-.9916-.0728-1.344.2795-.3524.3524-.4622.8803-.2795 1.344l7.2438 18.3882 3.4821-9.2857z" fill="#8cdaf0" stroke-linejoin="round"/></g></g></svg>assets/icon.svg000064400000002517151541756610007537 0ustar00<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m3.8291 10.63867h5.05957c.96484 0 1.75-.78516 1.75-1.75v-5.05908c0-.96484-.78516-1.75-1.75-1.75h-5.05957c-.96484 0-1.75.78516-1.75 1.75v5.05908c0 .96484.78516 1.75 1.75 1.75zm-.25-6.80908c0-.1377.1123-.25.25-.25h5.05957c.1377 0 .25.1123.25.25v5.05908c0 .1377-.1123.25-.25.25h-5.05957c-.1377 0-.25-.1123-.25-.25z"/><path d="m20.1709 2.07959h-5.05957c-.96484 0-1.75.78516-1.75 1.75v5.05908c0 .96484.78516 1.75 1.75 1.75h5.05957c.96484 0 1.75-.78516 1.75-1.75v-5.05908c0-.96484-.78516-1.75-1.75-1.75zm.25 6.80908c0 .1377-.1123.25-.25.25h-5.05957c-.1377 0-.25-.1123-.25-.25v-5.05908c0-.1377.1123-.25.25-.25h5.05957c.1377 0 .25.1123.25.25z"/><path d="m3.8291 21.92041h5.05957c.96484 0 1.75-.78516 1.75-1.75v-5.05908c0-.96484-.78516-1.75-1.75-1.75h-5.05957c-.96484 0-1.75.78516-1.75 1.75v5.05908c0 .96484.78516 1.75 1.75 1.75zm-.25-6.80908c0-.1377.1123-.25.25-.25h5.05957c.1377 0 .25.1123.25.25v5.05908c0 .1377-.1123.25-.25.25h-5.05957c-.1377 0-.25-.1123-.25-.25z"/><path d="m20.1709 13.36133h-5.05957c-.96484 0-1.75.78516-1.75 1.75v5.05908c0 .96484.78516 1.75 1.75 1.75h5.05957c.96484 0 1.75-.78516 1.75-1.75v-5.05908c0-.96484-.78516-1.75-1.75-1.75zm.25 6.80908c0 .1377-.1123.25-.25.25h-5.05957c-.1377 0-.25-.1123-.25-.25v-5.05908c0-.1377.1123-.25.25-.25h5.05957c.1377 0 .25.1123.25.25z"/></svg>button-grid.php000064400000017427151541756610007541 0ustar00<?php
/*
Widget Name: Button Grid
Description: Add multiple buttons in one go, customize individually, and present them in a neat grid layout.
Author: SiteOrigin
Author URI: https://siteorigin.com
Documentation: https://siteorigin.com/widgets-bundle/button-grid-widget/
*/

class SiteOrigin_Widget_Button_Grid_Widget extends SiteOrigin_Widget {
	private $settings;

	public function __construct() {
		parent::__construct(
			'sow-button-grid',
			__( 'SiteOrigin Button Grid', 'so-widgets-bundle' ),
			array(
				'description' => __( 'Add multiple buttons in one go, customize individually, and present them in a neat grid layout.', 'so-widgets-bundle' ),
				'help' => 'https://siteorigin.com/widgets-bundle/button-grid-widget/',
				'instance_storage' => true,
				'panels_title' => false,
			),
			array(),
			false,
			plugin_dir_path( __FILE__ )
		);
	}

	// Setup hooks to safely override button widget variables.
	public function get_template_variables( $instance, $args ) {
		add_filter( 'siteorigin_widgets_less_variables_sow-button', array( $this, 'override_button_less_variables' ), 10, 3 );
		add_filter( 'siteorigin_widgets_template_variables_sow-button', array( $this, 'override_button_variables' ), 10, 1 );

		add_action( 'siteorigin_widgets_after_widget_sow-button-grid', array( $this, 'remove_hooks' ) );

		return array();
	}

	// Remove hooks after the Button Grid has finished rendering.
	public function remove_hooks() {
		remove_filter( 'siteorigin_widgets_less_variables_sow-button', array( $this, 'override_button_less_variables' ), 10, 3 );
		remove_filter( 'siteorigin_widgets_template_variables_sow-button', array( $this, 'override_button_variables' ), 10, 1 );
		remove_action( 'siteorigin_widgets_before_widget_sow-button-grid', array( $this, 'remove_hooks' ) );
	}

	public function get_settings_form() {
		return array(
			'responsive_breakpoint' => array(
				'type' => 'measurement',
				'label' => __( 'Responsive Breakpoint', 'so-widgets-bundle' ),
				'default' => '780px',
				'description' => __( 'Device width, in pixels, to collapse into a mobile view.', 'so-widgets-bundle' ),
			),
		);
	}

	function get_widget_form() {
		return array(
			'buttons' => array(
				'type' => 'repeater',
				'label' => __( 'Buttons', 'so-widgets-bundle' ),
				'item_name' => __( 'Button', 'so-widgets-bundle' ),
				'item_label' => array(
					'selector' => "[id*='text']",
					'update_event' => 'change',
					'value_method' => 'val',
				),

				'fields' => array(
					'widget' => array(
						'type' => 'widget',
						'collapsible' => false,
						'class' => 'SiteOrigin_Widget_Button_Widget',
						'form_filter' => array( $this, 'filter_buttons_widget_form' ),
					),
				),
			),
			'layout' => array(
				'type' => 'section',
				'label' => __( 'Layout', 'so-widgets-bundle' ),
				'fields' => array(
					'desktop' => array(
						'type' => 'section',
						'label' => __( 'Desktop', 'so-widgets-bundle' ),
						'fields' => array(
							'columns' => array(
								'type' => 'number',
								'label' => __( 'Buttons Per Row', 'so-widgets-bundle' ),
								'default' => 3,
							),
							'alignment' => array(
								'type' => 'select',
								'label' => __( 'Button Alignment', 'so-widgets-bundle' ),
								'default' => 'center',
								'options' => array(
									'left' => __( 'Left', 'so-widgets-bundle' ),
									'center' => __( 'Center', 'so-widgets-bundle' ),
									'right' => __( 'Right', 'so-widgets-bundle' ),
								),
							),
							'gap' => array(
								'type' => 'multi-measurement',
								'label' => __( 'Gap', 'so-widgets-bundle' ),
								'default' => '20px 20px',
								'measurements' => array(
									'row' => __( 'Row', 'so-widgets-bundle' ),
									'column' => __( 'Column', 'so-widgets-bundle' ),
								),
							),
						),
					),
					'mobile' => array(
						'type' => 'section',
						'label' => __( 'Mobile', 'so-widgets-bundle' ),
						'fields' => array(
							'columns' => array(
								'type' => 'number',
								'label' => __( 'Buttons Per Row', 'so-widgets-bundle' ),
								'default' => 3,
							),
							'alignment' => array(
								'type' => 'select',
								'label' => __( 'Button Alignment', 'so-widgets-bundle' ),
								'default' => 'center',
								'options' => array(
									'left' => __( 'Left', 'so-widgets-bundle' ),
									'center' => __( 'Center', 'so-widgets-bundle' ),
									'right' => __( 'Right', 'so-widgets-bundle' ),
								),
							),
							'gap' => array(
								'type' => 'multi-measurement',
								'label' => __( 'Gap', 'so-widgets-bundle' ),
								'default' => '20px 20px',
								'measurements' => array(
									'row' => __( 'Row', 'so-widgets-bundle' ),
									'column' => __( 'Column', 'so-widgets-bundle' ),
								),
							),

						),
					),
				),
			),
		);
	}

	/**
	 * Adds a dedicated Grid option to the Button Widget. This allow users to override the Button Grid Alignment on a button by button basis.
	 *
	 * @param array $form_fields
	 *
	 * @return array $form_fields A modified Button Widget form options.
	 */
	function filter_buttons_widget_form( $form_fields ) {
		$form_fields['design']['fields']['align']['options']['default'] = __( 'Default', 'so-widgets-bundle' );
		$form_fields['design']['fields']['align']['default'] = 'default';
		$form_fields['design']['fields']['mobile_align']['options']['default'] = __( 'Default', 'so-widgets-bundle' );
		$form_fields['design']['fields']['mobile_align']['default'] = 'default';

		return $form_fields;
	}

	public function get_less_variables( $instance ) {
		if ( empty( $instance ) ) {
			return array();
		}

		if ( ! is_array( $instance['layout'] ) ) {
			$instance['layout'] = array();
		}

		$desktop = ! empty( $instance['layout']['desktop'] ) ? $instance['layout']['desktop'] : array();
		$mobile = ! empty( $instance['layout']['mobile'] ) ? $instance['layout']['mobile'] : array();

		$settings = array(
			'responsive_breakpoint' => $this->get_global_settings( 'responsive_breakpoint' ),
			'desktop_gap' => ! empty( $desktop['gap'] ) ? $desktop['gap'] : '20px',
			'mobile_gap' => ! empty( $mobile['gap'] ) ? $mobile['gap'] : '20px',
		);

		$settings = $this->generate_system_css(
			$settings,
			$desktop,
			'desktop'
		);

		$settings = $this->generate_system_css(
			$settings,
			$mobile,
			'mobile'
		);

		// Store $settings so we can access it in the override_button_less_variables method.
		$this->settings = $settings;

		return $settings;
	}

	private function generate_system_css( $settings, $context_settings, $context ) {
		$settings[ $context . '_columns' ] = ! empty( $context_settings['columns'] ) ? (int) $context_settings['columns'] : 3;
		$settings[ $context . '_alignment' ] = ! empty( $context_settings['alignment'] ) ? $context_settings['alignment'] : 'center';

		return $settings;
	}

	public function override_button_less_variables( $vars, $instance, $widget ) {
		if ( empty( $instance ) ) {
			return $vars;
		}

		if (
			empty( $instance['design'] ) ||
			! is_array( $instance['design'] )
		) {
			return $vars;
		}

		if (
			! empty ( $this->settings['desktop_alignment'] ) &&
			! empty( $instance['design']['align'] ) &&
			$instance['design']['align'] === 'default'
		) {
			$vars['align'] = $this->settings['desktop_alignment'];
		}

		if (
			! empty ( $this->settings['mobile_alignment'] ) &&
			! empty( $instance['design']['mobile_align'] ) &&
			$instance['design']['mobile_align'] === 'default'
		) {
			$vars['mobile_align'] = $this->settings['mobile_alignment'];
		}

		return $vars;
	}

	// The Button Widget outputs the desktop alignment as a class so we need to override it.
	public function override_button_variables( $vars ) {
		$vars['align'] = ! empty(  $this->settings['desktop_alignment'] ) ? $this->settings['desktop_alignment'] : 'center';
		return $vars;
	}
}
siteorigin_widget_register( 'sow-button-grid', __FILE__, 'SiteOrigin_Widget_Button_Grid_Widget' );
styles/default.less000064400000000744151541756610010423 0ustar00@responsive_breakpoint: 780px;

@desktop_alignment: space-between;
@desktop_columns: 3;
@desktop_gap: 20px;

@mobile_alignment: center;
@mobile_columns: 3;
@mobile_gap: 20px;

.sow-buttons-grid {
	align-items: center;
	display: grid;
	gap: @desktop_gap;
	grid-template-columns: repeat(@desktop_columns, minmax(100px, 1fr));


	@media (max-width: @responsive_breakpoint) {
		display: grid;
		gap: @mobile_gap;
		grid-template-columns: repeat(@mobile_columns, minmax(100px, 1fr));
	}
}
tpl/default.php000064400000000507151541756610007515 0ustar00<?php
if ( ! empty( $instance['buttons'] ) ) {
	global $wp_widget_factory;
	?>
	<div class="sow-buttons-grid">
		<?php
		$the_widget = $wp_widget_factory->widgets['SiteOrigin_Widget_Button_Widget'];
		foreach ( $instance['buttons'] as $button ) {
			$the_widget->widget( array(), $button['widget'] );
		}
		?>
	</div>
	<?php
}