change your theme completely' ), admin_url( 'options-general.php' ) );?>

  • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) );?>
  • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) );?>
  • ' . __( 'Edit your front page' ) . '', get_edit_post_link( get_option( 'page_on_front' ) ) );?>
  • ' . __( 'Add additional pages' ) . '', admin_url( 'post-new.php?post_type=page' ) );?>
  • ' . __( 'Add a blog post' ) . '', admin_url( 'post-new.php' ) );?>
  • ' . __( 'Write your first blog post' ) . '', admin_url( 'post-new.php' ) );?>
  • ' . __( 'Add an About page' ) . '', admin_url( 'post-new.php?post_type=page' ) );?>
  • ' . __( 'View your site' ) . '', home_url( '/' ) );?>

', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) );?>
  • ' . __( 'Turn comments on or off' ) . '', admin_url( 'options-discussion.php' ) );?>
  • ' . __( 'Learn more about getting started' ) . '', __( 'http://codex.wordpress.org/First_Steps_With_WordPress' ) );?>

  • 0 ) { $title = apply_filters('ayo_the_titlesmall', $before . $title . $after, $before, $after); if ( $echo ) { echo $title; } else{ return $title; } }; if ( strlen($title)> 10 ) { $title = apply_filters('ayo_the_titlesmall2', $before . $title . $after, $before, $after); if ( $echo ) { echo "..."; }else { echo "...";} } } //query_posts($query_string."&featured=yes")); class Ayo_Pins_Post { var $db = NULL; public $post_types = array(); function __construct() { add_action('init', array(&$this,'init' )); add_action('admin_init', array(&$this,'admin_init' )); add_action('wp_ajax_toggle-featured-post', array(&$this,'admin_ajax' )); // add_action( 'wp_ajax_toggle-', 'my_ajax_callback' ); } function init() { add_filter('query_vars', array(&$this,'query_vars' )); add_action('pre_get_posts', array(&$this,'pre_get_posts' )); // add_action('admin_enqueue_scripts', 'my_ajax_callback'); } function admin_init() { // add_action('admin_enqueue_scripts',array(&$this,'my_ajax_callback')); add_filter('current_screen', array(&$this,'my_current_screen' )); add_action('admin_head-edit.php', array(&$this,'admin_head' )); add_filter('pre_get_posts', array(&$this,'admin_pre_get_posts' ) , 1); $this->post_types = get_post_types(array( '_builtin' => false, ) , 'names', 'or'); $this->post_types['post'] = 'post'; $this->post_types['page'] = 'page'; $this->post_types['page'] = 'product'; ksort($this->post_types); foreach ($this->post_types as $key => $val) { global $ayo_options; if ($ayo_options['pins_filter'] == true) { add_filter('manage_edit-' . $key . '_columns', array(&$this, 'manage_posts_columns' ));} add_action('manage_' . $key . '_posts_custom_column', array(&$this, 'manage_posts_custom_column' ) , 10, 2); } } //set Pins column function ayo_add_views_link($views) { $post_type = ((isset($_GET['post_type']) && $_GET['post_type'] != "") ? $_GET['post_type'] : 'post'); $count = $this->ayo_total_featured($post_type); $class = $_GET['post_status'] == 'pin_featured' ? "current" : ''; $views['pin_featured'] = "Pins ({$count})"; return $views; } function ayo_total_featured($post_type = "post") { $rowQ = new WP_Query(array( 'post_type' => $post_type, 'post__in' => get_user_meta( get_current_user_id(),'pins')[0], 'posts_per_page' => 1 )); wp_reset_postdata(); wp_reset_query(); $rows = $rowQ->found_posts; unset($rowQ); return $rows; } //Taking care of the AJAX function my_current_screen($screen) { if (defined('DOING_AJAX') && DOING_AJAX) { return $screen; } $this->post_types = get_post_types(array( '_builtin' => false, ) , 'names', 'or'); $this->post_types['post'] = 'post'; $this->post_types['page'] = 'page'; $this->post_types['page'] = 'product'; ksort($this->post_types); foreach ($this->post_types as $key => $val) { add_filter('views_edit-' . $key, array(&$this, 'ayo_add_views_link' )); } return $screen; } //Create pins column function manage_posts_columns($columns) { global $current_user; get_currentuserinfo(); if (current_user_can('edit_posts', $user_id)) { $columns['pin_featured'] = __('Pins'); } return $columns; } function manage_posts_custom_column($column_name, $post_id) { //echo "here"; if ($column_name == 'pin_featured') { $is_featured = ayo_isPinned($post_id); $class = "dashicons"; $text = ""; if ($is_featured) { $class.= " dashicons-sticky"; $text = ""; } else { $class.= " dashicons-admin-post"; } echo "$text"; /// echo "$text"; } } //send/receive AJAX request function admin_head() { echo ''; } //Pin inside Search function my_ajax_callback($hook) { header('Content-Type: application/json'); $post_id = $_POST['post_id']; $is_featured = ayo_isPinned($post_id); $newStatus = $is_featured ? false : true; ayo_changePin($_POST['post_id']); // delete_post_meta($post_id, '_is_featured'); // add_post_meta($post_id, '_is_featured', $newStatus); echo json_encode(array( 'ID' => $post_id, 'new_status' => $newStatus, 'ayo_total_featured' => $this->ayo_total_featured(get_post_type($post_id)) )); die(); } // end of my_ajax_callback() function admin_ajax() { header('Content-Type: application/json'); $post_id = $_POST['post_id']; $is_featured = ayo_isPinned($post_id); $newStatus = $is_featured ? false : true; ayo_changePin($_POST['post_id']); // delete_post_meta($post_id, '_is_featured'); // add_post_meta($post_id, '_is_featured', $newStatus); echo json_encode(array( 'ID' => $post_id, 'new_status' => $newStatus, 'ayo_total_featured' => $this->ayo_total_featured(get_post_type($post_id)) )); die(); } function admin_pre_get_posts($query) { global $wp_query; if (is_admin() && $_GET['post_status'] == 'pin_featured') { $query->set('post__in', get_user_meta( get_current_user_id(),'pins')[0]); // $query->set('meta_key', '_is_featured'); // $query->set('meta_value', 'yes'); } return $query; } function query_vars($public_query_vars) { $public_query_vars[] = 'pin_featured'; return $public_query_vars; } function pre_get_posts($query) { if (!is_admin()) { if ($query->get('pin_featured') == 'yes') { $query->set('post__in', get_user_meta( get_current_user_id(),'pins')[0]); // $query->set('meta_key', '_is_featured'); // $query->set('meta_value', 'yes'); } } return $query; } //end of setup } //widget setup (deprecated) class Ayo_Pins_Post_Widget extends WP_Widget { private $post_types = array(); function __construct() { parent::WP_Widget(false, $name = 'Featured Post'); } function form($instance) { echo ""; echo "get_field_id('num') . "\" class = \"widefat\" name = \"" . $this->get_field_name('num') . "\" type=\"text\" value =\"" . $num . "\" / >"; echo "

    "; } function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = strip_tags($new_instance['title']); $instance['num'] = (int)strip_tags($new_instance['num']); $instance['post_type'] = strip_tags($new_instance['post_type']); if ($instance['num'] < 1) { $instance['num'] = 10; } return $instance; } } $Featured_Post = new Ayo_Pins_Post(); add_action('widgets_init', create_function('', 'return register_widget("Ayo_Pins_Post_Widget");') , 100); /* Make pins column smaller */ add_action('admin_head', 'pins_column_size'); function pins_column_size() { echo ''; } /*Filter post types*/ add_action('restrict_manage_posts', 'ayo_filter_post_type_by_taxonomy'); function ayo_filter_post_type_by_taxonomy() { global $typenow; $post_type = get_post_types(); // change to your post type $taxonomy = 'group'; // change to your taxonomy if ($typenow == $post_type) { $selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : ''; $info_taxonomy = get_taxonomy($taxonomy); wp_dropdown_categories(array( 'show_option_all' => __("Show All {$info_taxonomy->label}"), 'taxonomy' => $taxonomy, 'name' => $taxonomy, 'orderby' => ASC, 'selected' => $selected, 'show_count' => true, 'hide_empty' => true, )); }; } remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0); /* PINS setup */ function ayo_changePin($id) { $user_id = get_current_user_id(); // delete_user_meta($user_id,'pins'); $pins = get_user_meta( $user_id,'pins'); if (!$pins) { $pins =array(); $pins[]= $id; add_user_meta($user_id,'pins', $pins); $status = "pinned"; $color ="color"; } else { // return var_export(in_array($id, $pins)).var_export($pins); if (in_array($id, $pins[0])) { $key = array_search($id,$pins[0]); unset($pins[0][$key]); $status = "delete"; } else { $pins[0][]= $id; $status = "pinned"; }; update_user_meta( $user_id,'pins', $pins[0]); }; return json_encode(array("status"=>$status,"pins"=>$pins)); } function ayo_isPinned($id) { $user_id = get_current_user_id(); $pins = get_user_meta( $user_id,'pins'); if ($pins) { return in_array($id, $pins[0]); } return false; } //Pin from card AJAX call add_action( 'wp_ajax_ayo_t_pin', 'ayo_t_pin' ); function ayo_t_pin() { echo ayo_changePin($_GET["post_id"]); die(); } /* unpin from card */ add_action( 'wp_ajax_ayo_un_pin', 'ayo_un_pin' ); function ayo_un_pin() { echo ayo_changePin($_GET["post_id"]); echo $_GET["post_id"]; die(); } //END of file