From: Steve Sutton Date: Thu, 23 Jul 2015 19:48:42 +0000 (-0400) Subject: Block updates for edit page X-Git-Tag: v1.2.1~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=453479ae90e3348749d40f7babf6a407d710095c;p=WP-Plugins%2Fglm-blocks.git Block updates for edit page 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. --- diff --git a/controllers/admin.php b/controllers/admin.php index f16304c..cf09a3c 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -19,7 +19,6 @@ class glm_blocks_admin { $this->pluginDirName = $path; $jobs = new glm_models_block($path); - add_action('admin_init', array($this, 'remove_elements')); } /** @@ -30,25 +29,4 @@ class glm_blocks_admin $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 ''; - } - } - } - } diff --git a/glm-blocks.php b/glm-blocks.php index dab2668..00bc25f 100644 --- a/glm-blocks.php +++ b/glm-blocks.php @@ -1,7 +1,7 @@ Author URI: http://www.gaslightmedia.com diff --git a/js/glm-blocks.js b/js/glm-blocks.js new file mode 100644 index 0000000..23392a6 --- /dev/null +++ b/js/glm-blocks.js @@ -0,0 +1,19 @@ +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); + } + }); +}); diff --git a/models/block.php b/models/block.php index efaebf3..e171f89 100644 --- a/models/block.php +++ b/models/block.php @@ -31,6 +31,7 @@ class glm_models_block { $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')); @@ -39,6 +40,21 @@ class glm_models_block 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 * @@ -107,7 +123,7 @@ class glm_models_block { add_meta_box( 'glm_blocks_url', - __('URL', 'glm_blocks_textdomain'), + __('Destination', 'glm_blocks_textdomain'), array($this, 'metaBoxCallBack'), GLM_BLOCK_POST_TYPE, 'normal' diff --git a/views/admin/metaBoxes.php b/views/admin/metaBoxes.php index 7ebce57..7631d4f 100644 --- a/views/admin/metaBoxes.php +++ b/views/admin/metaBoxes.php @@ -6,7 +6,7 @@ echo 'checked'; }; ?>>