public static function set_timestamp($value = null)
 {
     if (!$value) {
         $value = $_SERVER['REQUEST_TIME'];
     }
     self::$timestamp = $value;
     theme_options::set_options(self::$iden, self::$timestamp);
 }
Example #2
0
 /**
  * backend js
  */
 public static function backend_enqueue_scripts()
 {
     if (!theme_options::is_options_page()) {
         return;
     }
     $js = ['frontend' => ['url' => theme_features::get_theme_js('backend-entry')]];
     foreach ($js as $k => $v) {
         wp_enqueue_script($k, $v['url'], isset($v['deps']) ? $v['deps'] : [], self::get_version($v), true);
     }
 }
Example #3
0
 public static function get_options($key = null)
 {
     static $caches = null;
     if ($caches === null) {
         $caches = theme_options::get_options(__CLASS__);
     }
     if ($key) {
         return isset($caches[$key]) ? $caches[$key] : false;
     }
     return $caches;
 }
 public static function get_options($key = null)
 {
     static $caches = [];
     if (!$caches) {
         $caches = (array) theme_options::get_options(__CLASS__);
     }
     if ($key) {
         return isset($caches[$key]) ? $caches[$key] : null;
     }
     return $caches;
 }
Example #5
0
 public static function get_options($key = null)
 {
     static $caches = null;
     if ($caches === null) {
         $caches = (array) theme_options::get_options(self::get_iden());
     }
     if ($key) {
         return isset($caches[$key]) ? $caches[$key] : false;
     }
     return $caches;
 }
 public static function get_options($key = null)
 {
     static $cache = null;
     if ($cache === null) {
         $cache = theme_options::get_options(self::$iden);
     }
     if ($key) {
         return isset($cache[$key]) ? $cache[$key] : false;
     } else {
         return $cache;
     }
 }
Example #7
0
 public static function get_options($key = null)
 {
     static $caches = [];
     if (!isset($caches[self::$iden])) {
         $caches[self::$iden] = theme_options::get_options(self::$iden);
     }
     if ($key) {
         return isset($caches[self::$iden][$key]) ? $caches[self::$iden][$key] : null;
     } else {
         return $caches[self::$iden];
     }
 }
 public static function get_options($key = null)
 {
     static $cache = null;
     if ($cache === null) {
         $cache = array_filter((array) theme_options::get_options(__CLASS__));
     }
     if ($key) {
         if (isset($cache[$key])) {
             return $cache[$key];
         }
         return isset(self::options_default()[__CLASS__][$key]) ? self::options_default()[__CLASS__][$key] : false;
     }
     return $cache ? $cache : self::options_default()[__CLASS__];
 }
Example #9
0
 public static function get_options($key = null)
 {
     static $caches = null;
     if ($caches === null) {
         $caches = (array) theme_options::get_options(__CLASS__);
     }
     if ($key) {
         if (isset($caches[$key])) {
             return $caches[$key];
         } else {
             $caches[$key] = isset(self::options_default()[__CLASS__][$key]) ? self::options_default()[__CLASS__][$key] : false;
             return $caches[$key];
         }
     }
     return $caches;
 }
Example #10
0
 public static function process_backend()
 {
     theme_features::check_referer();
     theme_features::check_nonce();
     if (!theme_cache::current_user_can('manage_options')) {
         return false;
     }
     $type = isset($_GET['type']) && is_string($_GET['type']) ? $_GET['type'] : false;
     switch ($type) {
         case 'recalculate':
             global $post;
             $query = new WP_Query(['nopaging' => true, 'meta_key' => self::$post_meta_key['count_points']]);
             if ($query->have_posts()) {
                 foreach ($query->posts as $post) {
                     setup_postdata($post);
                     /** get points from db */
                     $old_points = get_post_meta($post->ID, self::$post_meta_key['count_points'], true);
                     $new_points = self::get_post_points_count_from_users($post->ID);
                     /**
                      * skip if equal
                      */
                     if ($old_points == $new_points) {
                         continue;
                     }
                     /**
                      * update new points
                      */
                     update_post_meta($post->ID, self::$post_meta_key['count_points'], $new_points);
                 }
             }
             header('location: ' . theme_options::get_url() . '&' . __CLASS__);
             die;
             break;
         default:
             die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_type', 'msg' => ___('Sorry, type param is invaild.')]));
     }
 }
