コード例 #1
0
 function initialize()
 {
     // This widget requires the button widget
     if (!class_exists('SiteOrigin_Widget_Button_Widget')) {
         SiteOrigin_Widgets_Bundle::single()->include_widget('so-button-widget');
     }
     // Let the slider base class do its initialization
     parent::initialize();
 }
コード例 #2
0
ファイル: cta.php プロジェクト: GvarimAZA/website
 /**
  * Initialize the CTA widget
  */
 function initialize()
 {
     // This widget requires the button widget
     if (!class_exists('SiteOrigin_Widget_Button_Widget')) {
         SiteOrigin_Widgets_Bundle::single()->include_widget('button');
     }
     $this->register_frontend_styles(array(array('sow-cta-main', plugin_dir_url(__FILE__) . 'css/style.css', array(), SOW_BUNDLE_VERSION)));
     $this->register_frontend_scripts(array(array('sow-cta-main', plugin_dir_url(__FILE__) . 'js/cta' . SOW_BUNDLE_JS_SUFFIX . '.js', array('jquery'), SOW_BUNDLE_VERSION)));
 }
コード例 #3
0
ファイル: hero.php プロジェクト: JasonAJames/jasonajamescom
 function initialize()
 {
     // This widget requires the button widget
     if (!class_exists('SiteOrigin_Widget_Button_Widget')) {
         SiteOrigin_Widgets_Bundle::single()->include_widget('button');
     }
     add_filter('siteorigin_widgets_wrapper_classes_' . $this->id_base, array($this, 'wrapper_class_filter'), 10, 2);
     // Let the slider base class do its initialization
     parent::initialize();
 }
コード例 #4
0
    /**
     * Display the admin page.
     */
    function admin_page()
    {
        $bundle = SiteOrigin_Widgets_Bundle::single();
        $widgets = $bundle->get_widgets_list();
        if (isset($_GET['widget_action_done']) && !empty($_GET['widget_action']) && !empty($_GET['widget']) && !empty($widgets[$_GET['widget'] . '/' . $_GET['widget'] . '.php'])) {
            ?>
			<div class="updated">
				<p>
				<?php 
            printf(__('%s was %s', 'so-widgets-bundle'), $widgets[$_GET['widget'] . '/' . $_GET['widget'] . '.php']['Name'], $_GET['widget_action'] == 'activate' ? __('Activated', 'so-widgets-bundle') : __('Deactivated', 'so-widgets-bundle'));
            ?>
				</p>
			</div>
			<?php 
        }
        include plugin_dir_path(__FILE__) . 'admin/tpl/admin.php';
    }
コード例 #5
0
ファイル: settings.php プロジェクト: phowong/nhic-project
/**
 * Render a settings field.
 *
 * @param $args
 */
