public static function add_recaptcha_setting_field_callback()
 {
     $options = SB_Option::get();
     $value = isset($options['global']['recaptcha']['site_key']) ? $options['global']['recaptcha']['site_key'] : '';
     $args = array('id' => 'sb_core_global_recaptcha_site_key', 'name' => SB_Option::build_sb_option_name(array('global', 'recaptcha', 'site_key')), 'value' => $value, 'description' => __('The Google reCaptcha Site key, you can use this in the HTML code your site serves to users.', 'sb-core'), 'container_class' => 'margin-bottom');
     SB_Field::text($args);
     $value = isset($options['global']['recaptcha']['secret_key']) ? $options['global']['recaptcha']['secret_key'] : '';
     $args = array('id' => 'sb_core_global_recaptcha_secret_key', 'name' => SB_Option::build_sb_option_name(array('global', 'recaptcha', 'secret_key')), 'value' => $value, 'description' => __('The reCaptcha Secret key, you can use this for communication between your site and Google.', 'sb-core'));
     SB_Field::text($args);
 }
function sb_ui_reset_ajax_callback()
{
    $type = isset($_POST['data_type']) ? $_POST['data_type'] : '';
    switch ($type) {
        case 'rss_feed':
            $options = SB_Option::get();
            unset($options['theme']['rss_feed']);
            SB_Option::update($options);
            break;
    }
    die;
}
 public static function change_meta_url($old_url, $new_url)
 {
     $metas = SB_Option::get_term_metas();
     if (!is_array($metas)) {
         return;
     }
     $new_metas = array();
     foreach ($metas as $key => $meta) {
         if (isset($meta['thumbnail'])) {
             $meta['thumbnail'] = str_replace($old_url, $new_url, $meta['thumbnail']);
         }
         $new_metas[$key] = $meta;
     }
     SB_Option::update_term_metas($new_metas);
 }
 public function save($term_id)
 {
     if (!SB_Core::verify_nonce('sb_term_meta', 'sb_term_meta_nonce')) {
         return $term_id;
     }
     $taxonomy = isset($_POST['taxonomy']) ? $_POST['taxonomy'] : '';
     $sb_term_metas = SB_Option::get_term_metas();
     foreach ($this->fields as $field) {
         $name = isset($field['name']) ? $field['name'] : '';
         $value = isset($_POST[$name]) ? $_POST[$name] : '';
         $sb_term_metas[$term_id][$name] = $value;
         $sb_term_metas[$term_id]['taxonomy'] = $taxonomy;
     }
     SB_Option::update_term_metas($sb_term_metas);
     return $term_id;
 }
    public static function datetime($args = array())
    {
        $name = self::get_name($args);
        $value = isset($args['value']) ? $args['value'] : '';
        $field_class = isset($args['field_class']) ? trim($args['field_class']) : '';
        $label = isset($args['label']) ? $args['label'] : '';
        $date_format = isset($args['date_format']) ? $args['date_format'] : SB_Option::get_date_format();
        if (!empty($value)) {
            $value = date($date_format, $value);
        }
        if ($value == 0) {
            $value = '';
        }
        $field_class = SB_PHP::add_string_with_space_before($field_class, 'sb-datetime');
        $current = isset($args['current']) ? $args['current'] : false;
        if ($current && empty($value)) {
            $value = date($date_format);
        }
        ?>
        <p>
            <label for="<?php 
        echo esc_attr($name);
        ?>
"><?php 
        echo $label;
        ?>
:</label>
            <input type="text" id="<?php 
        echo esc_attr($name);
        ?>
" name="<?php 
        echo esc_attr($name);
        ?>
" value="<?php 
        echo $value;
        ?>
" class="<?php 
        echo $field_class;
        ?>
" placeholder="<?php 
        echo $date_format;
        ?>
" autocomplete="off">
        </p>
    <?php 
    }
 public function get_items($args = array())
 {
     $result = array();
     $this->fetch($args);
     if (is_array($this->items)) {
         $items = $this->items;
         foreach ($items as $item) {
             $description = $item->get_description();
             $thumbnail = SB_PHP::get_first_image($description);
             $description = strip_tags($description);
             $description = wp_strip_all_tags($description);
             $content = $item->get_content();
             if (empty($thumbnail)) {
                 $thumbnail = SB_PHP::get_first_image($content);
             }
             $value = array('permalink' => $item->get_permalink(), 'title' => $item->get_title(), 'date' => $item->get_date(SB_Option::get_date_time_format()), 'image_url' => $thumbnail, 'description' => $description, 'content' => $content);
             array_push($result, $value);
         }
     }
     return $result;
 }
    public static function rss_feed($args = array())
    {
        $id = '';
        $name = '';
        $list_feeds = array();
        $description = '';
        $order = '';
        if (is_array($args)) {
            extract($args, EXTR_OVERWRITE);
        }
        $count = SB_Option::get_theme_option(array('keys' => array('rss_feed', 'count')));
        if ($count > count($list_feeds)) {
            $count = count($list_feeds);
        }
        $real_count = $count;
        $next_id = 1;
        ?>
        <div id="<?php 
        echo $id;
        ?>
" class="sb-addable rss-feed min-height relative gray-bg border padding-10 sb-ui-panel">
            <div class="item-group">
                <ul class="sb-sortable-list" data-message-confirm="<?php 
        _e('Are you sure you want to delete?', 'sb-core');
        ?>
">
                    <?php 
        if ($count == 0) {
            ?>
                        <?php 
            $count++;
            ?>
                        <?php 
            SB_Admin_Custom::set_current_rss_feed_item(array('name' => $name, 'count' => $count));
            ?>
                        <?php 
            sb_core_get_loop('loop-rss-feed');
            ?>
                        <?php 
            $real_count = $count;
            ?>
                        <?php 
            $order = $count;
            ?>
                        <?php 
            $next_id++;
            ?>
                    <?php 
        }
        ?>
                    <?php 
        if ($count > 0) {
            ?>
                        <?php 
            $new_count = 1;
            ?>
                        <?php 
            foreach ($list_feeds as $feed) {
                ?>
                            <?php 
                $feed_id = isset($feed['id']) ? $feed['id'] : 0;
                if ($feed_id >= $next_id) {
                    $next_id = $feed_id + 1;
                }
                ?>
                            <?php 
                SB_Admin_Custom::set_current_rss_feed_item(array('feed' => $feed, 'count' => $new_count, 'name' => $name));
                ?>
                            <?php 
                sb_core_get_loop('loop-rss-feed');
                ?>
                            <?php 
                $new_count++;
                ?>

                        <?php 
            }
            ?>
                    <?php 
        }
        ?>
                </ul>
                <input type="hidden" name="<?php 
        echo $name;
        ?>
[order]" value="<?php 
        echo $order;
        ?>
" class="ui-item-order item-order" autocomplete="off">
                <input type="hidden" name="<?php 
        echo $name;
        ?>
[count]" value="<?php 
        echo $real_count;
        ?>
" class="ui-item-count item-count" autocomplete="off">
            </div>
            <button class="button add-item ui-add-item absolute" data-type="rss_feed" data-name="<?php 
        echo $name;
        ?>
" data-count="<?php 
        echo $count;
        ?>
" data-next-id="<?php 
        echo $next_id;
        ?>
"><?php 
        _e('Add new', 'sb-core');
        ?>
</button>
            <button class="button reset-item ui-reset-item absolute reset" data-type="rss_feed"><?php 
        _e('Reset', 'sb-core');
        ?>
 <img src="<?php 
        echo SB_CORE_URL;
        ?>
/images/ajax-loader.gif"></button>
        </div>
        <?php 
        if (!empty($description)) {
            ?>
            <p class="description"><?php 
            _e($description, 'sb-core');
            ?>
</p>
        <?php 
        }
        ?>
        <?php 
    }
 public static function change_custom_menu_url($args = array())
 {
     $site_url = isset($args['site_url']) ? $args['site_url'] : '';
     $url = isset($args['url']) ? $args['url'] : '';
     if (empty($url)) {
         $url = SB_Option::get_site_url();
     }
     if (empty($site_url) || $url == $site_url) {
         return;
     }
     $menu_items = self::get_menu_custom_items();
     if (!is_array($menu_items)) {
         return;
     }
     foreach ($menu_items as $item) {
         if ('trang-chu' == $item->post_name || 'home' == $item->post_name) {
             $item_url = $item->url;
             $item_url = mb_ereg_replace($url, $site_url, $item_url);
             SB_Post::update_custom_menu_url($item->ID, $item_url);
         }
     }
 }
 public function sanitize($input)
 {
     $options = SB_Option::get();
     $input = wp_parse_args($input, $options);
     return apply_filters('sb_options_sanitize', $input);
 }