Example #11
0
 public static function save_post($post_id)
 {
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return false;
     }
     if (!isset($_POST[__CLASS__ . '-nonce']) || !wp_verify_nonce($_POST[__CLASS__ . '-nonce'], __CLASS__)) {
         return false;
     }
     $opt = self::get_options();
     if (!isset($opt['ids'])) {
         $opt['ids'] = [];
     }
     /**
      * set to recomm
      */
     if (isset($_POST[__CLASS__])) {
         if (!in_array($post_id, $opt['ids'])) {
             $opt['ids'][] = $post_id;
             arsort($opt['ids']);
             $opt['ids'] = array_slice($opt['ids'], 0, 50);
             theme_options::set_options(__CLASS__, $opt);
             self::clear_cache();
         }
     } else {
         $key = array_search($post_id, $opt['ids']);
         if ($key !== false) {
             unset($opt['ids'][$key]);
             $opt['ids'] = array_slice($opt['ids'], 0, 50);
             theme_options::set_options(__CLASS__, $opt);
             self::clear_cache();
         }
     }
 }
Example #12
0
 public static function process()
 {
     theme_features::check_referer();
     $type = isset($_REQUEST['type']) && is_string($_REQUEST['type']) ? $_REQUEST['type'] : false;
     $current_user_id = theme_cache::get_current_user_id();
     switch ($type) {
         /**
          * backend create db table
          */
         case 'create-db':
             if (!theme_cache::current_user_can('manage_options')) {
                 die(___('Sorry, your permission is not enough to create database table.'));
             }
             //die(theme_features::json_format([
             //	'status' => 'error',
             //	'code' => 'invaild_permission',
             //	'msg' => ___('Sorry, your permission is not enough to create database table.'),
             //]));
             if (self::has_table()) {
                 die(___('Sorry, the database table already exists.'));
             }
             //die(theme_features::json_format([
             //	'status' => 'error',
             //	'code' => 'exists_table',
             //	'msg' => ___('Sorry, the database table already exists.'),
             //]));
             self::create_db_table();
             theme_options::set_options(__CLASS__, ['db-version' => self::$db_version]);
             header('location: ' . theme_options::get_url() . '&' . __CLASS__);
             die;
             //die(theme_features::json_format([
             //	'status' => 'success',
             //	'msg' => ___('Database table has been created.'),
             //]));
             /**
              * get-userdata
              */
         //die(theme_features::json_format([
         //	'status' => 'success',
         //	'msg' => ___('Database table has been created.'),
         //]));
         /**
          * get-userdata
          */
         case 'get-userdata':
             /** nonce */
             theme_features::check_nonce();
             /**
              * uid
              */
             $uid = isset($_REQUEST['uid']) && is_numeric($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
             /**
              * get userdata
              */
             $user = self::check_uid($uid);
             /** add user to lists */
             self::add_list($current_user_id, $user->ID);
             die(theme_features::json_format(['status' => 'success', 'name' => esc_html($user->display_name), 'avatar' => get_avatar_url($user->ID), 'msg' => ___('User data loaded, you can send P.M. now.'), 'url' => theme_cache::get_author_posts_url($user->ID)]));
             /**
              * remove user lists
              */
         /**
          * remove user lists
          */
         case 'remove-dialog':
             $receiver_uid = isset($_REQUEST['uid']) && is_numeric($_REQUEST['uid']) ? (int) $_REQUEST['uid'] : false;
             $receiver = self::check_uid($receiver_uid);
             $status = self::remove_list($current_user_id, $receiver->ID);
             if ($status) {
                 die(theme_features::json_format(['status' => 'success', 'code' => 'removed']));
             }
             die(theme_features::json_format(['status' => 'error', 'code' => 'remove_fail']));
             /**
              * send
              */
         /**
          * send
          */
         case 'send':
             /** nonce */
             theme_features::check_nonce();
             $receiver_uid = isset($_REQUEST['uid']) && is_numeric($_REQUEST['uid']) ? $_REQUEST['uid'] : false;
             $receiver = self::check_uid($receiver_uid);
             /** check content */
             $content = isset($_REQUEST['content']) && is_string($_REQUEST['content']) ? trim($_REQUEST['content']) : false;
             if ($content != '') {
                 $content = fliter_script(strip_tags($content, '<a><b><strong><em><i><del>'));
             }
             if (trim($content) == '') {
                 die(theme_features::json_format(['status' => 'error', 'code' => 'empty_content', 'msg' => ___('Sorry, message content is null, please try again.')]));
             }
             /** pass */
             $pm_id = self::insert_pm(['pm_author' => $current_user_id, 'pm_receiver' => $receiver->ID, 'pm_content' => $content]);
             if (!$pm_id) {
                 die(theme_features::json_format(['status' => 'error', 'code' => 'can_not_create_pm', 'msg' => ___('Sorry, system can not create the private message, please try again later.')]));
             }
             /** get pm */
             $pm = self::get_pm($pm_id);
             /** add list for author */
             self::add_list($current_user_id, $pm->pm_receiver);
             /** add list for receiver */
             self::add_list($pm->pm_receiver, $current_user_id);
             die(theme_features::json_format(['status' => 'success', 'pm' => ['pm_receiver' => self::get_niceid($pm->pm_receiver), 'pm_author' => self::get_niceid($pm->pm_author), 'pm_date' => current_time('Y/m/d H:i:s'), 'pm_content' => $pm->pm_content, 'url' => theme_cache::get_author_posts_url($pm->pm_receiver)], 'msg' => ___('Message sent.')]));
             /**
              * latest pm id
              */
         /**
          * latest pm id
          */
         case 'comet':
             /** nonce */
             theme_features::check_nonce();
             $receiver_id = $current_user_id;
             $client_timestamp = isset($_REQUEST['timestamp']) && is_numeric($_REQUEST['timestamp']) ? $_REQUEST['timestamp'] : false;
             /** if not client timestamp, return error */
             if (!$client_timestamp) {
                 die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_timestamp', 'msg' => ___('Sorry, your session is timeout, please refresh page.')]));
             }
             /** set timeout */
             set_time_limit(60);
             /** check new pm for receiver */
             for ($i = 0; $i < self::$comet_timeout; ++$i) {
                 /** have new pm */
                 $timestamp = self::get_timestamp($receiver_id);
                 if ($timestamp <= $client_timestamp) {
                     sleep(1);
                     continue;
                 }
                 /** have new pm, output latest pm */
                 $latest_pm = self::get_pm(self::get_latest_pm_id($receiver_id));
                 /** clear unreads for me */
                 self::clear_unreads($current_user_id);
                 die(theme_features::json_format(['status' => 'success', 'pm' => ['pm_receiver' => self::get_niceid($latest_pm->pm_receiver), 'pm_author' => self::get_niceid($latest_pm->pm_author), 'pm_author_name' => theme_cache::get_the_author_meta('display_name', $latest_pm->pm_author), 'pm_author_avatar' => get_avatar_url($latest_pm->pm_author), 'pm_date' => current_time('Y/m/d H:i:s'), 'pm_content' => $latest_pm->pm_content, 'url' => theme_cache::get_author_posts_url($pm->pm_author)], 'timestamp' => $timestamp]));
             }
             /** timeout msg */
             die(theme_features::json_format(['status' => 'error', 'code' => 'timeout', 'msg' => ___('Timeout')]));
         default:
             die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_type', 'msg' => ___('Sorry, type param is invaild.')]));
     }
 }
    /**
     * Display page list on select tag
     *
     * @param string $group_id
     * @param string $page_slug
     * @return
     * @version 1.1.1
     */
    public static function page_option_list($group_id, $page_slug)
    {
        static $caches = [];
        $cache_id = md5(json_encode(func_get_args()));
        if (isset($caches[$cache_id])) {
            echo $caches[$cache_id];
            return;
        }
        $opt = theme_options::get_options($group_id);
        $page_id = isset($opt[$page_slug]) ? (int) $opt[$page_slug] : null;
        ob_start();
        ?>
		<select name="<?php 
        echo $group_id, '[', $page_slug, ']';
        ?>
" id="<?php 
        echo $group_id, '-', $page_slug;
        ?>
">
			<option value="0"><?php 
        echo esc_attr(___('Select page'));
        ?>
</option>
			<?php 
        foreach (get_pages() as $page) {
            if ($page_id == $page->ID) {
                $selected = ' selected ';
            } else {
                $selected = null;
            }
            ?>
				<option value="<?php 
            echo esc_attr($page->ID);
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo esc_attr($page->post_title);
            ?>
</option>
				<?php 
        }
        ?>
		</select>
		<?php 
        $caches[$cache_id] = ob_get_contents();
        ob_end_clean();
        echo $caches[$cache_id];
    }
Example #14
0
    /**
     * Display page list on select tag
     *
     * @param string $group_id
     * @param string $page_slug
     * @return
     * @version 1.2.0
     */
    public static function page_option_list($group_id, $iden)
    {
        static $pages = null;
        if ($pages === null) {
            $pages = get_pages();
        }
        $opt = theme_options::get_options($group_id);
        $page_id = isset($opt[$iden]) ? (int) $opt[$iden] : null;
        ob_start();
        ?>
		<select name="<?php 
        echo $group_id;
        ?>
[<?php 
        echo $iden;
        ?>
]" id="<?php 
        echo $group_id;
        ?>
-<?php 
        echo $iden;
        ?>
">
			<option value="-1"><?php 
        echo ___('Select page');
        ?>
</option>
			<?php 
        foreach ($pages as $page) {
            if ($page_id == $page->ID) {
                $selected = ' selected ';
            } else {
                $selected = null;
            }
            ?>
				<option value="<?php 
            echo $page->ID;
            ?>
" <?php 
            echo $selected;
            ?>
><?php 
            echo theme_cache::get_the_title($page->ID);
            ?>
</option>
				<?php 
        }
        ?>
		</select>
		<?php 
    }
 /**
  * process
  */
 public static function process()
 {
     if (!theme_cache::current_user_can('manage_options')) {
         return false;
     }
     @ini_set('max_input_nesting_level', '10000');
     @ini_set('max_execution_time', 0);
     remove_dir(theme_features::get_stylesheet_directory() . theme_features::$basedir_js_min);
     theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_js_src);
     remove_dir(theme_features::get_stylesheet_directory() . theme_features::$basedir_css_min);
     theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_css_src);
     theme_features::minify_force(theme_features::get_stylesheet_directory() . theme_features::$basedir_addons);
     theme_file_timestamp::set_timestamp();
     wp_redirect(add_query_arg(__CLASS__, 1, theme_options::get_url()));
     die;
 }
 public static function get_posts($args = null)
 {
     global $post;
     $current_post = $post;
     $options = theme_options::get_options();
     $defaults = array('posts_per_page' => isset($options['related_post_num']) ? (int) $options['related_post_num'] : 6);
     $r = array_merge($defaults, $args);
     extract($r);
     /**
      * get the cache
      */
     $posts = (array) wp_cache_get($current_post->ID, 'theme_related_post');
     if (!is_null_array($posts)) {
         return $posts;
     }
     $tags = wp_get_post_tags($current_post->ID);
     $tags_len = count($tags);
     $surprise_num = $posts_per_page;
     $found_posts = 0;
     /* 存在tags */
     if ($tags_len) {
         for ($i = 0; $i < $tags_len; $i++) {
             $tags_array[] = $tags[$i]->term_id;
         }
         $query_args = array('tag__in' => $tags_array, 'post__not_in' => array($current_post->ID), 'posts_per_page' => $surprise_num);
         $query = new WP_Query($query_args);
         if ($query->have_posts()) {
             foreach ($query->posts as $post) {
                 $posts[] = $post;
             }
         }
         $found_posts = $query->found_posts;
         /* 发现到的文章数量 */
     }
     $surprise_num = $surprise_num - $found_posts;
     /* 计算剩余文章数量 */
     /* 当剩余文章大于0时候,调用分类目录中的文章来补充 */
     if ($surprise_num > 0) {
         $args = array('category__in' => array(theme_features::get_current_cat_id()), 'post__not_in' => array($current_post->ID), 'posts_per_page' => $surprise_num);
         $query = new WP_Query($args);
         if ($query->have_posts()) {
             foreach ($query->posts as $post) {
                 $posts[] = $post;
             }
         }
         $found_posts = $query->found_posts;
         /* 发现到的文章数量 */
         $surprise_num = $surprise_num - $found_posts;
         /* 计算剩余文章数量 */
     }
     $posts = array_filter($posts);
     wp_cache_set($current_post->ID, $posts, 'theme_related_post');
     //wp_reset_query();
     wp_reset_postdata();
     return $posts;
 }
