/**
  * Bulk category actions.
  *
  * @access public
  * @since 0.7.7
  * @uses current_user_can()
  * @uses check_admin_referer()
  * @uses wp_redirect()
  * @uses get_admin_url()
  * @uses get_current_blog_id()
  * @return void
  */
 public static function categoryManagement()
 {
     // Grab an instance of the Connections object.
     $instance = Connections_Directory();
     $action = '';
     if (isset($_REQUEST['action']) && '-1' !== $_REQUEST['action']) {
         $action = $_REQUEST['action'];
     } elseif (isset($_REQUEST['action2']) && '-1' !== $_REQUEST['action2']) {
         $action = $_REQUEST['action2'];
     }
     /*
      * Check whether user can edit Settings
      */
     if (current_user_can('connections_edit_categories')) {
         switch ($action) {
             case 'delete':
                 check_admin_referer('bulk-terms');
                 foreach ((array) $_POST['category'] as $id) {
                     $result = $instance->retrieve->category(absint($id));
                     $category = new cnCategory($result);
                     $category->delete();
                 }
                 break;
         }
         $url = get_admin_url(get_current_blog_id(), 'admin.php?page=connections_categories');
         if (isset($_REQUEST['paged']) && !empty($_REQUEST['paged'])) {
             $page = absint($_REQUEST['paged']);
             $url = add_query_arg(array('paged' => $page), $url);
         }
         wp_redirect($url);
         exit;
     } else {
         cnMessage::set('error', 'capability_categories');
     }
 }
 /**
  * Render the category breadcrumb.
  *
  * @access public
  * @since  8.5.18
  * @static
  *
  * @param array  $atts      The attributes array. {
  *
  *     @type bool   $link       Whether to format as link or as a string.
  *                              Default: FALSE
  *     @type string $separator  How to separate categories.
  *                              Default: '/'
  *     @type bool   $force_home Default: FALSE
  *     @type int    $home_id    Default: The page set as the directory home page.
  *     @type bool   $return     Whether or not to return or echo the pagination control. Set to TRUE to return instead of echo.
  *                              Default: FALSE
  * }
  *
  * @return string A list of category parents on success.
  */
 public static function categoryBreadcrumb($atts)
 {
     $defaults = array('link' => FALSE, 'separator' => '/', 'force_home' => FALSE, 'home_id' => cnSettingsAPI::get('connections', 'connections_home_page', 'page_id'), 'return' => FALSE);
     $atts = cnSanitize::args($atts, $defaults);
     $html = '';
     if ($current = cnCategory::getCurrent()) {
         $home = cnURL::permalink(array('type' => 'home', 'title' => esc_html__('Home', 'connections'), 'text' => esc_html__('Home', 'connections'), 'force_home' => $atts['force_home'], 'home_id' => $atts['home_id'], 'return' => TRUE));
         $breadcrumb = cnTemplatePart::getCategoryParents($current->parent, array('link' => $atts['link'], 'separator' => $atts['separator'], 'force_home' => $atts['force_home'], 'home_id' => $atts['home_id']));
         if (is_wp_error($breadcrumb)) {
             $breadcrumb = '';
         }
         //$currentLink = '<a href="' . esc_url( cnTerm::permalink( $current, 'category', $atts ) ) . '">' . $current->name . '</a>';
         $html = $home . $atts['separator'] . $breadcrumb . esc_html($current->name);
         $html = '<div class="cn-category-breadcrumb">' . $html . '</div>';
     }
     return self::echoOrReturn($atts['return'], $html);
 }
 /**
  * Add the the current Connections category description or entry bio excerpt as the page meta description.
  *
  * @access private
  * @since  0.7.8
  * @static
  *
  * @uses   cnQuery::getVar()
  * @uses   esc_attr()
  * @uses   strip_shortcodes()
  */
 public static function metaDesc()
 {
     // Whether or not to filter the page title with the current directory location.
     if (!cnSettingsAPI::get('connections', 'seo_meta', 'page_desc')) {
         return;
     }
     $description = '';
     if (cnQuery::getVar('cn-cat-slug')) {
         // If the category slug is a descendant, use the last slug from the URL for the query.
         $categorySlug = explode('/', cnQuery::getVar('cn-cat-slug'));
         if (isset($categorySlug[count($categorySlug) - 1])) {
             $categorySlug = $categorySlug[count($categorySlug) - 1];
         }
         $term = cnTerm::getBy('slug', $categorySlug, 'category');
         $category = new cnCategory($term);
         $description = $category->getExcerpt(array('length' => 160));
     }
     if (cnQuery::getVar('cn-cat')) {
         if (is_array(cnQuery::getVar('cn-cat'))) {
             return;
         }
         $categoryID = cnQuery::getVar('cn-cat');
         $term = cnTerm::getBy('id', $categoryID, 'category');
         $category = new cnCategory($term);
         $description = $category->getExcerpt(array('length' => 160));
     }
     if (cnQuery::getVar('cn-entry-slug')) {
         // Grab an instance of the Connections object.
         $instance = Connections_Directory();
         $result = $instance->retrieve->entries(array('slug' => urldecode(cnQuery::getVar('cn-entry-slug'))));
         // Make sure an entry is returned and then echo the meta desc.
         if (!empty($result)) {
             $entry = new cnEntry($result[0]);
             $description = $entry->getExcerpt(array('length' => 160));
         }
     }
     if (0 == strlen($description)) {
         return;
     }
     echo '<meta name="description" content="' . esc_attr(trim(strip_shortcodes(strip_tags(stripslashes($description))))) . '"/>' . "\n";
 }
