| 1 |
<?php |
| 2 |
/** |
| 3 |
* Add screens |
| 4 |
* |
| 5 |
* Add settings and tools screens. |
| 6 |
* |
| 7 |
* @package simple-embed-code |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Code Embed Menu |
| 12 |
* |
| 13 |
* Add a new option to the Admin menu and context menu |
| 14 |
* |
| 15 |
* @uses ce_help Return help text |
| 16 |
*/ |
| 17 |
function ce_menu() { |
| 18 |
|
| 19 |
// Add search sub-menu. |
| 20 |
|
| 21 |
global $ce_search_hook; |
| 22 |
|
| 23 |
$ce_search_hook = add_submenu_page( 'tools.php', __( 'Code Embed Search', 'simple-embed-code' ), __( 'Code Search', 'simple-embed-code' ), 'edit_posts', 'ce-search', 'ce_search' ); |
| 24 |
|
| 25 |
add_action( 'load-' . $ce_search_hook, 'ce_add_search_help' ); |
| 26 |
|
| 27 |
// Add options sub-menu. |
| 28 |
|
| 29 |
global $ce_options_hook; |
| 30 |
|
| 31 |
$ce_options_hook = add_submenu_page( 'options-general.php', __( 'Code Embed Settings', 'simple-embed-code' ), __( 'Code Embed', 'simple-embed-code' ), 'manage_options', 'ce-options', 'ce_options' ); |
| 32 |
|
| 33 |
add_action( 'load-' . $ce_options_hook, 'ce_add_options_help' ); |
| 34 |
} |
| 35 |
|
| 36 |
add_action( 'admin_menu', 'ce_menu' ); |
| 37 |
|
| 38 |
/** |
| 39 |
* Add Options Help |
| 40 |
* |
| 41 |
* Add help tab to options screen |
| 42 |
* |
| 43 |
* @uses ce_options_help Return help text. |
| 44 |
*/ |
| 45 |
function ce_add_options_help() { |
| 46 |
|
| 47 |
global $ce_options_hook; |
| 48 |
$screen = get_current_screen(); |
| 49 |
|
| 50 |
if ( $screen->id !== $ce_options_hook ) { |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
$screen->add_help_tab( |
| 55 |
array( |
| 56 |
'id' => 'ce-options-help-tab', |
| 57 |
'title' => __( 'Help', 'simple-embed-code' ), |
| 58 |
'content' => ce_options_help(), |
| 59 |
) |
| 60 |
); |
| 61 |
|
| 62 |
$screen->set_help_sidebar( ce_help_sidebar() ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Add Search Help |
| 67 |
* |
| 68 |
* Add help tab to search screen |
| 69 |
* |
| 70 |
* @uses ce_search_help Return help text. |
| 71 |
*/ |
| 72 |
function ce_add_search_help() { |
| 73 |
|
| 74 |
global $ce_search_hook; |
| 75 |
$screen = get_current_screen(); |
| 76 |
|
| 77 |
if ( $screen->id !== $ce_search_hook ) { |
| 78 |
return; |
| 79 |
} |
| 80 |
|
| 81 |
$screen->add_help_tab( |
| 82 |
array( |
| 83 |
'id' => 'ce-search-help-tab', |
| 84 |
'title' => __( 'Help', 'simple-embed-code' ), |
| 85 |
'content' => ce_search_help(), |
| 86 |
) |
| 87 |
); |
| 88 |
|
| 89 |
$screen->set_help_sidebar( ce_help_sidebar() ); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Code Embed Options |
| 94 |
* |
| 95 |
* Define an option screen |
| 96 |
*/ |
| 97 |
function ce_options() { |
| 98 |
|
| 99 |
include_once WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'options-screen.php'; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Code Embed Search |
| 104 |
* |
| 105 |
* Define a the search screen |
| 106 |
*/ |
| 107 |
function ce_search() { |
| 108 |
|
| 109 |
include_once WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . 'search-screen.php'; |
| 110 |
} |
| 111 |
|
| 112 |
/** |
| 113 |
* Code Embed Options Help |
| 114 |
* |
| 115 |
* Return help text for options screen |
| 116 |
* |
| 117 |
* @return string Help Text. |
| 118 |
*/ |
| 119 |
function ce_options_help() { |
| 120 |
|
| 121 |
$help_text = '<p>' . __( 'Use this screen to modify the various settings, including the identifiers and keyword used to specify your embedded code.', 'simple-embed-code' ) . '</p>'; |
| 122 |
$help_text .= '<p>' . __( 'The first option allows to suppress debug output. Normally this is an HTML comment in your page source - if you wish to hide this then simply tick this option.', 'simple-embed-code' ) . '</p>'; |
| 123 |
$help_text .= '<p>' . __( 'The second option allows to specify whether code embed requests should work in excerpts.', 'simple-embed-code' ) . '</p>'; |
| 124 |
$help_text .= '<p>' . __( 'The keyword is the name used for your custom field. The custom field\'s value is the code that you wish to embed.', 'simple-embed-code' ) . '</p>'; |
| 125 |
$help_text .= '<p>' . __( 'The keyword, sandwiched with the identifier before and after, is what you then need to add to your post or page to activate the embed code.', 'simple-embed-code' ) . '</p>'; |
| 126 |
|
| 127 |
return $help_text; |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* Code Embed Search Help |
| 132 |
* |
| 133 |
* Return help text for search screen |
| 134 |
* |
| 135 |
* @return string Help Text |
| 136 |
*/ |
| 137 |
function ce_search_help() { |
| 138 |
|
| 139 |
$help_text = '<p>' . __( 'This screen allows you to search for the post and pages that a particular code embed has been used in.', 'simple-embed-code' ) . '</p>'; |
| 140 |
$help_text .= '<p>' . __( 'Simply enter the code suffix that you wish to search for and press the \'Search\' key to display a list of all the posts using it. In addition the code will be shown alongside it. Click on the post name to edit the post.', 'simple-embed-code' ) . '</p>'; |
| 141 |
$help_text .= '<p>' . __( 'The search results are grouped together in matching code groups, so posts with the same code will be shown together with the same color background.', 'simple-embed-code' ) . '</p>'; |
| 142 |
|
| 143 |
return $help_text; |
| 144 |
} |
| 145 |
|
| 146 |
/** |
| 147 |
* Code Embed Help Sidebar |
| 148 |
* |
| 149 |
* Return sidebar help text |
| 150 |
* |
| 151 |
* @return string Help Text. |
| 152 |
*/ |
| 153 |
function ce_help_sidebar() { |
| 154 |
|
| 155 |
$help_text = '<p><strong>' . __( 'For more information:', 'simple-embed-code' ) . '</strong></p>'; |
| 156 |
$help_text .= '<p><a href="https://wordpress.org/plugins/simple-embed-code/">' . __( 'Instructions', 'simple-embed-code' ) . '</a></p>'; |
| 157 |
$help_text .= '<p><a href="https://github.com/dartiss/code-embed">' . __( 'Github (code and issues)', 'simple-embed-code' ) . '</a></p>'; |
| 158 |
$help_text .= '<p><a href="https://wordpress.org/support/plugin/simple-embed-code">' . __( 'Support Forum', 'simple-embed-code' ) . '</a></p></h4>'; |
| 159 |
|
| 160 |
return $help_text; |
| 161 |
} |
| 162 |
|