Example #17
0
 /**
  * Process
  * 
  * 
  * @return 
  * @version 1.0.0
  * 
  */
 public static function process()
 {
     theme_features::check_referer();
     if (!theme_cache::current_user_can('manage_options')) {
         die;
     }
     $output = [];
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
     switch ($type) {
         case 'import':
             $file = isset($_FILES['file']) ? $_FILES['file'] : false;
             if (!$file || $file['error'] != 0) {
                 die(theme_features::json_format(['status' => 'error', 'msg' => ___('Invalid file.')]));
             }
             $contents = json_decode(base64_decode(file_get_contents($file['tmp_name'])), true);
             if (is_array($contents) && !empty($contents)) {
                 set_theme_mod('theme_options', $contents);
                 die(theme_features::json_format(['status' => 'success', 'msg' => ___('Settings has been restored, refreshing page, please wait...')]));
                 /**
                  * invalid contents
                  */
             } else {
                 die(theme_features::json_format(['status' => 'error', 'msg' => ___('Invalid file content.')]));
             }
             break;
             /**
              * export
              */
         /**
          * export
          */
         case 'export':
             $contents = base64_encode(json_encode(theme_options::get_options()));
             /**
              * write content to a tmp file
              */
             $tmp = tmpfile();
             $filepath = stream_get_meta_data($tmp)['uri'];
             file_put_contents($filepath, $contents);
             /**
              * output file download
              */
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Expires: 0');
             header('Cache-Control: must-revalidate');
             header('Pragma: public');
             header('Content-Length: ' . filesize($filepath));
             $download_fn = ___('Backup');
             $download_fn .= '-' . theme_cache::get_bloginfo('name');
             $download_fn .= '-' . theme_functions::$iden;
             $download_fn .= '-' . date('Ymd-His') . '.bk';
             header('Content-Disposition: attachment; filename=" ' . $download_fn . '"');
             readfile($filepath);
             die;
     }
     die(theme_features::json_format($output));
 }
 /**
  * delete_options
  *
  * @param string
  * @return 
  * @version 1.0.2
  */
 public static function delete_options($key)
 {
     self::$opts = self::get_options();
     if (!isset(self::$opts[$key])) {
         return false;
     }
     unset(self::$opts[$key]);
     set_theme_mod(__CLASS__, self::$opts);
     return self::$opts;
 }
