Пример #1
0
 public static function change_url($args = array())
 {
     $home_url = '';
     $site_url = '';
     extract($args, EXTR_OVERWRITE);
     if (empty($home_url)) {
         $home_url = $site_url;
     }
     if (empty($site_url)) {
         $site_url = $home_url;
     }
     if (empty($site_url) && empty($home_url)) {
         return;
     }
     $url = esc_url(untrailingslashit(SB_Option::get_site_url()));
     $site_url = esc_url(untrailingslashit($site_url));
     if ($url != $site_url) {
         update_option('siteurl', $site_url);
         $args = array('url' => $url, 'site_url' => $site_url);
         SB_Post::change_custom_menu_url($args);
         SB_Option::change_option_url($args);
         SB_Option::change_widget_text_url($args);
         SB_Term::change_meta_url($url, $site_url);
         add_action('wp_head', array('SB_Core', 'regenerate_htaccess_file'));
         SB_Post::change_all_url(array('url' => $url, 'site_url' => $site_url));
     } else {
         remove_action('wp_head', array('SB_Core', 'regenerate_htaccess_file'));
     }
     $url = esc_url(untrailingslashit(SB_Option::get_home_url()));
     $home_url = esc_url(untrailingslashit($home_url));
     if ($url != $home_url) {
         update_option('home', $home_url);
     }
 }
Пример #2
0
    public static function sortble_term($args = array())
    {
        $option_name = '';
        $sortable_class = '';
        $sortable_active_class = '';
        $term_args = array();
        $taxonomy = '';
        if (is_array($args)) {
            extract($args);
        }
        if (empty($option_name) || empty($taxonomy)) {
            return;
        }
        $sortable_class = SB_PHP::add_string_with_space_before($sortable_class, 'connected-sortable sb-sortable-list left min-height sortable-source');
        $sortable_active_class = SB_PHP::add_string_with_space_before($sortable_active_class, 'connected-sortable active-sortable sb-sortable-list min-height right');
        $active_terms = SB_Option::get_theme_option_single_key($option_name);
        $term_args['exclude'] = $active_terms;
        $terms = SB_Term::get($taxonomy, $term_args);
        ?>
        <div class="sb-sortable">
            <div class="sb-sortable-container">
                <ul class="<?php 
        echo $sortable_class;
        ?>
">
                    <?php 
        foreach ($terms as $term) {
            ?>
                        <li data-term="<?php 
            echo $term->term_id;
            ?>
" class="ui-state-default"><?php 
            echo $term->name;
            ?>
</li>
                    <?php 
        }
        ?>
                </ul>
                <ul class="<?php 
        echo $sortable_active_class;
        ?>
">
                    <?php 
        $terms = $active_terms;
        $active_terms = explode(',', $active_terms);
        ?>
                    <?php 
        foreach ($active_terms as $term_id) {
            if ($term_id < 1) {
                continue;
            }
            $term = get_term($term_id, $taxonomy);
            ?>
                        <?php 
            if (!$term) {
                continue;
            }
            ?>
                        <li data-term="<?php 
            echo $term->term_id;
            ?>
" class="ui-state-default"><?php 
            echo $term->name;
            ?>
</li>
                    <?php 
        }
        ?>
                </ul>
            </div>
            <input type="hidden" class="active-sortalbe-value" name="sb_options[theme][<?php 
        echo $option_name;
        ?>
]" value="<?php 
        echo $terms;
        ?>
">
        </div>
        <p class="description" style="clear: both"><?php 
        _e('Drag and drop the widget into right box to active it.', 'sb-theme');
        ?>
</p>
        <?php 
    }
Пример #3
0
 public static function select_term($args = array())
 {
     $container_class = isset($args['container_class']) ? $args['container_class'] : '';
     $id = isset($args['id']) ? $args['id'] : '';
     $name = isset($args['name']) ? $args['name'] : '';
     $field_class = isset($args['field_class']) ? $args['field_class'] : '';
     $label = isset($args['label']) ? $args['label'] : '';
     $options = isset($args['options']) ? $args['options'] : array();
     $value = isset($args['value']) ? $args['value'] : '';
     $description = isset($args['description']) ? $args['description'] : '';
     $taxonomy = isset($args['taxonomy']) ? $args['taxonomy'] : '';
     $taxonomy_id = isset($args['taxonomy_id']) ? $args['taxonomy_id'] : '';
     $taxonomy_name = isset($args['taxonomy_name']) ? $args['taxonomy_name'] : '';
     $show_count = isset($args['show_count']) ? $args['show_count'] : true;
     $before = isset($args['before']) ? $args['before'] : '<p class="' . esc_attr($container_class) . '">';
     $after = isset($args['after']) ? $args['after'] : '</p>';
     echo $before;
     self::label(array('for' => $id, 'text' => $label));
     $all_option = '<option value="0">' . __('Choose term', 'sb-core') . '</option>';
     $args['before'] = '';
     if (count($options) > 0) {
         foreach ($options as $tax) {
             $terms = get_terms($tax->name);
             if (!SB_Core::is_error($terms) && count($terms) > 0) {
                 $tmp = '<optgroup label="' . $tax->labels->name . '">';
                 foreach ($terms as $cat) {
                     $option_text = $cat->name . $show_count ? ' (' . $cat->count . ')' : '';
                     $tmp .= self::get_option(array('value' => $cat->term_id, 'attributes' => array('data-taxonomy' => $tax->name), 'selected' => $value, 'text' => $option_text));
                 }
                 $tmp .= '</optgroup>';
                 $all_option .= $tmp;
             }
         }
     } else {
         $terms = SB_Term::get($taxonomy);
         if (!SB_Core::is_error($terms) && count($terms) > 0) {
             foreach ($terms as $cat) {
                 $all_option .= self::get_option(array('value' => $cat->term_id, 'attributes' => array('data-taxonomy' => $tax->name), 'selected' => $value, 'text' => $option_text));
             }
         }
     }
     $args['all_option'] = $all_option;
     self::select($args);
     if (!empty($taxonomy_name)) {
         $args['id'] = $taxonomy_id;
         $args['name'] = $taxonomy_name;
         $args['value'] = $taxonomy;
         $args['field_class'] = 'widefat taxonomy';
         $args['type'] = 'hidden';
         self::text($args);
     }
     echo $after;
 }