Changeset 2364265
- Timestamp:
- 08/18/2020 07:41:38 PM (6 years ago)
- Location:
- wp-edit-homepage/trunk
- Files:
-
- 4 edited
-
. (modified) (1 prop)
-
includes/class-wp-edit-homepage-plugin.php (modified) (3 diffs)
-
readme.txt (modified) (1 diff)
-
wp-edit-homepage.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-edit-homepage/trunk
-
Property
svn:ignore
set to
phpcs.xml.dist
.git
-
Property
svn:ignore
set to
-
wp-edit-homepage/trunk/includes/class-wp-edit-homepage-plugin.php
r2354426 r2364265 27 27 add_action( 'admin_head', array( $this, 'add_global_wp_admin_submenu_filter' ), 15 ); 28 28 29 // Add the homepage edit link .29 // Add the homepage edit link to WP admin menu. 30 30 add_filter( 'wpedh_filter_global_wp_admin_submenu', array( $this, 'add_homepage_edit_link' ) ); 31 32 // Add the homepage edit link to plugins page item. 33 if ( defined( 'WP_EDIT_HOMEPAGE_BASENAME' ) ) { 34 add_filter( 'plugin_action_links_' . WP_EDIT_HOMEPAGE_BASENAME, array( $this, 'add_plugins_page_link' ) ); 35 } 31 36 } 32 37 … … 55 60 * 56 61 * @param array $submenu An array of WP admin menu items. 62 * 63 * @return array The filtered WP admin menu with the home page edit link added (if possible). 57 64 */ 58 65 public function add_homepage_edit_link( $submenu ) { 59 60 // Bail early - no 'static' homepage. 61 if ( get_option( 'show_on_front' ) !== 'page' ) { 62 return $submenu; 63 } 64 65 $homepage_id = get_option( 'page_on_front', 0 ); 66 67 // Bail early - homepage not set. 68 if ( empty( $homepage_id ) ) { 69 return $submenu; 70 } 71 72 // Get admin relative page edit URL. 73 $homepage_edit_link = get_edit_post_link( $homepage_id ); 66 // Get homepage edit link. 67 $homepage_edit_link = $this->get_edit_homepage_link(); 74 68 75 69 // Bail early - no edit link found. … … 90 84 return $submenu; 91 85 } 86 87 /** 88 * Generates a link to the homepage edit screen. 89 * 90 * @return string The link to the homepage edit screen. Empty string on failure. 91 */ 92 public function get_edit_homepage_link() { 93 $homepage_edit_link = ''; 94 95 // Bail early - no 'static' homepage. 96 if ( get_option( 'show_on_front' ) !== 'page' ) { 97 return $homepage_edit_link; 98 } 99 100 $homepage_id = get_option( 'page_on_front', 0 ); 101 102 // Bail early - invalid homepage ID somehow. 103 if ( empty( $homepage_id ) ) { 104 return $homepage_edit_link; 105 } 106 107 // Get homepage edit URL. 108 $homepage_edit_link = get_edit_post_link( $homepage_id ); 109 110 return $homepage_edit_link; 111 } 112 113 /** 114 * Filters the list of action links displayed for this plugin in the Plugins list table. 115 * 116 * @param array $links An array of plugin action links. 117 * 118 * @return array The filtered array of plugin action links. 119 */ 120 public function add_plugins_page_link( $links ) { 121 $link = $this->get_edit_homepage_link(); 122 $text = __( 'Edit Homepage', 'wp-edit-homepage' ); 123 124 // No homepage set - add fallback link to reading page. 125 if ( empty( $link ) ) { 126 $link = admin_url( 'options-reading.php' ); 127 $text = __( 'Set Homepage', 'wp-edit-homepage' ); 128 } 129 130 // Create the link. 131 $plugins_page_link = '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>'; 132 133 // Adds the link to the start of the array. 134 array_unshift( $links, $plugins_page_link ); 135 136 return $links; 137 } 92 138 } 93 139 } -
wp-edit-homepage/trunk/readme.txt
r2354426 r2364265 3 3 Tags: edit, homepage, page, admin 4 4 Requires at least: 5.0 5 Tested up to: 5. 46 Stable tag: 1. 05 Tested up to: 5.5 6 Stable tag: 1.1 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html 10 10 11 A simple WordPress plugin that adds a homepage edit link to the admin sidebar 11 A simple WordPress plugin that adds a homepage edit link to the admin sidebar. 12 12 13 13 == Description == 14 14 15 This plugin adds a link to the edit screen of your homepage. The link is added in the admin sidebar underneath the default 'Pages' menu item. 15 Bored of hunting down the edit button for your homepage? 16 16 17 If you don't have a static homepage set, the link will not appear as there's no page to edit. 17 This plugin adds an 'Edit Homepage' link to the WP admin sidebar. The edit link can be found in the admin sidebar: 'Pages > Edit Homepage'. 18 19 If you don't have a homepage set, the link will simply not appear. 18 20 19 21 == Changelog == 20 22 23 = 1.1 = 24 * Adds edit/set homepage links in plugin list table. 25 * Adds image assets for plugin directory listing. 26 21 27 = 1.0 = 22 28 * Adds the homepage edit link to the admin sidebar. 29 30 == Screenshots == 31 1. Homepage edit link shown as Pages > Edit Homepage 32 2. Admin homepage settings on the Settings > Reading screen. -
wp-edit-homepage/trunk/wp-edit-homepage.php
r2354426 r2364265 7 7 * @wordpress-plugin 8 8 * Plugin Name: WP Edit Homepage 9 * Plugin URI: https://github.com/tommyferry/wp-edit-homepage 9 10 * Description: A simple WordPress plugin that adds a homepage edit link to the admin sidebar 10 * Version: 1. 011 * Version: 1.1 11 12 * Author: Tommy Ferry 12 13 * License: GPLv2 or later … … 34 35 } 35 36 37 if ( ! defined( 'WP_EDIT_HOMEPAGE_BASENAME' ) ) { 38 define( 'WP_EDIT_HOMEPAGE_BASENAME', plugin_basename( __FILE__ ) ); 39 } 40 36 41 require_once 'includes/class-wp-edit-homepage-plugin.php'; 37 42
Note: See TracChangeset
for help on using the changeset viewer.