コード例 #1
0
 function otw_tsw_init()
 {
     global $otw_tsw_plugin_url, $otw_tsw_plugin_options, $otw_tsw_shortcode_component, $otw_tsw_shortcode_object, $otw_tsw_form_component, $otw_tsw_validator_component, $otw_tsw_form_object, $otw_tsw_skin, $wp_tsw_cs_items;
     if (is_admin()) {
         add_action('admin_menu', 'otw_tsw_init_admin_menu');
         add_action('admin_print_styles', 'otw_tsw_enqueue_admin_styles');
         add_action('admin_enqueue_scripts', 'otw_tsw_enqueue_admin_scripts');
     }
     otw_tsw_enqueue_styles();
     include_once plugin_dir_path(__FILE__) . 'otw_tsw_dialog_info.php';
     //shortcode component
     $otw_tsw_shortcode_component = otw_load_component('otw_shortcode');
     $otw_tsw_shortcode_object = otw_get_component($otw_tsw_shortcode_component);
     $otw_tsw_shortcode_object->editor_button_active_for['page'] = true;
     $otw_tsw_shortcode_object->editor_button_active_for['post'] = true;
     $otw_tsw_shortcode_object->add_default_external_lib('css', 'style', get_stylesheet_directory_uri() . '/style.css', 'live_preview', 10);
     $otw_tsw_shortcode_object->shortcodes['tabslayout'] = array('title' => __('Tabs Layout', 'otw_tsw'), 'enabled' => true, 'children' => false, 'parent' => false, 'order' => 7, 'path' => dirname(__FILE__) . '/otw_components/otw_shortcode/', 'url' => $otw_tsw_plugin_url . '/include/otw_components/otw_shortcode/', 'dialog_text' => $otw_tsw_dialog_text);
     include_once plugin_dir_path(__FILE__) . 'otw_labels/otw_tsw_shortcode_object.labels.php';
     $otw_tsw_shortcode_object->init();
     //form component
     $otw_tsw_form_component = otw_load_component('otw_form');
     $otw_tsw_form_object = otw_get_component($otw_tsw_form_component);
     include_once plugin_dir_path(__FILE__) . 'otw_labels/otw_tsw_form_object.labels.php';
     $otw_tsw_form_object->init();
     //validator component
     $otw_tsw_validator_component = otw_load_component('otw_validator');
     $otw_tsw_validator_object = otw_get_component($otw_tsw_validator_component);
     $otw_tsw_validator_object->init();
 }
コード例 #2
0
ファイル: otw_functions.php プロジェクト: AttyC/elizafilby
/** init plugin
 *
 */
function otw_wpl_plugin_init()
{
    global $wp_registered_sidebars, $otw_replaced_sidebars, $wp_wpl_int_items, $otw_wpl_plugin_url, $otw_wpl_grid_manager_component, $otw_wpl_shortcode_component, $otw_wpl_form_component, $otw_wpl_grid_manager_object;
    if (is_admin()) {
        if (function_exists('otwrem_dynamic_sidebar')) {
            update_option('otw_wpl_plugin_error', '');
        }
    }
    $otw_registered_sidebars = get_option('otw_sidebars');
    $otw_widget_settings = get_option('otw_widget_settings');
    if (!is_array($otw_widget_settings)) {
        $otw_widget_settings = array();
        update_option('otw_widget_settings', $otw_widget_settings);
    }
    if (is_array($otw_registered_sidebars) && count($otw_registered_sidebars)) {
        foreach ($otw_registered_sidebars as $otw_sidebar_id => $otw_sidebar) {
            $sidebar_params = array();
            $sidebar_params['id'] = $otw_sidebar_id;
            $sidebar_params['name'] = $otw_sidebar['title'];
            $sidebar_params['description'] = $otw_sidebar['description'];
            $sidebar_params['replace'] = $otw_sidebar['replace'];
            $sidebar_params['status'] = $otw_sidebar['status'];
            if (isset($otw_sidebar['widget_alignment'])) {
                $sidebar_params['widget_alignment'] = $otw_sidebar['widget_alignment'];
            }
            $sidebar_params['validfor'] = $otw_sidebar['validfor'];
            //collect all replacements for faster search in font end
            if (strlen($sidebar_params['replace'])) {
                if (!isset($otw_replaced_sidebars[$sidebar_params['replace']])) {
                    $otw_replaced_sidebars[$sidebar_params['replace']] = array();
                }
                $otw_replaced_sidebars[$sidebar_params['replace']][$sidebar_params['id']] = $sidebar_params['id'];
                if (isset($wp_registered_sidebars[$sidebar_params['replace']])) {
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['class'])) {
                        $sidebar_params['class'] = $wp_registered_sidebars[$sidebar_params['replace']]['class'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['before_widget'])) {
                        $sidebar_params['before_widget'] = $wp_registered_sidebars[$sidebar_params['replace']]['before_widget'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['after_widget'])) {
                        $sidebar_params['after_widget'] = $wp_registered_sidebars[$sidebar_params['replace']]['after_widget'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['before_title'])) {
                        $sidebar_params['before_title'] = $wp_registered_sidebars[$sidebar_params['replace']]['before_title'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['after_title'])) {
                        $sidebar_params['after_title'] = $wp_registered_sidebars[$sidebar_params['replace']]['after_title'];
                    }
                }
            } else {
                $sidebar_params['before_widget'] = '';
                $sidebar_params['after_widget'] = '';
            }
            register_sidebar($sidebar_params);
        }
    }
    //apply validfor settings to all sidebars
    if (is_array($wp_registered_sidebars) && count($wp_registered_sidebars)) {
        foreach ($wp_registered_sidebars as $wp_widget_key => $wo_widget_data) {
            if (array_key_exists($wp_widget_key, $otw_widget_settings)) {
                $wp_registered_sidebars[$wp_widget_key]['widgets_settings'] = $otw_widget_settings[$wp_widget_key];
            } else {
                $wp_registered_sidebars[$wp_widget_key]['widgets_settings'] = array();
            }
        }
    }
    //otw grid manager component
    include_once plugin_dir_path(__FILE__) . 'otw_wpl_grid_meta_info.php';
    $otw_wpl_grid_manager_component = otw_load_component('otw_grid_manager');
    $otw_wpl_grid_manager_object = otw_get_component($otw_wpl_grid_manager_component);
    $otw_wpl_grid_manager_object->active_for_posts = true;
    $otw_wpl_grid_manager_object->meta_info = $otw_wpl_grid_meta_info;
    include_once plugin_dir_path(__FILE__) . 'otw_labels/otw_sbm_grid_manager_object.labels.php';
    $otw_wpl_grid_manager_object->init();
    //shortcode component
    $otw_wpl_shortcode_component = otw_load_component('otw_shortcode');
    $otw_wpl_shortcode_object = otw_get_component($otw_wpl_shortcode_component);
    $otw_wpl_shortcode_object->shortcodes['sidebar'] = array('title' => __('OTW Sidebar', 'widgetize-pages-light'), 'enabled' => true, 'children' => false, 'order' => 100000, 'path' => dirname(__FILE__) . '/otw_components/otw_shortcode/', 'url' => $otw_wpl_plugin_url . 'include/otw_components/otw_shortcode/');
    include_once plugin_dir_path(__FILE__) . 'otw_labels/otw_sbm_shortcode_object.labels.php';
    $otw_wpl_shortcode_object->init();
    //form component
    $otw_wpl_form_component = otw_load_component('otw_form');
    $otw_wpl_form_object = otw_get_component($otw_wpl_form_component);
    include_once plugin_dir_path(__FILE__) . 'otw_labels/otw_sbm_form_object.labels.php';
    $otw_wpl_form_object->init();
    if (is_admin()) {
        require_once plugin_dir_path(__FILE__) . '/otw_process_actions.php';
        if (get_user_option('rich_editing')) {
            add_filter('mce_external_plugins', 'add_otw_wpl_tinymce_plugin');
            add_filter('mce_buttons', 'register_otw_wpl_tinymce_button');
        }
    } else {
    }
}
コード例 #3
0
ファイル: otw_sidebar_manager.php プロジェクト: phupx/genco
/** init otw sidebars
 *
 */
