Skip to content

Instantly share code, notes, and snippets.

@alexknowshtml
Created March 24, 2014 20:02
Show Gist options
  • Save alexknowshtml/9747882 to your computer and use it in GitHub Desktop.
Save alexknowshtml/9747882 to your computer and use it in GitHub Desktop.
/*Barley Overrides*/
if ( !isset($_GET['barley_editor']) || $_GET['barley_editor'] !== 'on' )
$_GET['barley_editor'] = 'off';
remove_filter('edit_post_link', 'barley_custom_edit_post_link');
// Change "Edit" to "Edit Advanced Options" when template uses edit_post_link
function indyhall_barley_custom_edit_post_link($output) {
if ( is_single() || is_page() ) { // Only replace this link on single or pages
$output = str_replace('Edit', 'Edit Advanced Options', $output);
$barley_querystring_separator = (isset($_GET['p']) && $_GET['p']) ? '&' : '?';
if ( isset($_GET['barley_editor']) && $_GET['barley_editor'] == 'off' ) {
$output .= ' | <a href="'.get_permalink().$barley_querystring_separator.'barley_editor=on">' . __( 'Turn Barley Editor on', 'barley-for-wordpress' ) . '</a>';
} else {
$output .= ' | <a href="'.get_permalink().$barley_querystring_separator.'barley_editor=off">' . __( 'Turn Barley Editor off', 'barley-for-wordpress' ) . '</a>';
}
}
return $output;
}
add_filter('edit_post_link', 'indyhall_barley_custom_edit_post_link');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment