Call in a script to hide elements on edit and add pages.
Add jquery calls to the change events for the page selector or url
field, so it selects the correct radio button.
Update label for the fields.
{
$this->pluginDirName = $path;
$jobs = new glm_models_block($path);
- add_action('admin_init', array($this, 'remove_elements'));
}
/**
$this->pluginDirName = $dir;
}
-
- /**
- * Hide certain elements from the normal post edit page.
- */
- function remove_elements()
- {
- if( isset($_GET['post']) && $_GET['post']
- || (isset($_GET['post_type']) && $_GET['post_type'] == GLM_BLOCK_POST_TYPE)
- ) {
- $post_type = (isset($_GET['post']))
- ? get_post_type($_GET['post'])
- : $_GET['post_type'];
- if($post_type == GLM_BLOCK_POST_TYPE) {
- echo '<style>
- #edit-slug-box, #postbox-container-2 .inside p {display:none;}
- #set-ngg-post-thumbnail {display: none;}
- </style>';
- }
- }
- }
-
}
<?php
/*
Plugin Name: GLM Blocks
-Version: 1.2.0
+Version: 1.2.1
Description: Displays blocks of content managed from the admin under Blocks.
Author: Steve Sutton <steve@gaslightmedia.com>
Author URI: http://www.gaslightmedia.com
--- /dev/null
+jQuery(function($){
+
+ $("#edit-slug-box").hide();
+ $("#set-ngg-post-thumbnail").hide();
+ $("#glm_block_page").change(function(){
+ if($("#glm_block_page").val()) {
+ $("input[name=glm_block_url]").filter('input[value=page]').attr('checked', true);
+ } else {
+ $("input[name=glm_block_url]").filter('input[value=page]').attr('checked', false);
+ }
+ });
+ $("#glm_block_ext_url").change(function(){
+ if($("#glm_block_ext_url").val()) {
+ $("input[name=glm_block_url]").filter('input[value=url]').attr('checked', true);
+ } else {
+ $("input[name=glm_block_url]").filter('input[value=url]').attr('checked', false);
+ }
+ });
+});
{
$this->pluginDirName = $path;
add_action('init', array($this, 'addPostTypes'));
+ add_action('admin_enqueue_scripts', array($this, 'load_admin_scripts'));
add_action('add_meta_boxes', array($this, 'addMetaBoxes'));
add_action('save_post', array($this, 'saveMetaBox'));
add_action('manage_edit-glm_blocks_columns', array($this, 'addOrderColumn'));
add_action('pre_get_posts', array($this, 'sortQuery'));
}
+ public function load_admin_scripts()
+ {
+ $current_screen = get_current_screen();
+ //var_dump($current_screen);
+
+ if ($current_screen->post_type == 'glm_blocks') {
+ wp_enqueue_script('jquery');
+ wp_enqueue_script(
+ 'glm_blocks_js',
+ plugins_url('../js/glm-blocks.js', __FILE__),
+ array('jquery')
+ );
+ }
+ }
+
/**
* sortQuery
*
{
add_meta_box(
'glm_blocks_url',
- __('URL', 'glm_blocks_textdomain'),
+ __('Destination', 'glm_blocks_textdomain'),
array($this, 'metaBoxCallBack'),
GLM_BLOCK_POST_TYPE,
'normal'
echo 'checked';
}; ?>>
<label>
-<?php echo _e('External URL', 'glm_blocks_textdomain'); ?>
+<?php echo _e('External URL (with http://)', 'glm_blocks_textdomain'); ?>
<input
type="text"
id="glm_block_ext_url"
<?php if ($glm_block_url == 'page') {
echo 'checked';
}; ?>>
-<label for="my_meta_box_post_type">Post type: </label>
+<label for="my_meta_box_post_type">Internal link: </label>
<?php
wp_dropdown_pages(
array(
)
);
?>
-</select>
\ No newline at end of file
+</select>