function otw_sidebar_init()
{
    global $wp_registered_sidebars, $otw_replaced_sidebars, $wp_sbm_int_items, $otw_sbm_plugin_url, $pagenow, $otw_sbm_grid_manager_component, $otw_sbm_shortcode_component, $otw_sbm_form_component, $otw_sbm_grid_manager_object, $otw_sbm_widget_settings, $otw_plugin_options;
    otw_sidebar_add_items();
    $otw_registered_sidebars = get_option('otw_sidebars');
    $otw_widget_settings = get_option('otw_widget_settings');
    if (!is_array($otw_widget_settings)) {
        $otw_widget_settings = array();
        update_option('otw_widget_settings', $otw_widget_settings);
    }
    if (is_array($otw_registered_sidebars) && count($otw_registered_sidebars)) {
        foreach ($otw_registered_sidebars as $otw_sidebar_id => $otw_sidebar) {
            $sidebar_params = array();
            $sidebar_params['id'] = $otw_sidebar_id;
            $sidebar_params['name'] = $otw_sidebar['title'];
            $sidebar_params['description'] = $otw_sidebar['description'];
            $sidebar_params['replace'] = $otw_sidebar['replace'];
            $sidebar_params['status'] = $otw_sidebar['status'];
            if (isset($otw_sidebar['widget_alignment'])) {
                $sidebar_params['widget_alignment'] = $otw_sidebar['widget_alignment'];
            }
            $sidebar_params['validfor'] = $otw_sidebar['validfor'];
            if (isset($otw_sidebar['exclude_posts_for'])) {
                $sidebar_params['exclude_posts_for'] = $otw_sidebar['exclude_posts_for'];
            }
            //collect all replacements for faster search in font end
            if (strlen($sidebar_params['replace'])) {
                if (!isset($otw_replaced_sidebars[$sidebar_params['replace']])) {
                    $otw_replaced_sidebars[$sidebar_params['replace']] = array();
                }
                $otw_replaced_sidebars[$sidebar_params['replace']][$sidebar_params['id']] = $sidebar_params['id'];
                if (isset($wp_registered_sidebars[$sidebar_params['replace']])) {
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['class'])) {
                        $sidebar_params['class'] = $wp_registered_sidebars[$sidebar_params['replace']]['class'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['before_widget'])) {
                        $sidebar_params['before_widget'] = $wp_registered_sidebars[$sidebar_params['replace']]['before_widget'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['after_widget'])) {
                        $sidebar_params['after_widget'] = $wp_registered_sidebars[$sidebar_params['replace']]['after_widget'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['before_title'])) {
                        $sidebar_params['before_title'] = $wp_registered_sidebars[$sidebar_params['replace']]['before_title'];
                    }
                    if (isset($wp_registered_sidebars[$sidebar_params['replace']]['after_title'])) {
                        $sidebar_params['after_title'] = $wp_registered_sidebars[$sidebar_params['replace']]['after_title'];
                    }
                }
            } else {
                foreach ($otw_sbm_widget_settings as $s_type => $s_data) {
                    if (isset($otw_plugin_options['otw_sbm_' . $s_type])) {
                        $sidebar_params[$s_type] = $otw_plugin_options['otw_sbm_' . $s_type];
                    } else {
                        $sidebar_params[$s_type] = $s_data[1];
                    }
                }
            }
            register_sidebar($sidebar_params);
        }
    }
    //apply validfor settings to all sidebars
    if (is_array($wp_registered_sidebars) && count($wp_registered_sidebars)) {
        foreach ($wp_registered_sidebars as $wp_widget_key => $wo_widget_data) {
            if (array_key_exists($wp_widget_key, $otw_widget_settings)) {
                $wp_registered_sidebars[$wp_widget_key]['widgets_settings'] = $otw_widget_settings[$wp_widget_key];
            } else {
                $wp_registered_sidebars[$wp_widget_key]['widgets_settings'] = array();
            }
        }
    }
    $custom_post_types = get_post_types(array('public' => true, '_builtin' => false), 'object');
    if (is_array($custom_post_types)) {
        foreach ($custom_post_types as $c_key => $c_cust) {
            if (otw_installed_plugin('bbpress') && $c_key == 'reply') {
                //skip reply they appear on same pages as topics
            } else {
                $wp_sbm_int_items['cpt_' . $c_cust->name] = array(array(), $c_cust->label, __('All ', 'otw_sbm') . $c_cust->labels->name);
            }
        }
    }
    $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'object');
    if (is_array($custom_taxonomies)) {
        foreach ($custom_taxonomies as $c_cust) {
            $wp_sbm_int_items['ctx_' . $c_cust->name] = array(array(), $c_cust->label . ' ' . __('archives', 'otw_sbm'), __('All ', 'otw_sbm') . $c_cust->label . ' ' . __('archives', 'otw_sbm'));
            foreach ($c_cust->object_type as $c_object) {
                if ($c_object_info = get_post_type_object($c_object)) {
                    $wp_sbm_int_items[$c_object . '_in_ctx_' . $c_cust->name] = array(array(), __('All', 'otw_sbm') . ' ' . $c_object_info->labels->name . ' ' . __('from taxonomy', 'otw_sbm') . ' ' . $c_cust->label, __('All', 'otw_sbm') . ' ' . $c_object_info->labels->name . ' ' . __('from taxonomy', 'otw_sbm') . ' ' . $c_cust->label);
                }
            }
        }
    }
    //otw grid manager component
    $otw_sbm_grid_manager_component = otw_load_component('otw_grid_manager');
    $otw_sbm_grid_manager_object = otw_get_component($otw_sbm_grid_manager_component);
    if (isset($otw_plugin_options['otw_gm_metabox_for'])) {
        $otw_sbm_grid_manager_object->show_metabox_for = $otw_plugin_options['otw_gm_metabox_for'];
    }
    include_once plugin_dir_path(__FILE__) . 'include/otw_labels/otw_sbm_grid_manager_object.labels.php';
    $otw_sbm_grid_manager_object->init();
    //shortcode component
    $otw_sbm_shortcode_component = otw_load_component('otw_shortcode');
    $otw_sbm_shortcode_object = otw_get_component($otw_sbm_shortcode_component);
    $otw_sbm_shortcode_object->shortcodes['sidebars'] = array('title' => __('Sidebars', 'otw_sbm'), 'enabled' => true, 'children' => false, 'order' => 132, 'parent' => false, 'path' => dirname(__FILE__) . '/include/otw_components/otw_shortcode/', 'url' => $otw_sbm_plugin_url . '/include/otw_components/otw_shortcode/');
    $otw_sbm_shortcode_object->shortcodes['sidebar'] = array('title' => __('OTW Sidebar', 'otw_sbm'), 'enabled' => false, 'children' => false, 'order' => 100000, 'path' => dirname(__FILE__) . '/include/otw_components/otw_shortcode/', 'url' => $otw_sbm_plugin_url . '/include/otw_components/otw_shortcode/');
    include_once plugin_dir_path(__FILE__) . 'include/otw_labels/otw_sbm_shortcode_object.labels.php';
    $otw_sbm_shortcode_object->init();
    //form component
    $otw_sbm_form_component = otw_load_component('otw_form');
    $otw_sbm_form_object = otw_get_component($otw_sbm_form_component);
    include_once plugin_dir_path(__FILE__) . 'include/otw_labels/otw_sbm_form_object.labels.php';
    $otw_sbm_form_object->init();
    $otw_sbm_content_sidebars_component = otw_load_component('otw_content_sidebars');
    $otw_sbm_content_sidebars_object = otw_get_component($otw_sbm_content_sidebars_component);
    $otw_sbm_content_sidebars_object->meta_name = 'otw_content_sidebars_settings';
    if (isset($otw_plugin_options['otw_cs_metabox_for'])) {
        $otw_sbm_content_sidebars_object->show_metabox_for = $otw_plugin_options['otw_cs_metabox_for'];
    }
    include_once plugin_dir_path(__FILE__) . 'include/otw_labels/otw_sbm_content_sidebars_object.labels.php';
    $otw_sbm_content_sidebars_object->init();
    if (is_admin()) {
        require_once plugin_dir_path(__FILE__) . '/include/otw_process_actions.php';
        /*
        		if( get_user_option('rich_editing') ){
        			
        			add_filter('mce_external_plugins', 'add_otw_tinymce_plugin');
        			add_filter('mce_buttons', 'register_otw_tinymce_button');
        		}*/
        add_action('add_meta_boxes', 'otw_sbm_meta_boxes');
        add_action('save_post', 'otw_sbm_pcm_save');
    } else {
        wp_register_style('otw_sbm.css', $otw_sbm_plugin_url . '/css/otw_sbm.css');
        wp_enqueue_style('otw_sbm.css');
        add_filter('the_content', 'otw_sbm_pcm_show');
    }
}