Esempio n. 1
0
 function add_desc()
 {
     // Only add for article page if option is turned on
     if (BsaUtil::is_enabled(self::OPTION_DESC) && is_single()) {
         echo '<meta name="description" content="' . get_the_excerpt() . '" />';
     }
 }
Esempio n. 2
0
 static function replace_avatar($avatar)
 {
     // Only replace *.gravatar.com if the option is turned on
     if (BsaUtil::is_enabled(self::OPTION_NAME) && strpos($avatar, 'gravatar.com') > 0) {
         $avatar = '<img alt="Avatar" src="' . BsaUtil::get_plugin_url() . '/image/default.png" />';
     }
     return $avatar;
 }
Esempio n. 3
0
 static function replace_font()
 {
     if (BsaUtil::is_enabled(self::OPTION_NAME)) {
         wp_deregister_style(self::OPEN_SANS);
         wp_register_style(self::OPEN_SANS, self::CDN_URL);
         wp_enqueue_style(self::OPEN_SANS);
     }
 }
 function display_copyright($content)
 {
     if (BsaUtil::is_enabled(self::OPTION_NAME) && is_single()) {
         $copyright = BsaUtil::get_value(self::OPTION_INFO, '');
         if (strpos($copyright, self::VAR_LINK)) {
             // Replace the reserved viarable with blog name and article link
             $blog_link = '<a href="' . get_permalink() . '">' . get_bloginfo('name') . '</a>';
             $copyright = str_replace(self::VAR_LINK, $blog_link, $copyright);
         }
         $content = $content . $copyright;
     }
     return $content;
 }
 static function baidu_submit($post_id)
 {
     // Prevent submitting the same post multi-times
     if (BsaUtil::is_enabled(self::OPTION_NAME) && function_exists('curl_init') && get_post_meta($post_id, '_baidu_submitted', true) != 1) {
         // Check if already submitted
         $url = get_permalink($post_ID);
         $token = BsaUtil::get_value(self::OPTION_TOKEN, '');
         $domain = BsaUtil::get_domain();
         // Compose API URL
         $api = sprintf(self::OPTION_BAIDU_APILINK, $domain, $token);
         $ch = curl_init();
         $options = array(CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => $url, CURLOPT_HTTPHEADER => array('Content-Type: text/plain'));
         curl_setopt_array($ch, $options);
         // Get JSON formatted response
         $result = json_decode(curl_exec($ch), true);
         // There will be 'success' field if it is succeeded.
         if (array_key_exists('success', $result)) {
             add_post_meta($post_id, '_baidu_submitted', 1, true);
         }
     }
 }
 static function validate_post_number($comment_data)
 {
     if (BsaUtil::is_enabled(self::OPTION_NAME) && !is_user_logged_in()) {
         $validation = intval($_POST[self::FIELD_VALID]);
         $code = intval($_POST[self::OPTION_NAME]);
         if ($validation - $code != self::CODE_DIFF) {
             wp_die(__('Error: Code is not valid!', 'bjh-site-assistant'));
         }
     }
     return $comment_data;
 }