Permalink
Browse files

Put menu under tools. Swap tools logo for plugin logo

  • Loading branch information...
1 parent 541360b commit 7e274dca12a2b3c447172587c4b1d734eee6d3be @tlovett1 committed Aug 24, 2012
Showing with 25 additions and 88 deletions.
  1. +0 −84 df
  2. BIN images/{safe-redirect-icon.png → icon32x32.png}
  3. +25 −4 safe-redirect-manager.php
View
84 df
@@ -1,84 +0,0 @@
-diff --git a/safe-redirect-manager.php b/safe-redirect-manager.php
-index 139f861..9b3fe1b 100644
---- a/safe-redirect-manager.php
-+++ b/safe-redirect-manager.php
-@@ -49,9 +49,9 @@ class SRM_Safe_Redirect_Manager {
- * @return object
- */
- public function __construct() {
-+ add_action( 'init', array( $this, 'action_register_post_types' ) );
- add_action( 'parse_request', array( $this, 'action_parse_request' ), 0 );
- add_action( 'after_theme_setup', array( $this, 'action_load_texthost' ) );
-- add_action( 'init', array( $this, 'action_register_post_types' ) );
- add_action( 'save_post', array( $this, 'action_save_post' ) );
- add_filter( 'manage_' . $this->redirect_post_type . '_posts_columns' , array( $this, 'filter_redirect_columns' ) );
- add_action( 'manage_' . $this->redirect_post_type . '_posts_custom_column' , array( $this, 'action_custom_redirect_columns' ), 10, 2 );
-@@ -60,9 +60,19 @@ class SRM_Safe_Redirect_Manager {
- add_action( 'admin_notices', array( $this, 'action_redirect_chain_alert' ) );
- add_filter( 'the_title', array( $this, 'filter_admin_title' ), 100, 2 );
- add_action( 'admin_init', array( $this, 'action_admin_init' ) );
-+ add_filter( 'bulk_actions-' . 'edit-redirect_rule', array( $this, 'filter_bulk_actions' ) );
- }
-
- /**
-+ * Removes bulk actions from post manager
-+ *
-+ * @return array
-+ */
-+ public function filter_bulk_actions() {
-+ return array();
-+ }
-+
-+ /**
- * Echoes admin message if redirect chains exist
- *
- * @since 1.0
-@@ -397,27 +407,34 @@ class SRM_Safe_Redirect_Manager {
- * Force update on the redirect cache and return cache
- *
- * @since 1.0
-- * @uses get_posts, set_transient, get_post_meta
-+ * @uses set_transient, get_post_meta, the_post, have_posts, get_the_ID
- * @return array
- */
- public function update_redirect_cache() {
-- $redirects = get_posts( array( 'numberposts' => 1000, 'post_type' => $this->redirect_post_type ) );
-+ global $post;
-+ $old_post = $post;
-+
-+ $redirect_query = new WP_Query( array( 'posts_per_page' => 1000, 'post_type' => $this->redirect_post_type ) );
- $redirect_cache = array();
-
-- foreach ( $redirects as $redirect ) {
-- $redirect_from = get_post_meta( $redirect->ID, $this->meta_key_redirect_from, true );
-- $redirect_to = get_post_meta( $redirect->ID, $this->meta_key_redirect_to, true );
-- $status_code = get_post_meta( $redirect->ID, $this->meta_key_redirect_status_code, true );
--
-- if ( ! empty( $redirect_from ) && ! empty( $redirect_to ) ) {
-- $redirect_cache[] = array(
-- 'redirect_from' => $redirect_from,
-- 'redirect_to' => $redirect_to,
-- 'status_code' => absint( $status_code )
-- );
-+ if ( $redirect_query->have_posts() ) {
-+ while ( $redirect_query->have_posts() ) {
-+ $redirect_query->the_post();
-+
-+ $redirect_from = get_post_meta( get_the_ID(), $this->meta_key_redirect_from, true );
-+ $redirect_to = get_post_meta( get_the_ID(), $this->meta_key_redirect_to, true );
-+ $status_code = get_post_meta( get_the_ID(), $this->meta_key_redirect_status_code, true );
-+
-+ if ( ! empty( $redirect_from ) && ! empty( $redirect_to ) ) {
-+ $redirect_cache[] = array(
-+ 'redirect_from' => $redirect_from,
-+ 'redirect_to' => $redirect_to,
-+ 'status_code' => absint( $status_code )
-+ );
-+ }
- }
- }
--
-+ $post = $old_post;
- set_transient( $this->cache_key_redirects, $redirect_cache );
-
- return $redirect_cache;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -60,9 +60,31 @@ public function __construct() {
add_action( 'admin_notices', array( $this, 'action_redirect_chain_alert' ) );
add_filter( 'the_title', array( $this, 'filter_admin_title' ), 100, 2 );
add_action( 'admin_init', array( $this, 'action_admin_init' ) );
- add_filter( 'bulk_actions-' . 'edit-redirect_rule', array( $this, 'filter_bulk_actions' ) );
+ add_filter( 'bulk_actions-' . 'edit-redirect_rule', array( $this, 'filter_bulk_actions' ) );
+ add_action( 'admin_print_styles-edit.php', array( $this, 'action_print_logo_css' ), 10, 1 );
+ add_action( 'admin_print_styles-post.php', array( $this, 'action_print_logo_css' ), 10, 1 );
}
+ /**
+ * Swap tools logo for plugin logo
+ *
+ * @uses plugins_url
+ * @return void
+ */
+ public function action_print_logo_css() {
+ global $post;
+ if ( is_object( $post ) && $this->redirect_post_type == $post->post_type ) {
+ ?>
+ <style type="text/css">
+ #icon-tools {
+ background: url("<?php echo plugins_url(); ?>/safe-redirect-manager/images/icon32x32.png") no-repeat top left !important;
+ margin-right: 0;
+ }
+ </style>
+ <?php
+ }
+ }
+
/**
* Removes bulk actions from post manager
*
@@ -293,7 +315,7 @@ public function action_register_post_types() {
'add_new_item' => __( 'Safe Redirect Manager', 'safe-redirect-manager' ),
'edit_item' => __( 'Edit Redirect Rule', 'safe-redirect-manager' ),
'new_item' => __( 'New Redirect Rule', 'safe-redirect-manager' ),
- 'all_items' => __( 'All Redirects', 'safe-redirect-manager' ),
+ 'all_items' => __( 'Safe Redirect Manager', 'safe-redirect-manager' ),
'view_item' => __( 'View Redirect Rule', 'safe-redirect-manager' ),
'search_items' => __( 'Search Redirects', 'safe-redirect-manager' ),
'not_found' => __( 'No redirect rules found.', 'safe-redirect-manager' ),
@@ -306,14 +328,13 @@ public function action_register_post_types() {
'public' => false,
'publicly_queryable' => true,
'show_ui' => true,
- 'show_in_menu' => true,
+ 'show_in_menu' => 'tools.php',
'query_var' => false,
'rewrite' => false,
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'register_meta_box_cb' => array( $this, 'action_redirect_rule_metabox' ),
- 'menu_icon' => plugins_url() . '/safe-redirect-manager/images/safe-redirect-icon.png',
'menu_position' => 80,
'supports' => array( '' )
);

0 comments on commit 7e274dc

Please sign in to comment.