articlesss.com. Attention! If you deactivate the plugin its settings will be removed from the database.', 'article-directory'); return $string; } add_filter('pre_kses', 'artdir_plugin_description'); function artdir_default_options() { $def_options['exclude_cats'] = 0; $def_options['show_parent_count'] = 1; $def_options['show_child_count'] = 1; $def_options['hide_empty'] = 0; $def_options['desc_for_parent_title'] = 1; $def_options['desc_for_child_title'] = 1; $def_options['child_hierarchical'] = 1; $def_options['column_count'] = 3; $def_options['sort_by'] = 0; $def_options['sort_direction'] = 0; $def_options['no_child_alert'] = 1; $def_options['show_child'] = 1; $def_options['maximum_child'] = 0; $def_options['author_interface'] = 0; $def_options['author_panel_id'] = ''; $def_options['article_status'] = 0; $def_options['minimum_symbols'] = 700; $def_options['maximum_links'] = 3; $def_options['sel_only_one_cat'] = 1; $def_options['show_tags'] = 0; $def_options['allow_new_tags'] = 0; $def_options['publish_terms_text'] = ''; $def_options['kinderloss'] = 1; $def_options['show_article_code'] = 0; return $def_options; } function artdir_validate($input) { $def_options = artdir_default_options(); $input['exclude_cats'] = (preg_match("/^(\d+,)*\d+$/", $input['exclude_cats']) ? $input['exclude_cats'] : $def_options['exclude_cats']); $input['show_parent_count'] = ($input['show_parent_count'] == 1 ? 1 : 0); $input['show_child_count'] = ($input['show_child_count'] == 1 ? 1 : 0); $input['hide_empty'] = ($input['hide_empty'] == 1 ? 1 : 0); $input['desc_for_parent_title'] = ($input['desc_for_parent_title'] == 1 ? 1 : 0); $input['desc_for_child_title'] = ($input['desc_for_child_title'] == 1 ? 1 : 0); $input['child_hierarchical'] = ($input['child_hierarchical'] == 1 ? 1 : 0); $input['column_count'] = (is_numeric($input['column_count']) && $input['column_count'] > 0 ? $input['column_count'] : $def_options['column_count']); $input['sort_by'] = ($input['sort_by'] == 1 ? 1 : 0); $input['sort_direction'] = ($input['sort_direction'] == 1 ? 1 : 0); $input['no_child_alert'] = ($input['no_child_alert'] == 1 ? 1 : 0); $input['show_child'] = ($input['show_child'] == 1 ? 1 : 0); $input['maximum_child'] = (is_numeric($input['maximum_child']) && $input['maximum_child'] > 0 ? $input['maximum_child'] : $def_options['maximum_child']); $input['author_interface'] = ($input['author_interface'] == 1 ? 1 : 0); $input['author_panel_id'] = (!empty($input['author_panel_id']) && $input['author_panel_id'] > 0 && is_numeric($input['author_panel_id']) ? $input['author_panel_id'] : ''); $input['article_status'] = ($input['article_status'] == 1 ? 1 : 0); $input['minimum_symbols'] = (!empty($input['minimum_symbols']) && $input['minimum_symbols'] > 0 && is_numeric($input['minimum_symbols']) ? $input['minimum_symbols'] : $def_options['minimum_symbols']); $input['maximum_links'] = (!empty($input['maximum_links']) && $input['maximum_links'] >= 0 && is_numeric($input['maximum_links']) ? $input['maximum_links'] : $def_options['maximum_links']); $input['sel_only_one_cat'] = ($input['sel_only_one_cat'] == 1 ? 1 : 0); $input['show_tags'] = ($input['show_tags'] == 1 ? 1 : 0); $input['allow_new_tags'] = ($input['allow_new_tags'] == 1 ? 1 : 0); $input['publish_terms_text'] = (!empty($input['publish_terms_text']) ? $input['publish_terms_text'] : ''); $input['kinderloss'] = ($input['kinderloss'] == 1 ? 1 : 0); $input['show_article_code'] = ($input['show_article_code'] == 1 ? 1 : 0); if (isset($_POST['artdirReset'])) { $input = artdir_default_options(); } return $input; } function artdir_uninstall() { delete_option('article_directory'); } register_deactivation_hook( __FILE__, 'artdir_uninstall'); function article_directory($echo = TRUE) { $options = get_option('article_directory'); $exclude_cat = array($options['exclude_cats']); $show_parent_count = $options['show_parent_count']; $show_child_count = $options['show_child_count']; $hide_empty = $options['hide_empty']; $desc_for_parent_title = $options['desc_for_parent_title']; $desc_for_child_title = $options['desc_for_child_title']; $child_hierarchical = $options['child_hierarchical']; $column_count = $options['column_count']; $sort_by = $options['sort_by']; $sort_direction = $options['sort_direction']; $no_child_alert = $options['no_child_alert']; $show_child = $options['show_child']; $maximum_child = $options['maximum_child']; global $wpdb; $cal_tree = array(); if (!$column_count) $column_count = 1; global $rssfeeds; $feed = ''; if ($rssfeeds) { $feed = 'RSS'; $show_parent_count = 0; $show_child_count = 0; } if ($sort_by == 0) $order_by = $orderby = 'name'; elseif ($sort_by == 1) { $order_by = 'term_order'; $orderby = 'term_group'; } $parent_cats = $wpdb->get_results("SELECT * FROM " . $wpdb->term_taxonomy . " term_taxonomy LEFT JOIN " . $wpdb->terms . " terms ON terms.term_id = term_taxonomy.term_id WHERE term_taxonomy.taxonomy = 'category' AND term_taxonomy.parent = 0 " . ( count($exclude_cat) ? ' AND terms.term_id NOT IN (' . implode(',', $exclude_cat) . ') ' : '' ) . " ORDER BY terms." . $order_by); foreach ($parent_cats as $parent) { $summ = "SELECT SUM(count) FROM " . $wpdb->term_taxonomy . " WHERE taxonomy = 'category' AND parent = " . $parent->term_id; $child_summ = mysql_result(mysql_query($summ),0); //считаем кол-во статей в подрубрике 1-го уровня $catid = $wpdb->get_var("SELECT term_ID FROM " . $wpdb->term_taxonomy . " WHERE taxonomy = 'category' AND parent = " . $parent->term_id); //определяем ID подрубрики 1-го уровня $sub_child_summ = (int)$catid ? $wpdb->get_var("SELECT SUM(count) FROM " . $wpdb->term_taxonomy . " WHERE taxonomy = 'category' AND parent = " . $catid) : 0; //считаем кол-во статей в подрубрике 2-го уровня $cat_name = get_the_category_by_ID($parent->term_id); $descr = sprintf(__("View all posts filed under %s"), $cat_name); if ($desc_for_parent_title == 1) { if (empty($parent->description)) { $descr = $descr; } else { $descr = $parent->description; } } $child_summ += $parent->count; //прибавляем к сумме родительской рубрики сумму в подрубрике 1-го уровня $child_summ += $sub_child_summ; //прибавляем к сумме родительской рубрики сумму в подрубрике 2-го уровня if ($show_parent_count == 1) { $parent_count = ' (' . $child_summ . ')'; } else { $parent_count = ''; } $cal_tree[] = array( 'cat' => array( 'href' => get_category_link($parent->term_id), 'title' => $descr, 'name' => $cat_name, 'count' => $parent_count ), 'cats'=> wp_list_categories( ( count($exclude_cat) ? 'exclude=' . implode(',', $exclude_cat) : '' ) . '&orderby=' . $orderby . '&show_count=' . $show_child_count . '&hide_empty=' . $hide_empty . '&use_desc_for_title=' . $desc_for_child_title . '&child_of=' . $parent->term_id . '&title_li=&hierarchical=' . $child_hierarchical . '&echo=0&feed=' . $feed) ); } $_tree = array(); $count = count($cal_tree); if ($sort_direction) { $line_count = ceil( $count / $column_count ); $limit = $count - $line_count * $column_count % $count; for ($i = 0; $i < $count; $i++) { $index = floor($i / $line_count) + ($limit && $i > $limit ? 1 : 0); if (!isset($_tree[$index])) { $_tree[$index] = array(); } $_tree[$index][] = &$cal_tree[$i]; } } else { for ($i = 0; $i < $count; $i++) { $index = $i % $column_count; if (!isset($_tree[$index])) { $_tree[$index] = array(); } $_tree[$index][] = &$cal_tree[$i]; } } if (count($_tree)) { $write = '
' . __('Attention', 'article-directory') . '! ' . __('The option "ID of author panel page" must be filled obligatory. Otherwise, the authors are unable to add articles.', 'article-directory') . '
' . __('Source') . ': ' . get_permalink() . '
"); $("#textVersion").text("' . get_the_title() . '" + "\r\n\r\n" + $("#artdirPost").text() + "\r\n" + "' . __('Source') . ': ' . get_permalink() . '"); $("#getArticleCode textarea, #getArticleCode input").click(function() { $(this).select() }); }) })(jQuery)'.__('Article Source', 'article-directory').'
'; if (is_single()) { return '