Example #19
0
    public static function admin()
    {
        $options = theme_options::get_options();
        $theme_data = wp_get_theme();
        $theme_meta_origin = theme_functions::theme_meta_translate();
        $is_oem = isset($theme_meta_origin['oem']) ? true : false;
        $theme_meta = isset($theme_meta_origin['oem']) ? $theme_meta_origin['oem'] : $theme_meta_origin;
        ?>
<fieldset>
	<legend><?php 
        echo ___('Theme Information');
        ?>
</legend>
	<table class="form-table">
		<tbody>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme name');
        ?>
</th>
				<td><?php 
        echo $theme_meta['name'];
        ?>
</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme version');
        ?>
</th>
				<td><?php 
        echo $theme_data->display('Version');
        ?>
</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme edition');
        ?>
</th>
				<td><?php 
        echo $theme_meta_origin['edition'];
        ?>
</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme description');
        ?>
</th>
				<td><p><?php 
        echo $theme_meta['des'];
        ?>
</p></td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme URI');
        ?>
</th>
				<td><a href="<?php 
        echo esc_url($theme_meta['theme_url']);
        ?>
" target="_blank"><?php 
        echo esc_url($theme_meta['theme_url']);
        ?>
</a></td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Theme author');
        ?>
</th>
				<td><?php 
        echo $theme_meta['author'];
        ?>
</td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Author site');
        ?>
</th>
				<td><a href="<?php 
        echo esc_url($theme_meta['author_url']);
        ?>
" target="_blank"><?php 
        echo esc_url($theme_meta['author_url']);
        ?>
</a></td>
			</tr>
			<tr>
				<th scope="row"><?php 
        echo ___('Feedback and technical support');
        ?>
</th>
				<td>
				
					<?php 
        if (isset($theme_meta['email'])) {
            ?>
						<p><?php 
            echo ___('E-Mail');
            ?>
 <a href="mailto:<?php 
            echo $theme_meta['email'];
            ?>
"><?php 
            echo $theme_meta['email'];
            ?>
</a></p>
					<?php 
        }
        ?>
					
					<?php 
        if (isset($theme_meta['qq'])) {
            ?>
						<p><?php 
            echo ___('QQ');
            ?>
							<?php 
            if (isset($theme_meta['qq']['link'])) {
                ?>
								<a target="_blank" href="<?php 
                echo esc_url($theme_meta['qq']['link']);
                ?>
"><?php 
                echo $theme_meta['qq']['number'];
                ?>
</a>
							<?php 
            } else {
                ?>
								<?php 
                echo $theme_meta['qq']['number'];
                ?>
							<?php 
            }
            ?>
						</p>
					<?php 
        }
        ?>
					
					<?php 
        if (isset($theme_meta['qq_group'])) {
            ?>
						<p><?php 
            echo ___('QQ group');
            ?>
							<?php 
            if (isset($theme_meta['qq_group']['link'])) {
                ?>
								<a target="_blank" href="<?php 
                echo esc_url($theme_meta['qq_group']['link']);
                ?>
"><?php 
                echo $theme_meta['qq_group']['number'];
                ?>
</a>
							<?php 
            } else {
                ?>
								<?php 
                echo $theme_meta['qq_group']['number'];
                ?>
							<?php 
            }
            ?>
						</p>
					<?php 
        }
        ?>
				</td>
			</tr>
			<?php 
        if (!$is_oem) {
            ?>
				<tr>
					<th scope="row"><?php 
            echo ___('Donate');
            ?>
</th>
					<td>
						<p>
							<a id="paypal_donate" href="javascript:;" title="<?php 
            echo ___('Donation by Paypal');
            ?>
">
								<img src="http://ww2.sinaimg.cn/large/686ee05djw1ella1kv74cj202o011wea.jpg" alt="<?php 
            echo ___('Donation by Paypal');
            ?>
" width="96" height="37"/>
							</a>
							<a id="alipay_donate" target="_blank" href="http://ww3.sinaimg.cn/large/686ee05djw1eihtkzlg6mj216y16ydll.jpg" title="<?php 
            echo ___('Donation by Alipay');
            ?>
">
								<img width="96" height="37" src="http://ww1.sinaimg.cn/large/686ee05djw1ellabpq9euj202o011dfm.jpg" alt="<?php 
            echo ___('Donation by Alipay');
            ?>
"/>
							</a>
						</p>
					</td>
				</tr>
			<?php 
        } else {
            ?>
			<tr>
				<th scope="row"><?php 
            echo ___('Theme core');
            ?>
</th>
				<td><a href="<?php 
            echo esc_url($theme_meta['core']['url']);
            ?>
" target="_blank"><?php 
            echo $theme_meta['core']['name'];
            ?>
</a></td>
			</tr>
			<?php 
        }
        ?>


		</tbody>
	</table>
</fieldset>
	<?php 
    }
Example #20
0
 /**
  * action_add_history_core_transition_post_status_post_publish
  *
  * @param int Post id
  * @param object Post
  * @version 1.0.1
  */
 public static function action_add_history_core_post_publish($post_id, $post)
 {
     /** if published, do not add point and history */
     if (class_exists('theme_custom_contribution') && theme_custom_contribution::is_once_published($edit_post_id)) {
         return false;
     }
     $meta = array('type' => 'post-publish', 'post-id' => $post_id, 'timestamp' => current_time('timestamp'));
     /**
      * add to history
      */
     self::add_history($post->post_author, $meta);
     /**
      * update point
      */
     /**
      * if is not post type, return false
      */
     if ($post->post_type !== 'post') {
         return false;
     }
     $old_point = self::get_point($post->post_author);
     update_user_meta($post->post_author, self::$user_meta_key['point'], $old_point + (int) theme_options::get_options(__CLASS__)['points']['post-publish']);
 }
Example #21
0
 public static function get_options($key = null)
 {
     static $caches = [];
     if (!isset($caches)) {
         $caches = theme_options::get_options(__CLASS__);
     }
     if ($key) {
         if (isset($caches[$key]) && !empty($caches[$key])) {
             return $caches[$key];
         } else {
             return self::options_default()[__CLASS__][$key];
         }
     }
     return $caches;
 }
    public static function display_backend_options_list()
    {
        ?>
		<fieldset>
			<legend><?php 
        echo ___('Theme options debug');
        ?>
</legend>
			<textarea class="code widefat" cols="50" rows="50" readonly ><?php 
        esc_textarea(print_r(theme_options::get_options()));
        ?>
</textarea>
		</fieldset>
		<?php 
    }