| 1 |
<?php |
| 2 |
/** |
| 3 |
* Administration Menu Options |
| 4 |
* |
| 5 |
* Add various adminstration menu options |
| 6 |
* |
| 7 |
* @package Artiss-Code-Embed |
| 8 |
*/ |
| 9 |
|
| 10 |
/** |
| 11 |
* Add Settings link to plugin list |
| 12 |
* |
| 13 |
* Add a Settings link to the options listed against this plugin |
| 14 |
* |
| 15 |
* @since 1.6 |
| 16 |
* |
| 17 |
* @param string $links Current links |
| 18 |
* @param string $file File in use |
| 19 |
* @return string Links, now with settings added |
| 20 |
*/ |
| 21 |
|
| 22 |
function ace_add_settings_link( $links, $file ) { |
| 23 |
|
| 24 |
static $this_plugin; |
| 25 |
|
| 26 |
if ( !$this_plugin ) { $this_plugin = plugin_basename( __FILE__ ); } |
| 27 |
|
| 28 |
if ( strpos( $file, 'code-embed.php' ) !== false ) { |
| 29 |
$settings_link = '<a href="admin.php?page=code-embed-options">' . __( 'Settings' ) . '</a>'; |
| 30 |
array_unshift( $links, $settings_link ); |
| 31 |
} |
| 32 |
|
| 33 |
return $links; |
| 34 |
} |
| 35 |
add_filter( 'plugin_action_links', 'ace_add_settings_link', 10, 2 ); |
| 36 |
|
| 37 |
/** |
| 38 |
* Add meta to plugin details |
| 39 |
* |
| 40 |
* Add options to plugin meta line |
| 41 |
* |
| 42 |
* @since 1.6 |
| 43 |
* |
| 44 |
* @param string $links Current links |
| 45 |
* @param string $file File in use |
| 46 |
* @return string Links, now with settings added |
| 47 |
*/ |
| 48 |
|
| 49 |
function ace_set_plugin_meta( $links, $file ) { |
| 50 |
|
| 51 |
if ( strpos( $file, 'code-embed.php' ) !== false ) { |
| 52 |
|
| 53 |
$links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/forum/specific-plugins-group2/artiss-code-embed-forum3">' . __( 'Support' ) . '</a>' ) ); |
| 54 |
$links = array_merge( $links, array( '<a href="http://www.artiss.co.uk/donate">' . __( 'Donate' ) . '</a>' ) ); |
| 55 |
} |
| 56 |
|
| 57 |
return $links; |
| 58 |
} |
| 59 |
add_filter( 'plugin_row_meta', 'ace_set_plugin_meta', 10, 2 ); |
| 60 |
|
| 61 |
/** |
| 62 |
* Code Embed Menu |
| 63 |
* |
| 64 |
* Add a new option to the Admin menu |
| 65 |
* |
| 66 |
* @since 1.4 |
| 67 |
* |
| 68 |
* @uses ace_help Return help text |
| 69 |
*/ |
| 70 |
|
| 71 |
function ace_menu() { |
| 72 |
|
| 73 |
$code_embed_hook = add_options_page( 'Artiss Code Embed Settings', 'Code Embed', 10, 'code-embed-options', 'ace_options' ); |
| 74 |
|
| 75 |
if ( function_exists( 'add_contextual_help' ) ) { |
| 76 |
add_contextual_help( $code_embed_hook, __( ace_options_help() ) ); |
| 77 |
} |
| 78 |
|
| 79 |
$code_embed_hook = add_submenu_page( 'tools.php', 'Code Embed Search', 'Code Embed Search', 10, 'code-embed-search', 'ace_search' ); |
| 80 |
|
| 81 |
if ( function_exists( 'add_contextual_help' ) ) { |
| 82 |
add_contextual_help( $code_embed_hook, __( ace_search_help() ) ); |
| 83 |
} |
| 84 |
|
| 85 |
} |
| 86 |
add_action( 'admin_menu','ace_menu' ); |
| 87 |
|
| 88 |
/** |
| 89 |
* Code Embed Options |
| 90 |
* |
| 91 |
* Define an option screen |
| 92 |
* |
| 93 |
* @since 1.4 |
| 94 |
*/ |
| 95 |
|
| 96 |
function ace_options() { |
| 97 |
|
| 98 |
include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . "code-embed-options.php" ); |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Code Embed Search |
| 104 |
* |
| 105 |
* Define a the search screen |
| 106 |
* |
| 107 |
* @since 1.6 |
| 108 |
*/ |
| 109 |
|
| 110 |
function ace_search() { |
| 111 |
|
| 112 |
include_once( WP_PLUGIN_DIR . '/' . str_replace( basename( __FILE__ ), '', plugin_basename( __FILE__ ) ) . "code-embed-search.php" ); |
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Code Embed Options Help |
| 118 |
* |
| 119 |
* Return help text for options screen |
| 120 |
* |
| 121 |
* @since 1.5 |
| 122 |
* |
| 123 |
* @return string Help Text |
| 124 |
*/ |
| 125 |
|
| 126 |
function ace_options_help() { |
| 127 |
|
| 128 |
$help_text = '<p><a href="http://www.artiss.co.uk/code-embed">Artiss Code Embed Plugin Documentation</a></p>'; |
| 129 |
$help_text .= '<p><a href="http://www.artiss.co.uk/forum/specific-plugins-group2/artiss-code-embed-forum3">Artiss Code Embed Support Forum</a></p>'; |
| 130 |
$help_text .= '<p>All of my plugins are supported via <a title="Artiss.co.uk" href="http://www.artiss.co.uk" target="_blank">my website</a>. Please feel free to visit the site for plugin updates and development news - either visit the site regularly, follow <a title="RSS News Feed" href="http://www.artiss.co.uk/feed" target="_blank">my news feed</a> or <a title="Artiss.co.uk on Twitter" href="http://www.twitter.com/artiss_tech" target="_blank">follow me on Twitter</a> (@artiss_tech).</p>'; |
| 131 |
$help_text .= '<h4>This plugin, and all support, is supplied for free, but <a title="Donate" href="http://artiss.co.uk/donate" target="_blank">donations</a> are always welcome.</h4>'; |
| 132 |
|
| 133 |
return $help_text; |
| 134 |
} |
| 135 |
|
| 136 |
/** |
| 137 |
* Code Embed Search Help |
| 138 |
* |
| 139 |
* Return help text for search screen |
| 140 |
* |
| 141 |
* @since 1.6 |
| 142 |
* |
| 143 |
* @return string Help Text |
| 144 |
*/ |
| 145 |
|
| 146 |
function ace_search_help() { |
| 147 |
|
| 148 |
$help_text = '<p>This screen allows you to search for the post and pages that a particular code embed has been used in.</p>'; |
| 149 |
$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.</p>'; |
| 150 |
$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 colour background.</p>'; |
| 151 |
|
| 152 |
return $help_text; |
| 153 |
} |
| 154 |
?> |