public static function get_header($name = null) { $wp_query = self::$query; if (!CMA_Settings::getOption(CMA_Settings::OPTION_SEO_META_REWRITE_ENABLED)) { get_header($name); return; } ob_start(); get_header($name); $content = ob_get_clean(); if ($desc = static::getMetaDescription()) { $content = self::replaceHeadTag($content, '#(<meta name="description" content=")([^"]+)("[ /]*>)#i', '<meta name="description" content="' . esc_attr($desc) . '">', $desc, $append = true); } if ($keywords = CMA_Settings::getOption(CMA_Settings::OPTION_INDEX_META_KEYWORDS)) { $content = self::replaceHeadTag($content, '#(<meta name="keywords" content=")([^"]+)("[ /]*>)#i', '<meta name="keywords" content="' . esc_attr($keywords) . '">', $keywords, $append = true); } if (!$wp_query->is_single() and $title = CMA_Settings::getOption(CMA_Settings::OPTION_INDEX_META_TITLE)) { $content = self::replaceHeadTag($content, '#(<title>)([^<]+)(</title>)#i', '<title>' . esc_html($title) . '</title>', $title, $append = false); } // --------------------------------------------------------------------------------------------------- // Add canonical if ($wp_query->get('CMA-contributor-index')) { if ($user = get_user_by('slug', $wp_query->get('contributor'))) { $canonical = self::getContributorUrl($user); } } else { if ($wp_query->is_post_type_archive(CMA_Thread::POST_TYPE)) { $obj = $wp_query->get_queried_object(); if (isset($obj->term_id) and $category = CMA_Category::getInstance($obj->term_id)) { $canonical = $category->getPermalink(); } else { $canonical = CMA::permalink(); } } else { if ($wp_query->is_single() and $wp_query->get('post_type') == CMA_Thread::POST_TYPE) { // Canonical is added by WP } } } if (!empty($canonical)) { $content = self::replaceHeadTag($content, '#(<link rel=[\'"]?canonical[\'"]? href=[\'"])([^\'"]+)([\'"][ /]*>)#i', '<link rel="canonical" href="' . esc_attr($canonical) . '">', $canonical, $append = false); } echo $content; }
public static function processDelete() { if (isset($_GET['backlink'])) { $url = base64_decode($_GET['backlink']); } else { $url = null; } if (self::$query->post and !empty($_GET['nonce']) and wp_verify_nonce($_GET['nonce'], 'cma_thread_delete')) { if ($thread = CMA_Thread::getInstance(self::$query->post->ID)) { if (empty($url) and $category = $thread->getCategory()) { $url = $category->getPermalink(); } if ($thread->canDelete()) { $thread->delete(); self::addMessage(self::MESSAGE_SUCCESS, CMA::__('Thread has been deleted.')); } else { self::addMessage(self::MESSAGE_ERROR, CMA::__('You cannot delete this thread.')); } } else { self::addMessage(self::MESSAGE_ERROR, CMA::__('Thread not found.')); } } else { self::addMessage(self::MESSAGE_ERROR, CMA::__('Invalid request.')); } if (empty($url)) { $url = CMA::permalink(); } if (isset($_GET['widgetCacheId'])) { $url = add_query_arg('widgetCacheId', urlencode($_GET['widgetCacheId']), $url); } wp_redirect($url); exit; }