Created
December 20, 2018 10:18
-
-
Save NateWr/be978ed15a23863340a1fb694c422a51 to your computer and use it in GitHub Desktop.
Show the menu and menu item shortcodes in the admin lists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Show Shortcodes for Food and Drink Menu | |
* Plugin URI: http://themeofthecrop.com | |
* Description: Show the menu and menu item shortcodes in the admin lists. | |
* Version: 1.0 | |
* Author: Theme of the Crop | |
* Author URI: http://themeofthecrop.com | |
* License: GNU General Public License v2.0 or later | |
* License URI: http://www.gnu.org/licenses/gpl-2.0.html | |
* Requires at least: 4.0 | |
* Tested up to: 4.01 | |
* | |
* Text Domain: food-and-drink-menu | |
* Domain Path: /languages/ | |
* | |
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU | |
* General Public License as published by the Free Software Foundation; either version 2 of the License, | |
* or (at your option) any later version. | |
* | |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | |
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
* | |
* You should have received a copy of the GNU General Public License along with this program; if not, write | |
* to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
*/ | |
defined( 'ABSPATH' ) || exit; | |
add_filter( 'manage_fdm-menu_posts_columns', 'ssffdm_menu_columns', 100); | |
function ssffdm_menu_columns( $columns ) { | |
$columns['shortcode'] = __( 'Shortcode', 'food-and-drink-menu' ); | |
return $columns; | |
} | |
add_action( 'manage_fdm-menu_posts_custom_column', 'ssffdm_menu_columns_content', 100, 2 ); | |
function ssffdm_menu_columns_content( $column, $post ) { | |
if ( $column === 'shortcode' ) { | |
echo '[fdm-menu id=' . $post . ']'; | |
} | |
} | |
add_filter( 'manage_fdm-menu-item_posts_columns', 'ssffdm_menu_item_columns', 100); | |
function ssffdm_menu_item_columns( $columns ) { | |
$columns['shortcode'] = __( 'Shortcode', 'food-and-drink-menu' ); | |
return $columns; | |
} | |
add_action( 'manage_fdm-menu-item_posts_custom_column', 'ssffdm_menu_item_columns_content', 100, 2 ); | |
function ssffdm_menu_item_columns_content( $column, $post ) { | |
if ( $column === 'shortcode' ) { | |
echo '[fdm-menu-item id=' . $post . ']'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment