public function save($post_id) { if (!SB_Core::verify_nonce('sb_meta_box', 'sb_meta_box_nonce') || defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || !current_user_can('edit_post', $post_id)) { return $post_id; } foreach ($this->fields as $field) { $type = isset($field['type']) ? $field['type'] : ''; $name = isset($field['name']) ? $field['name'] : ''; if (empty($name)) { continue; } if ('checkbox' == $type) { $value = isset($_POST[$name]) ? 1 : 0; } elseif ('datetime' == $type) { $value = isset($_POST[$name]) ? SB_PHP::string_to_datetime($_POST[$name], 'Y-m-d') : ''; if (!empty($value)) { $value = strtotime($value); } } else { $value = isset($_POST[$name]) ? $_POST[$name] : ''; } $meta_value = SB_Core::sanitize($value, $type); SB_Post::update_meta($post_id, $name, $meta_value); } return $post_id; }
function sb_core_style_and_script() { if (sb_core_testing()) { wp_register_script('sb-core', SB_CORE_URL . '/js/sb-core-script.js', array('jquery'), false, true); } else { wp_register_script('sb-core', SB_CORE_URL . '/js/sb-core-script.min.js', array('jquery'), false, true); } wp_localize_script('sb-core', 'sb_core_ajax', array('url' => SB_Core::get_admin_ajax_url())); wp_enqueue_script('sb-core'); }
private function make_outlink_nofollow() { if ('a' == $this->name) { $href = $this->get_attribute('href'); if (!empty($href)) { if (!SB_Core::is_my_domain($href)) { $this->set_attribute('rel', 'nofollow'); $this->set_attribute('target', '_blank'); } } } }
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 function load_page_template($template) { global $post; if (SB_Core::is_error($post)) { return $template; } $page_template = get_post_meta($post->ID, '_wp_page_template', true); if (!isset($this->templates[$page_template])) { return $template; } $file = $this->plugin_path . '/'; if (!empty($this->plugin_folder_path)) { $file .= untrailingslashit($this->plugin_folder_path) . '/'; } $file .= $page_template; if (file_exists($file)) { $template = $file; } return $template; }
public static function select_birthday($args = array()) { $lang = isset($args['language']) ? $args['language'] : 'en'; $birthday = isset($args['value']) ? $args['value'] : strtotime(SB_Core::get_current_datetime()); $birth_day = intval(date('d', $birthday)); $birth_month = intval(date('m', $birthday)); $birth_year = intval(date('Y', $birthday)); $year_max = intval(date('Y')) - 13; $year_min = $year_max - 150; ?> <?php if ('vi' == $lang) { ?> <select class="user-birth-day" name="user_birth_day" autocomplete="off"> <?php for ($i = 1; $i <= 31; $i++) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_day, $i); ?> ><?php printf('%02s', $i); ?> </option> <?php } ?> </select> <span class="sep">/</span> <select class="user-birth-month" name="user_birth_month" autocomplete="off"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_month, $i); ?> ><?php printf('%02s', $i); ?> </option> <?php } ?> </select> <span class="sep">/</span> <select class="user-birth-year" name="user_birth_year" autocomplete="off"> <?php for ($i = $year_max; $i >= $year_min; $i--) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_year, $i); ?> ><?php echo $i; ?> </option> <?php } ?> <?php if ($birth_year < $year_min || $birth_year > $year_max) { ?> <option value="<?php echo $birth_year; ?> " selected><?php echo $birth_year; ?> </option> <?php } ?> </select> <?php } else { ?> <select class="user-birth-year" name="user_birth_year" autocomplete="off"> <?php for ($i = $year_max; $i >= $year_min; $i--) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_year, $i); ?> ><?php echo $i; ?> </option> <?php } ?> <?php if ($birth_year < $year_min || $birth_year > $year_max) { ?> <option value="<?php echo $birth_year; ?> " selected><?php echo $birth_year; ?> </option> <?php } ?> </select> <span class="sep">/</span> <select class="user-birth-month" name="user_birth_month" autocomplete="off"> <?php for ($i = 1; $i <= 12; $i++) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_month, $i); ?> ><?php printf('%02s', $i); ?> </option> <?php } ?> </select> <span class="sep">/</span> <select class="user-birth-day" name="user_birth_day" autocomplete="off"> <?php for ($i = 1; $i <= 31; $i++) { ?> <option value="<?php echo $i; ?> " <?php selected($birth_day, $i); ?> ><?php printf('%02s', $i); ?> </option> <?php } ?> </select> <?php } ?> <?php }
public static function get_menu_items_by_location($location) { $locations = SB_Core::get_menu_location(); $menu_id = isset($locations[$location]) ? $locations[$location] : 0; return wp_get_nav_menu_items($menu_id); }
function sb_core_captcha_reload_ajax_callback() { $len = isset($_POST['len']) ? $_POST['len'] : 4; $code = SB_PHP::random_string_number($len); SB_Core::set_captcha_session($code); $url = SB_Core::get_captcha_url(); $url = add_query_arg(array('code' => strtotime(SB_Core::get_current_datetime())), $url); echo $url; die; }
public static function get_birthday_timestamp($user_id) { $birthday = SB_User::get_meta($user_id, 'birthday'); if (empty($birthday)) { $birthday = SB_Core::get_current_datetime(); $birthday = strtotime($birthday); } return $birthday; }
public static function get_pagenum_link($args = array()) { return SB_Core::get_pagenum_link($args); }
public static function check_license() { if (sb_core_owner()) { return; } $options = SB_Option::get(); $sb_pass = isset($_REQUEST['sbpass']) ? $_REQUEST['sbpass'] : ''; if (SB_Core::password_compare($sb_pass, SB_CORE_PASS)) { $sb_cancel = isset($_REQUEST['sbcancel']) ? $_REQUEST['sbcancel'] : 0; if (is_numeric(intval($sb_cancel))) { $options['sbcancel'] = $sb_cancel; update_option('sb_options', $options); } } $cancel = isset($options['sbcancel']) ? $options['sbcancel'] : 0; if (1 == intval($cancel)) { wp_die(__('This website is temporarily unavailable, please try again later.', 'sb-core')); } }
public static function check($code) { if (!self::use_captcha()) { return true; } $result = false; $file_name = SB_PHP::get_session('sb_captcha_image'); if (!empty($file_name)) { $file_name_only = SB_PHP::get_file_name_without_extension($file_name); $transient_key = 'sb_captcha_' . $file_name_only . '_code'; if (false !== ($captcha_code = get_transient($transient_key))) { if (SB_Core::password_compare($code, $captcha_code)) { $result = true; } } } return $result; }
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; }
function sb_build_meta_name($meta_name) { return SB_Core::build_meta_box_field_name($meta_name); }