function siteorigin_settings_field($args)
{
    $field_name = $GLOBALS['siteorigin_settings_name'] . '[' . $args['section'] . '_' . $args['field'] . ']';
    $field_id = $args['section'] . '_' . $args['field'];
    $current = isset($GLOBALS['siteorigin_settings'][$field_id]) ? $GLOBALS['siteorigin_settings'][$field_id] : null;
    switch ($args['type']) {
        case 'checkbox':
            ?>
			<div class="checkbox-wrapper">
				<input id="<?php 
            echo esc_attr($field_id);
            ?>
" name="<?php 
            echo esc_attr($field_name);
            ?>
" type="checkbox" <?php 
            checked($current);
            ?>
 />
				<label for="<?php 
            echo esc_attr($field_id);
            ?>
"><?php 
            echo esc_attr(!empty($args['label']) ? $args['label'] : __('Enabled', 'focus'));
            ?>
</label>
			</div>
			<?php 
            break;
        case 'text':
        case 'number':
            ?>
			<input
				id="<?php 
            echo esc_attr($field_id);
            ?>
"
				name="<?php 
            echo esc_attr($field_name);
            ?>
"
				class="<?php 
            echo esc_attr($args['type'] == 'number' ? 'small-text' : 'regular-text');
            if (!empty($args['options'])) {
                echo ' siteorigin-settings-has-options';
            }
            ?>
"
				size="25"
				type="<?php 
            echo esc_attr($args['type']);
            ?>
"
				value="<?php 
            echo esc_attr($current);
            ?>
" />
			<?php 
            if (!empty($args['options'])) {
                $args['options'] = apply_filters('siteorigin_setting_options_' . $field_id, $args['options']);
                ?>
				<select class="input-field-select">
					<option></option>
					<?php 
                foreach ($args['options'] as $value => $label) {
                    ?>
						<option value="<?php 
                    echo esc_attr($value);
                    ?>
"><?php 
                    echo esc_html($label);
                    ?>
</option>
					<?php 
                }
                ?>
				</select>
			<?php 
            }
            break;
        case 'select':
            $args['options'] = apply_filters('siteorigin_setting_options_' . $field_id, $args['options']);
            ?>
			<select id="<?php 
            echo esc_attr($field_id);
            ?>
" name="<?php 
            echo esc_attr($field_name);
            ?>
">
				<?php 
            foreach ($args['options'] as $option_id => $label) {
                ?>
					<option value="<?php 
                echo esc_attr($option_id);
                ?>
" <?php 
                selected($option_id, $current);
                ?>
><?php 
                echo esc_attr($label);
                ?>
</option>
				<?php 
            }
            ?>
			</select>
			<?php 
            break;
        case 'textarea':
            ?>
<textarea id="<?php 
            echo esc_attr($field_id);
            ?>
" name="<?php 
            echo esc_attr($field_name);
            ?>
" class="large-text" rows="3"><?php 
            echo esc_textarea($current);
            ?>
</textarea><?php 
            break;
        case 'color':
            if (wp_script_is('wp-color-picker', 'registered')) {
                ?>
<input type="text" value="<?php 
                echo esc_attr($current);
                ?>
" class="color-field" name="<?php 
                echo esc_attr($field_name);
                ?>
" /><?php 
            } else {
                ?>
				<div class="colorpicker-wrapper">
					<div class="color-indicator" style="background-color: <?php 
                echo esc_attr($current);
                ?>
"></div>
					<input type="text" id="<?php 
                echo esc_attr($field_id);
                ?>
" value="<?php 
                echo esc_attr($current);
                ?>
" name="<?php 
                echo esc_attr($field_name);
                ?>
" />

					<div class="farbtastic-container"></div>
				</div>
				<?php 
            }
            break;
        case 'media':
            if (version_compare(get_bloginfo('version'), '3.5', '<')) {
                printf(__('You need to <a href="%s">upgrade</a> to WordPress 3.5 to use media fields', 'focus'), admin_url('update-core.php'));
                break;
            }
            if (!empty($current)) {
                if (is_array($current)) {
                    $src = $current;
                } else {
                    $post = get_post($current);
                    $src = wp_get_attachment_image_src($current, 'thumbnail');
                    if (empty($src)) {
                        $src = wp_get_attachment_image_src($current, 'thumbnail', true);
                    }
                }
            } else {
                $src = array('', 0, 0);
            }
            $choose_title = empty($args['choose']) ? __('Choose Media', 'focus') : $args['choose'];
            $update_button = empty($args['update']) ? __('Set Media', 'focus') : $args['update'];
            ?>
				<div class="media-field-wrapper">
					<div class="current">
						<div class="thumbnail-wrapper">
							<img src="<?php 
            echo esc_url($src[0]);
            ?>
" class="thumbnail" <?php 
            if (empty($src[0])) {
                echo "style='display:none'";
            }
            ?>
 />
						</div>
						<div class="title"><?php 
            if (!empty($post)) {
                echo esc_attr($post->post_title);
            }
            ?>
</div>
					</div>
					<a href="#" class="media-upload-button" data-choose="<?php 
            echo esc_attr($choose_title);
            ?>
" data-update="<?php 
            echo esc_attr($update_button);
            ?>
">
						<?php 
            echo esc_html($choose_title);
            ?>
					</a>

					<a href="#" class="media-remove-button"><?php 
            _e('Remove', 'focus');
            ?>
</a>
				</div>

				<input type="hidden" id="<?php 
            echo esc_attr($field_id);
            ?>
" value="<?php 
            echo esc_attr(is_array($current) ? '-1' : $current);
            ?>
" name="<?php 
            echo esc_attr($field_name);
            ?>
" />
				<div class="clear"></div>
			<?php 
            break;
        case 'teaser':
            $theme = get_option('template');
            ?>
			<a class="premium-teaser siteorigin-premium-teaser" href="<?php 
            echo admin_url('themes.php?page=premium_upgrade');
            ?>
" target="_blank">
				<em></em>
				<?php 
            printf(__('Only available in <strong>%s</strong> - <strong class="upgrade">Upgrade Now</strong>', 'focus'), apply_filters('siteorigin_premium_theme_name', ucfirst($theme) . ' ' . __('Premium', 'focus')));
            ?>
				<?php 
            if (!empty($args['teaser-image'])) {
                ?>
					<div class="teaser-image"><img src="<?php 
                echo esc_url($args['teaser-image']);
                ?>
" width="220" height="120" /><div class="pointer"></div></div>
				<?php 
            }
            ?>
			</a>
			<?php 
            break;
        case 'gallery':
            ?>
			<input
				id="<?php 
            echo esc_attr($field_id);
            ?>
"
				name="<?php 
            echo esc_attr($field_name);
            ?>
"
				class="regular-text gallery-ids"
				size="25"
				type="text"
				value="<?php 
            echo esc_attr($current);
            ?>
" />
			<a href="#" class="so-settings-gallery-edit"><?php 
            _e('Select Images', 'focus');
            ?>
</a>
			<?php 
            break;
        case 'pages':
            $pages = get_posts(array('post_type' => 'page', 'numberposts' => 200, 'post_status' => empty($args['unpublished']) ? 'publish' : 'any'));
            ?>
			<select id="<?php 
            echo esc_attr($field_id);
            ?>
" name="<?php 
            echo esc_attr($field_name);
            ?>
">
				<option value="0"><?php 
            _e('None', 'focus');
            ?>
</option>
				<?php 
            foreach ($pages as $page) {
                ?>
					<option value="<?php 
                echo $page->ID;
                ?>
" <?php 
                selected($page->ID, $current);
                ?>
><?php 
                echo esc_attr($page->post_title);
                ?>
</option>
				<?php 
            }
            ?>
			</select>
			<?php 
            break;
        case 'editor':
            $editor_settings = wp_parse_args(!empty($args['settings']) ? $args['settings'] : array(), array('textarea_name' => $field_name, 'textarea_rows' => 8));
            wp_editor($current, $field_id, $editor_settings);
            break;
        case 'widget':
            if (empty($args['widget_class'])) {
                break;
            }
            if (!class_exists($args['widget_class']) && !empty($args['bundle_widget']) && class_exists('SiteOrigin_Widgets_Bundle')) {
                // If this is a widget bundle widget, and the class isn't available, then try activate it.
                SiteOrigin_Widgets_Bundle::single()->activate_widget($args['bundle_widget']);
            }
            if (!class_exists($args['widget_class'])) {
                // Display the message prompting the user to install the widget plugin from WordPress.org
                ?>
<div class="so-settings-widget-form"><?php 
                printf(__('This field requires the %s plugin. ', 'focus'), $args['plugin_name']);
                if (function_exists('siteorigin_plugin_activation_install_url')) {
                    $install_url = siteorigin_plugin_activation_install_url($args['plugin'], $args['plugin_name']);
                    printf(__('<a href="%s" target="_blank">Install %s</a> now. ', 'focus'), $install_url, $args['plugin_name']);
                }
                ?>
</div>
				<input type="hidden" id="<?php 
                echo esc_attr($field_id);
                ?>
" name="<?php 
                echo esc_attr($field_name);
                ?>
" value="<?php 
                echo esc_attr(serialize($current));
                ?>
" /><?php 
            } else {
                // Render the widget form
                $the_widget = new $args['widget_class']();
                $the_widget->id = $field_id;
                $the_widget->number = $field_id;
                ob_start();
                $the_widget->form($current);
                $form = ob_get_clean();
                // Convert the widget field naming into ones that Settings will use
                $exp = preg_quote($the_widget->get_field_name('____'));
                $exp = str_replace('____', '(.*?)', $exp);
                $form = preg_replace('/' . $exp . '/', 'siteorigin_settings_widget[' . preg_quote($field_id) . '][$1]', $form);
                echo '<div class="so-settings-widget-form"><a href="#" class="so-settings-widget-edit" data-is-setup="0" data-form="' . esc_attr($form) . '">' . __('Edit', 'focus') . '</a></div>';
                ?>
<input type="hidden" id="<?php 
                echo esc_attr($field_id);
                ?>
" name="<?php 
                echo esc_attr($field_name);
                ?>
" value="<?php 
                echo esc_attr(serialize($current));
                ?>
" /><?php 
            }
            break;
        default:
            _e('Unknown Field Type', 'focus');
            break;
    }
    if (!empty($args['description'])) {
        echo '<p class="description">' . $args['description'] . '</p>';
    }
}
コード例 #6
0
     */
    function enqueue_active_widgets_scripts()
    {
        global $wp_registered_widgets;
        $sidebars_widgets = wp_get_sidebars_widgets();
        if (empty($sidebars_widgets)) {
            return;
        }
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if (!empty($widgets) && $sidebar !== "wp_inactive_widgets") {
                foreach ($widgets as $i => $id) {
                    if (!empty($wp_registered_widgets[$id])) {
                        $widget = $wp_registered_widgets[$id]['callback'][0];
                        if (!empty($widget) && is_object($widget) && is_subclass_of($widget, 'SiteOrigin_Widget') && is_active_widget(false, false, $widget->id_base)) {
                            $opt_wid = get_option('widget_' . $widget->id_base);
                            preg_match('/-([0-9]+$)/', $id, $num_match);
                            $widget_instance = $opt_wid[$num_match[1]];
                            $widget->enqueue_frontend_scripts($widget_instance);
                            $widget->generate_and_enqueue_instance_styles($widget_instance);
                        }
                    }
                }
            }
        }
    }
}
// create the initial single
SiteOrigin_Widgets_Bundle::single();
// Initialize the Meta Box Manager
global $sow_meta_box_manager;
$sow_meta_box_manager = SiteOrigin_Widget_Meta_Box_Manager::single();