'); add_option('seosiloing_after_list', ''); add_option('seosiloing_sort_column', 'post_title'); add_option('seosiloing_sort_order', 'ASC'); add_option('seosiloing_noposts_msg', "
There are currently no posts in the '{cat_name}' category.
" ); add_option('seosiloing_nocategory_msg', "There is no matching category for '{cat_name}'.
" ); function seosiloing_add_option_pages() { if (function_exists('add_options_page')) { add_options_page('SEO Siloing', 'SEOSiloing', 8, __FILE__, 'seosiloing_options_page'); } } function seosiloing_options_page() { global $seosiloing_ver; if (isset($_POST['set_defaults'])) { echo '';
update_option('seosiloing_before_list', ' There are currently no posts in the '{cat_name}' category. There is no matching category for '{cat_name}'.');
update_option('seosiloing_after_list', '
');
update_option('seosiloing_sort_column', 'post_title');
update_option('seosiloing_sort_order', 'ASC');
update_option('seosiloing_noposts_msg', "
'; update_option('seosiloing_before_list', stripslashes((string)$_POST['seosiloing_before_list'])); update_option('seosiloing_after_list', stripslashes((string)$_POST['seosiloing_after_list'])); update_option('seosiloing_sort_column', stripslashes((string)$_POST['seosiloing_sort_column'])); update_option('seosiloing_sort_order', stripslashes((string)$_POST['seosiloing_sort_order'])); update_option('seosiloing_noposts_msg', stripslashes((string)$_POST['seosiloing_noposts_msg'])); update_option('seosiloing_nocategory_msg', stripslashes((string)$_POST['seosiloing_nocategory_msg'])); echo 'Configuration updated!'; echo '
To check for new versions or get more information, visit this plugin's page.
[SEO Siloing] ' . $str . "
"; } function seosiloing_debug( $debug=true ){ global $seosiloing_debug; $old = $seosiloing_debug; $seosiloing_debug = $debug; return $old; } function seosiloing_category_posts( $cat='' ) { $before_list = get_option('seosiloing_before_list'); $after_list = get_option('seosiloing_after_list'); $sort_column = get_option('seosiloing_sort_column'); $sort_order = get_option('seosiloing_sort_order'); $noposts_msg = get_option('seosiloing_noposts_msg'); $nocategory_msg = get_option('seosiloing_nocategory_msg'); $t_out = ''; global $wp_query; global $seosiloing_debug; if( empty( $cat ) ){ $page = $wp_query->post; if( $seosiloing_debug ){ $t_out .= seosiloing_msg( "Getting category ID for slug '" . $page->post_name . "'" ); } $cat = $page->post_name; $catID = seosiloing_catID( $cat ); } else if( is_numeric( $cat ) ){ $catID = $cat; } else { if( $seosiloing_debug ){ $t_out .= seosiloing_msg( "Getting category ID for category '" . $cat . "'" ); } $catID = seosiloing_catID( $cat ); } $category = null; if( $catID ){ $category = get_category( $catID ); } if( $category ){ $cat = $category->cat_name; if( empty( $cat ) ){ $cat = $category->category_nicename; } if( $seosiloing_debug ){ $t_out .= seosiloing_msg( "Generating list for category ID " . $catID . ", '$cat'" ); } $opt = array(); $opt[] = "numberposts=999"; $opt[] = "orderby=" . $sort_column; $opt[] = "order=" . $sort_order; $opt[] = "category=" . $catID; $opt_string = implode('&', $opt); $posts = get_posts($opt_string); if( count( $posts ) > 0 ){ $t_out .= $before_list; foreach( $posts as $post ) : if($post->comment_count == '0') { $t_out .= '". $seodebug . "
", $seodebug, $content ); $content = str_replace( $seodebug, seosiloing_msg( "debug enabled" ), $content ); } // Otherwise make the substitutions $pattern = '/(\s*)?(\s*<\/p>)?/i'; $matches = array(); $pos = preg_pos_all( $pattern, $content, $matches, $args ); /* $content .= "
Count is " . count($pos) . "
"; foreach( $pos as $p ){ $content .= "Pos: " . $p. "
"; } foreach( $matches as $m ){ $m = str_replace( "<", "<", $m ); $m = str_replace( ">", ">", $m ); $content .= "Substring: " . $m . "
"; } foreach( $args as $a ){ $content .= "Arg: " . $a . "
"; } */ $i = 0; while( $i < count( $pos ) ){ $list = seosiloing_category_posts( $args[$i] ); $content = str_replace( $matches[$i], $list, $content ); $i += 1; } return $content; } add_filter('the_content', 'seosiloing_process'); add_action('admin_menu', 'seosiloing_add_option_pages'); function preg_pos($hs_pattern, $hs_subject, &$hs_fullstring, &$hs_argstring, $hn_offset = 0) { $hs_foundstring = NULL; if (preg_match($hs_pattern, $hs_subject, $ha_matches, PREG_OFFSET_CAPTURE, $hn_offset)) { $hs_fullstring = $ha_matches[0][0]; $hs_argstring = $ha_matches[3][0]; return $ha_matches[0][1]; } else { return FALSE; } } function preg_pos_all($hs_pattern, $hs_subject, &$ha_fullstring, &$ha_argstring, $hn_offset = 0, $hn_limit = 0) { $ha_positions = array(); $ha_fullstring = array(); $ha_argstring = array(); $hn_count = 0; while (false !== ($pos = preg_pos($hs_pattern, $hs_subject, $hs_fullstring, $hs_argstring, $hn_offset)) && ($hn_limit == 0 || $hn_count < $hn_limit)) { $ha_positions[] = $pos; $ha_fullstring[] = $hs_fullstring; $ha_argstring[] = $hs_argstring; $hn_offset = $pos + strlen( $hs_fullstring ); ++$hn_count; } return $ha_positions; } ?>