Example #4
0
 public function showForm($data = NULL)
 {
     global $connections;
     $form = new cnFormObjects();
     $category = new cnCategory($data);
     $parent = new cnCategory($connections->retrieve->category($category->getParent()));
     $level = NULL;
     $out = '<div class="form-field form-required connectionsform">';
     $out .= '<label for="cat_name">Category Name</label>';
     $out .= '<input type="text" aria-required="true" size="40" value="' . $category->getName() . '" id="category_name" name="category_name"/>';
     $out .= '<input type="hidden" value="' . $category->getID() . '" id="category_id" name="category_id"/>';
     $out .= '</div>';
     $out .= '<div class="form-field connectionsform">';
     $out .= '<label for="category_nicename">Category Slug</label>';
     $out .= '<input type="text" size="40" value="' . $category->getSlug() . '" id="category_slug" name="category_slug"/>';
     $out .= '</div>';
     $out .= '<div class="form-field connectionsform">';
     $out .= '<label for="category_parent">Category Parent</label>';
     $out .= '<select class="postform" id="category_parent" name="category_parent">';
     $out .= '<option value="0">None</option>';
     $out .= $this->buildCategoryRow('option', $connections->retrieve->categories(), $level, $parent->getID());
     $out .= '</select>';
     $out .= '</div>';
     $out .= '<div class="form-field connectionsform">';
     $out .= '<label for="category_description">Description</label>';
     $out .= '<textarea cols="40" rows="5" id="category_description" name="category_description">' . $category->getDescription() . '</textarea>';
     $out .= '</div>';
     echo $out;
 }
Example #5
0
function connectionsShowCategoriesPage()
{
    /*
     * Check whether user can edit categories.
     */
    if (!current_user_can('connections_edit_categories')) {
        wp_die('<p id="error-page" style="-moz-background-clip:border;
				-moz-border-radius:11px;
				background:#FFFFFF none repeat scroll 0 0;
				border:1px solid #DFDFDF;
				color:#333333;
				display:block;
				font-size:12px;
				line-height:18px;
				margin:25px auto 20px;
				padding:1em 2em;
				text-align:center;
				width:700px">' . __('You do not have sufficient permissions to access this page.', 'connections') . '</p>');
    } else {
        // Grab an instance of the Connections object.
        $instance = Connections_Directory();
        $form = new cnFormObjects();
        $taxonomy = 'category';
        $action = '';
        if (isset($_GET['cn-action'])) {
            $action = $_GET['cn-action'];
        }
        if ($action === 'edit_category') {
            $id = absint($_GET['id']);
            check_admin_referer('category_edit_' . $id);
            $term = $instance->retrieve->category($id);
            $category = new cnCategory($term);
            /**
             * Fires before the Edit Term form for all taxonomies.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to
             * the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param object $tag      Current taxonomy term object.
             * @param string $taxonomy Current $taxonomy slug.
             */
            do_action("cn_{$taxonomy}_pre_edit_form", $term, $taxonomy);
            ?>

			<div class="wrap">
				<div class="form-wrap" style="width:600px; margin: 0 auto;">
					<h2><a name="new"></a><?php 
            _e('Edit Category', 'connections');
            ?>
</h2>

					<?php 
            $attr = array('action' => '', 'method' => 'post', 'id' => 'addcat', 'name' => 'updatecategory');
            $form->open($attr);
            $form->tokenField('update_category');
            /**
             * Fires inside the Edit Term form tag.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to
             * the taxonomy slug.
             *
             * @since 3.7.0
             */
            do_action("cn_{$taxonomy}_term_edit_form_tag");
            ?>

					<div class="form-field form-required term-name-wrap">
						<label for="category_name"><?php 
            _e('Name', 'connections');
            ?>
</label>
						<input type="text" aria-required="true" size="40" value="<?php 
            echo esc_attr($category->getName());
            ?>
" id="category_name" name="category_name"/>
						<input type="hidden" value="<?php 
            echo esc_attr($category->getID());
            ?>
" id="category_id" name="category_id"/>

						<p><?php 
            _e('The name is how it appears on your site.', 'connections');
            ?>
</p>
					</div>

					<div class="form-field term-slug-wrap">
						<label for="category_slug"><?php 
            _e('Slug', 'connections');
            ?>
 </label>
						<input type="text" size="40" value="<?php 
            echo esc_attr($category->getSlug());
            ?>
" id="category_slug" name="category_slug"/>

						<p><?php 
            _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'connections');
            ?>
</p>
					</div>

					<div class="form-field term-parent-wrap">
						<label for="category_parent"><?php 
            _e('Parent', 'connections');
            ?>
</label>

						<?php 
            cnTemplatePart::walker('term-select', array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'name' => 'category_parent', 'orderby' => 'name', 'taxonomy' => 'category', 'selected' => $category->getParent(), 'exclude_tree' => $category->getID(), 'hierarchical' => TRUE, 'show_option_none' => __('None', 'connections')));
            ?>
						<p><?php 
            _e('Categories can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.', 'connections');
            ?>
</p>
					</div>


					<div class="form-field term-description-wrap">
						<?php 
            ob_start();
            /*
             * Now we're going to have to keep track of which TinyMCE plugins
             * WP core supports based on version, sigh.
             */
            if (version_compare($GLOBALS['wp_version'], '3.8.999', '<')) {
                $tinymcePlugins = array('inlinepopups', 'tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs');
            } else {
                $tinymcePlugins = array('tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs');
            }
            wp_editor(wp_kses_post($category->getDescription()), 'category_description', array('media_buttons' => FALSE, 'tinymce' => array('editor_selector' => 'tinymce', 'toolbar1' => 'bold, italic, underline, |, bullist, numlist, |, justifyleft, justifycenter, justifyright, alignleft, aligncenter, alignright, |, link, unlink, |, pastetext, pasteword, removeformat, |, undo, redo', 'toolbar2' => '', 'inline_styles' => TRUE, 'relative_urls' => FALSE, 'remove_linebreaks' => FALSE, 'plugins' => implode(',', $tinymcePlugins))));
            echo ob_get_clean();
            ?>
					</div>

					<?php 
            /**
             * Fires after the Edit Term form fields are displayed.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to
             * the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param object $tag      Current taxonomy term object.
             * @param string $taxonomy Current taxonomy slug.
             */
            do_action("cn_{$taxonomy}_edit_form_fields", $term, $taxonomy);
            /**
             * Fires at the end of the Edit Term form for all taxonomies.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param object $tag      Current taxonomy term object.
             * @param string $taxonomy Current taxonomy slug.
             */
            do_action("{$taxonomy}_edit_form", $term, $taxonomy);
            ?>

					<input type="hidden" name="cn-action" value="update_category"/>

					<p class="submit">
						<a class="button button-warning" href="admin.php?page=connections_categories"><?php 
            _e('Cancel', 'connections');
            ?>
</a>
						<input type="submit" name="update" id="update" class="button button-primary" value="<?php 
            _e('Update Category', 'connections');
            ?>
"/>
					</p>

					<?php 
            $form->close();
            ?>

				</div>
			</div>
		<?php 
        } else {
            /**
             * @var CN_Terms_List_Table $table
             */
            $table = cnTemplatePart::table('term-admin', array('screen' => get_current_screen()->id));
            $table->prepare_items();
            ?>
			<div class="wrap nosubsub">

				<h2>Connections : <?php 
            _e('Categories', 'connections');
            ?>
</h2>

				<form class="search-form" action="" method="get">

					<input type="hidden" name="page" value="<?php 
            echo esc_attr($_REQUEST['page']);
            ?>
"/>
					<?php 
            $table->search_box(__('Search Categories', 'connections'), 'category');
            ?>

				</form>
				<br class="clear"/>

				<div id="col-container">

					<div id="col-right">
						<div class="col-wrap">
							<?php 
            $attr = array('action' => '', 'method' => 'post');
            $form->open($attr);
            //$form->tokenField( 'bulk_delete_category' );
            ?>
							<input type="hidden" name="cn-action" value="category_bulk_actions"/>
							<?php 
            $table->display();
            $form->close();
            ?>

							<br class="clear" />

							<script type="text/javascript">
								/* <![CDATA[ */
								(function ($) {
									$(document).ready(function () {
										$('#doaction, #doaction2').click(function () {
											if ($('select[name^="action"]').val() == 'delete') {
												var m = 'You are about to delete the selected category(ies).\n  \'Cancel\' to stop, \'OK\' to delete.';
												return showNotice.warn(m);
											}
										});
									});
								})(jQuery);
								/* ]]> */
							</script>

							<div class="form-wrap">
								<p><?php 
            _e('<strong>Note:</strong><br/>Deleting a category which has been assigned to an entry will reassign that entry as <strong>Uncategorized</strong>.', 'connections');
            ?>
</p>
							</div>

							<?php 
            /**
             * Fires after the taxonomy list table.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param string $taxonomy The taxonomy name.
             */
            do_action("cn_after-{$taxonomy}-table", $taxonomy);
            ?>

						</div>
					</div>
					<!-- right column -->

					<div id="col-left">
						<div class="col-wrap">

							<?php 
            /**
             * Fires before the Add Term form for all taxonomies.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param string $taxonomy The taxonomy slug.
             */
            do_action("cn_{$taxonomy}_pre_add_form", $taxonomy);
            ?>

							<div class="form-wrap">
								<h3><?php 
            _e('Add New Category', 'connections');
            ?>
</h3>

								<?php 
            $attr = array('action' => '', 'method' => 'post');
            $form->open($attr);
            $form->tokenField('add_category');
            /**
             * Fires at the beginning of the Add Tag form.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.7.0
             */
            do_action("cn_{$taxonomy}_term_new_form_tag");
            ?>
								<div class="form-field form-required term-name-wrap">
									<label for="category_name"><?php 
            _e('Name', 'connections');
            ?>
</label>
									<input type="text" aria-required="true" size="40" value="" id="category_name" name="category_name"/>
									<input type="hidden" value="" id="category_id" name="category_id"/>

									<p><?php 
            _e('The name is how it appears on your site.', 'connections');
            ?>
</p>
								</div>

								<div class="form-field term-slug-wrap">
									<label for="category_slug"><?php 
            _e('Slug', 'connections');
            ?>
</label>
									<input type="text" size="40" value="" id="category_slug" name="category_slug"/>

									<p><?php 
            _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.', 'connections');
            ?>
</p>
								</div>

								<div class="form-field term-parent-wrap">
									<label for="category_parent"><?php 
            _e('Parent', 'connections');
            ?>
</label>

									<?php 
            $dropdown_args = array('hide_empty' => 0, 'hide_if_empty' => FALSE, 'taxonomy' => 'category', 'name' => 'category_parent', 'orderby' => 'name', 'hierarchical' => TRUE, 'show_option_none' => __('None', 'connections'));
            /**
             * Filter the taxonomy parent drop-down on the Edit Term page.
             *
             * @since 3.7.0
             *
             * @param array   $dropdown_args    {
             *                                  An array of taxonomy parent drop-down arguments.
             *
             * @type int|bool $hide_empty       Whether to hide terms not attached to any posts. Default 0|false.
             * @type bool     $hide_if_empty    Whether to hide the drop-down if no terms exist. Default false.
             * @type string   $taxonomy         The taxonomy slug.
             * @type string   $name             Value of the name attribute to use for the drop-down select element.
             *                                      Default 'parent'.
             * @type string   $orderby          The field to order by. Default 'name'.
             * @type bool     $hierarchical     Whether the taxonomy is hierarchical. Default true.
             * @type string   $show_option_none Label to display if there are no terms. Default 'None'.
             * }
             *
             * @param string  $taxonomy         The taxonomy slug.
             */
            $dropdown_args = apply_filters('cn_taxonomy_parent_dropdown_args', $dropdown_args, 'category');
            cnTemplatePart::walker('term-select', $dropdown_args);
            ?>

									<p><?php 
            _e('Categories can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.', 'connections');
            ?>
</p>
								</div>

								<div class="form-field term-description-wrap">
									<?php 
            ob_start();
            /*
             * Now we're going to have to keep track of which TinyMCE plugins
             * WP core supports based on version, sigh.
             */
            if (version_compare($GLOBALS['wp_version'], '3.8.999', '<')) {
                $tinymcePlugins = array('inlinepopups', 'tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs');
            } else {
                $tinymcePlugins = array('tabfocus', 'paste', 'wordpress', 'wplink', 'wpdialogs');
            }
            wp_editor('', 'category_description', array('media_buttons' => FALSE, 'tinymce' => array('editor_selector' => 'tinymce', 'toolbar1' => 'bold, italic, underline, |, bullist, numlist, |, justifyleft, justifycenter, justifyright, alignleft, aligncenter, alignright, |, link, unlink, |, pastetext, pasteword, removeformat, |, undo, redo', 'toolbar2' => '', 'inline_styles' => TRUE, 'relative_urls' => FALSE, 'remove_linebreaks' => FALSE, 'plugins' => implode(',', $tinymcePlugins))));
            echo ob_get_clean();
            ?>

								</div>

								<input type="hidden" name="cn-action" value="add_category"/>

								<?php 
            /**
             * Fires after the Add Term form fields for hierarchical taxonomies.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param string $taxonomy The taxonomy slug.
             */
            do_action("cn_{$taxonomy}_add_form_fields", $taxonomy);
            submit_button(__('Add New Category', 'connections'), 'primary', 'add');
            /**
             * Fires at the end of the Add Term form for all taxonomies.
             *
             * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
             *
             * @since 3.0.0
             *
             * @param string $taxonomy The taxonomy slug.
             */
            do_action("cn_{$taxonomy}_add_form", $taxonomy);
            ?>

								<?php 
            $form->close();
            ?>
							</div>
						</div>
					</div>
					<!-- left column -->

				</div>
				<!-- Column container -->
			</div>
		<?php 
        }
    }
}
 /**
  * Output the current category description.
  *
  * @access public
  * @since  0.7.8
  *
  * @uses   get_query_var()
  *
  * @param  array  $atts [optional]
  * @param  array  $results [optional]
  *
  * @return string
  */
 public static function categoryDescription($atts = array(), $results = array())
 {
     // Check whether or not the category description should be displayed or not.
     if (!cnSettingsAPI::get('connections', 'connections_display_results', 'cat_desc')) {
         return '';
     }
     $out = '';
     $defaults = array('before' => '', 'after' => '', 'return' => FALSE);
     $atts = wp_parse_args($atts, $defaults);
     if (get_query_var('cn-cat-slug')) {
         // If the category slug is a descendant, use the last slug from the URL for the query.
         $categorySlug = explode('/', get_query_var('cn-cat-slug'));
         if (isset($categorySlug[count($categorySlug) - 1])) {
             $categorySlug = $categorySlug[count($categorySlug) - 1];
         }
         $term = cnTerm::getBy('slug', $categorySlug, 'category');
         $category = new cnCategory($term);
         $out = $category->getDescriptionBlock(array('return' => TRUE));
     }
     if (get_query_var('cn-cat')) {
         $categoryID = get_query_var('cn-cat');
         if (is_array($categoryID)) {
             if (empty($categoryID)) {
                 return $out;
             } else {
                 $categoryID = $categoryID[0];
                 if (empty($categoryID)) {
                     return $out;
                 }
             }
         }
         $term = cnTerm::getBy('id', $categoryID, 'category');
         $category = new cnCategory($term);
         $out = $category->getDescriptionBlock(array('return' => TRUE));
     }
     $out = (empty($atts['before']) ? '' : $atts['before']) . $out . (empty($atts['after']) ? '' : $atts['after']) . PHP_EOL;
     return self::echoOrReturn($atts['return'], $out);
 }