Exemple #10
0
 public static function get_social_share_url($args = array())
 {
     $result = '';
     $title = get_the_title();
     $permalink = get_the_permalink();
     $url = $permalink;
     $social_name = '';
     $thumbnail = '';
     $excerpt = get_the_excerpt();
     $language = SB_Option::get_default_language();
     $twitter_account = 'skylarkcob';
     extract($args, EXTR_OVERWRITE);
     $permalink = urlencode($permalink);
     if (empty($twitter_account)) {
         $twitter_account = SB_Option::get_theme_social('twitter');
         $twitter_account = basename($twitter_account);
     }
     switch ($social_name) {
         case 'email':
             $result = 'mailto:email@hocwp.net?subject=' . $title . '&amp;body=' . $permalink;
             break;
         case 'facebook':
             $url = 'https://www.facebook.com/sharer/sharer.php';
             $url = add_query_arg('u', $permalink, $url);
             if (!empty($title)) {
                 $url = add_query_arg('t', $title, $url);
             }
             $result = $url;
             break;
         case 'googleplus':
             $url = 'http://plusone.google.com/_/+1/confirm';
             $url = add_query_arg('hl', $language, $url);
             $url = add_query_arg('url', $permalink, $url);
             $result = $url;
             break;
         case 'twitter':
             $url = 'http://twitter.com/share';
             $url = add_query_arg('url', $permalink, $url);
             if (!empty($title)) {
                 $url = add_query_arg('text', $title, $url);
             }
             $url = add_query_arg('via', $twitter_account, $url);
             $result = $url;
             break;
         case 'pinterest':
             $url = 'http://www.pinterest.com/pin/create/button';
             if (!empty($thumbnail)) {
                 $url = add_query_arg('media', $thumbnail, $url);
             }
             $url = add_query_arg('url', $permalink, $url);
             if (!empty($title)) {
                 $url = add_query_arg('description', $title . ' ' . $permalink, $url);
             }
             $result = $url;
             break;
         case 'zingme':
             $url = 'http://link.apps.zing.vn/share';
             if (!empty($title)) {
                 $url = add_query_arg('t', $title, $url);
             }
             $url = add_query_arg('u', $permalink, $url);
             if (!empty($excerpt)) {
                 $url = add_query_arg('desc', $excerpt, $url);
             }
             $result = $url;
             break;
     }
     return $result;
 }
    public static function rss_feed($args = array())
    {
        $id = isset($args['id']) ? $args['id'] : '';
        $name = isset($args['name']) ? $args['name'] : '';
        $list_feeds = isset($args['list_feeds']) ? $args['list_feeds'] : array();
        $description = isset($args['description']) ? $args['description'] : '';
        $order = isset($args['order']) ? $args['order'] : '';
        $count = SB_Option::get_theme_option(array('keys' => array('rss_feed', 'count')));
        if ($count > count($list_feeds)) {
            $count = count($list_feeds);
        }
        $real_count = $count;
        $next_id = 1;
        ?>
        <div id="<?php 
        echo esc_attr($id);
        ?>
" class="sb-addable rss-feed min-height relative gray-bg border padding-10 sb-ui-panel">
            <div class="item-group">
                <ul class="sb-sortable-list" data-message-confirm="<?php 
        echo SB_Message::get_confirm_delete_text();
        ?>
">
                    <?php 
        if (0 == $count) {
            $count++;
            SB_Admin_Custom::set_current_rss_feed_item(array('name' => $name, 'count' => $count));
            sb_core_get_loop('loop-rss-feed');
            $real_count = $count;
            $order = $count;
            $next_id++;
        }
        if (0 < $count) {
            $new_count = 1;
            foreach ($list_feeds as $feed) {
                $feed_id = isset($feed['id']) ? $feed['id'] : 0;
                if ($feed_id >= $next_id) {
                    $next_id = $feed_id + 1;
                    SB_Admin_Custom::set_current_rss_feed_item(array('feed' => $feed, 'count' => $new_count, 'name' => $name));
                    sb_core_get_loop('loop-rss-feed');
                    $new_count++;
                }
            }
        }
        ?>
                </ul>
                <input type="hidden" name="<?php 
        echo $name;
        ?>
[order]" value="<?php 
        echo $order;
        ?>
" class="ui-item-order item-order" autocomplete="off">
                <input type="hidden" name="<?php 
        echo $name;
        ?>
[count]" value="<?php 
        echo $real_count;
        ?>
" class="ui-item-count item-count" autocomplete="off">
            </div>
            <button class="button add-item ui-add-item absolute" data-type="rss_feed" data-name="<?php 
        echo $name;
        ?>
" data-count="<?php 
        echo $count;
        ?>
" data-next-id="<?php 
        echo $next_id;
        ?>
"><?php 
        _e('Add new', 'sb-core');
        ?>
</button>
            <button class="button reset-item ui-reset-item absolute reset" data-type="rss_feed"><?php 
        _e('Reset', 'sb-core');
        ?>
 <img src="<?php 
        echo SB_CORE_URL;
        ?>
/images/ajax-loader.gif"></button>
        </div>
        <?php 
        self::the_description($description);
    }
function sb_paginate_border_radius_callback()
{
    $args = array('default' => __('Default', 'sb-paginate'), 'elipse' => __('Elipse', 'sb-paginate'), 'none' => __('None', 'sb-paginate'));
    $styles = apply_filters('sb_paginate_border_radius', $args);
    $name = 'sb_paginate_border_radius';
    $options = SB_Option::get();
    $value = isset($options['paginate']['border_radius']) ? $options['paginate']['border_radius'] : 'default';
    $description = __('You can make navigation buttons have border radius or not.', 'sb-paginate');
    ?>
    <label for="<?php 
    echo $name;
    ?>
"></label>
    <select id="<?php 
    echo $name;
    ?>
" name="<?php 
    echo esc_attr('sb_options[paginate][border_radius]');
    ?>
">
        <?php 
    foreach ($styles as $key => $title) {
        ?>
            <option value="<?php 
        echo $key;
        ?>
"<?php 
        selected($value, $key);
        ?>
><?php 
        echo $title;
        ?>
</option>
        <?php 
    }
    ?>
    </select>
    <p class="description"><?php 
    echo $description;
    ?>
</p>
<?php 
}