'parent', 'id' => 'term_id'); function start_lvl(&$output, $depth, $args) { $output .= "
\n"; } function end_lvl(&$output, $depth, $args) { $output .= "
"; } function start_el(&$output, $category, $depth, $args) { extract($args); $arrids = explode(';', $_POST['setcat_catids']); $class = ''; if (gettype($popular_cats) !== "array") $class = ''; else $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; $output .= "\n"; $output .= "
" . '+ ' . ''; } function end_el(&$output, $category, $depth, $args) { $output .= "
"; } } function com_aswinanand_assignCategories() { ?> 0) { if ($_POST['setcat_numposts'] >= 500) update_option('setcat_numposts', 500); else update_option('setcat_numposts', $_POST['setcat_numposts']); } else if ('all' == $_POST['setcat_numposts']) { update_option('setcat_numposts', 'all'); } else { update_option('setcat_numposts', 25); } } echo '

Options have been updated successfully.'; echo 'Close

'; } /* Apply selected categories to posts */ $arrids = null; $arrpostids = null; $res = null; $suc = ""; $fai = ""; if (isset($_POST['setcat_catids']) && 0 != strlen(trim($_POST['setcat_catids'])) ) { $arrids = explode(';', $_POST['setcat_catids']); if (isset($_POST['setcat_postids']) && 0 != strlen(trim($_POST['setcat_postids'])) ) { $arrpostids = explode(';', $_POST['setcat_postids']); $preserve = isset($_POST['setcat_preserve']) ? true : false; echo '
'; echo 'Close'; echo '

'; foreach ($arrpostids as $ap) { if ($preserve) { $res = wp_get_object_terms($ap, 'category', array('fields'=>'ids')); $res = array_unique(array_merge($res, $arrids)); $pdata = array('ID'=>$ap, 'post_category'=>$res); } else { $pdata = array('ID'=>$ap, 'post_category'=>$arrids); } if (is_numeric(wp_update_post($pdata))) $suc .= $ap . ", "; else $fai .= $ap . ", "; } if (strlen($suc) > 0) echo "Categories have been successfully for the posts: " . substr($suc, 0, strlen($suc)-2) . "
"; if (strlen($fai) > 0) echo "Categories have NOT been applied for the posts: " . substr($fai, 0, strlen($fai)-2); echo '
'; echo '

'; } } /* Display the UI */ echo '
'; echo '

Search

'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo '
'; echo ' '; echo ' '; echo ' '; echo '
'; echo '
'; echo '
'; echo '

Options


'; echo ''; echo '

'; echo ''; echo '

'; echo ''; echo ' '; echo '
'; echo '

Set Categories

'; echo '
'; global $wpdb; $p = $wpdb->prefix; $res = get_terms('category','get=all'); echo '

Pick your categories

'; echo 'Select All Categories  |  '; echo 'Unselect All Categories

'; echo '
'; $arrgs = array( 'hierarchical'=>true, 'hide_empty'=>false ); $res1 = get_categories($arrgs); $cat_args = array( 'show_option_all' => '', 'show_option_none' => '', 'orderby' => 'id', 'order' => 'ASC', 'show_last_update' => 0, 'show_count' => 0, 'hide_empty' => 1, 'child_of' => 0, 'exclude' => '', 'echo' => 1, 'selected' => 0, 'hierarchical' => 0, 'name' => 'cat', 'class' => 'postform', 'depth' => 0, 'tab_index' => 0 ); $argu = array($res1, 1000, wp_parse_args(array('hierarchical'=>true, 'hide_empty'=>false), $cat_args)); $wlk = new Walker_Category_Div(); echo call_user_func_array(array(&$wlk, 'walk'), $argu); echo '
'; echo ''; echo '
'; /* List Posts */ global $wp_query; global $post; $wp_query->query(array('s'=>isset($_POST['search'])?$_POST['search']:'', 'paged'=>isset($_GET['paged'])?$_GET['paged']:1, 'posts_per_page'=>$numposts)); $page_links = paginate_links( array( 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', 'total' => $wp_query->max_num_pages, 'current' => isset($_GET['paged'])?$_GET['paged']:1 )); echo "

Pick your posts

"; echo '

'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; while (have_posts()) { the_post(); echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo "
Select All Posts | Unselect All Posts | '; echo '
IDPost TitleCategories
'; echo 'ID, $arrpostids)) echo 'checked="checked" ';*/ echo 'type="checkbox" id="' . $post->ID . '" name="' . $post->ID . '" value="' . $post->ID . '" />' . '' . get_the_category_list(',', '', $post->ID) . '
IDPost TitleCategories
Select All Posts | Unselect All Posts'; if ( $page_links ) echo "
$page_links
"; echo '
"; echo ''; echo '

'; echo '
'; echo '
'; echo ''; } function com_aswinanand_setAdminPages() { add_management_page('Assign Categories', 'Assign Categories', 8, __FILE__, 'com_aswinanand_assignCategories'); } function com_aswinanand_removeSetCat() { delete_option('setcat_select_subcat'); delete_option('setcat_numposts'); } add_action('admin_menu', 'com_aswinanand_setAdminPages'); if (function_exists('register_uninstall_hook')) { register_uninstall_hook(__FILE__, 'com_aswinanand_removeSetCat'); } ?>