Example #7
0
function processDeleteCategory($type)
{
	global $connections;
	
	switch ($type)
	{
		case 'delete':
			$id = esc_attr($_GET['id']);
			check_admin_referer('category_delete_' . $id);
			
			$result = $connections->retrieve->category($id);
			$category = new cnCategory($result);
			$category->delete();
		break;
		
		case 'bulk_delete':
			foreach ( (array) $_POST['category'] as $cat_ID )
			{
				$cat_ID = esc_attr($cat_ID);
				
				$result = $connections->retrieve->category(attribute_escape($cat_ID));
				$category = new cnCategory($result);
				$category->delete();
			}
		break;
	}
}
Example #8
0
 /**
  * Add the the current Connections category description or entry bio excerpt  as the page meta description.
  *
  * @access private
  * @since  0.7.8
  * @static
  *
  * @uses   get_query_var()
  * @uses   esc_attr()
  * @uses   strip_shortcodes()
  *
  * @return string
  */
 public static function metaDesc()
 {
     global $connections;
     // Whether or not to filter the page title with the current directory location.
     if (!cnSettingsAPI::get('connections', 'connections_seo_meta', 'page_desc')) {
         return;
     }
     if (get_query_var('cn-cat-slug')) {
         // If the category slug is a descendant, use the last slug from the URL for the query.
         $categorySlug = explode('/', get_query_var('cn-cat-slug'));
         if (isset($categorySlug[count($categorySlug) - 1])) {
             $categorySlug = $categorySlug[count($categorySlug) - 1];
         }
         $term = $connections->term->getTermBy('slug', $categorySlug, 'category');
         $category = new cnCategory($term);
         $description = $category->getExcerpt(array('length' => 160));
     }
     if (get_query_var('cn-cat')) {
         if (is_array(get_query_var('cn-cat'))) {
             return;
         }
         $categoryID = get_query_var('cn-cat');
         $term = $connections->term->getTermBy('id', $categoryID, 'category');
         $category = new cnCategory($term);
         $description = $category->getExcerpt(array('length' => 160));
     }
     if (get_query_var('cn-entry-slug')) {
         $result = $connections->retrieve->entries(array('slug' => urldecode(get_query_var('cn-entry-slug'))));
         $entry = new cnEntry($result[0]);
         $description = $entry->getExcerpt(array('length' => 160));
     }
     if (empty($description)) {
         return;
     }
     echo '<meta name="description" content="' . esc_attr(trim(strip_shortcodes(strip_tags(stripslashes($description))))) . '"/>' . "\n";
 }