/wp-content/plugins/custom-field-template/custom-field-template.php
PHP | 3707 lines | 3261 code | 384 blank | 62 comment | 1107 complexity | 1b0f46e2c32ebc583b19216d4c29888c MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- Plugin Name: Custom Field Template
- Plugin URI: http://wpgogo.com/development/custom-field-template.html
- Description: This plugin adds the default custom fields on the Write Post/Page.
- Author: Hiroaki Miyashita
- Version: 1.8.6
- Author URI: http://wpgogo.com/
- */
-
- /*
- This program is based on the rc:custom_field_gui plugin written by Joshua Sigar.
- I appreciate your efforts, Joshua.
- */
-
- /* Copyright 2008 -2011 Hiroaki Miyashita
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
- class custom_field_template {
- var $is_excerpt;
-
- function custom_field_template() {
- add_action( 'init', array(&$this, 'custom_field_template_init') );
- add_action( 'admin_menu', array(&$this, 'custom_field_template_admin_menu') );
- add_action( 'admin_print_scripts', array(&$this, 'custom_field_template_admin_scripts') );
- add_action( 'admin_head', array(&$this, 'custom_field_template_admin_head'), 100 );
-
- //add_action( 'edit_post', array(&$this, 'edit_meta_value'), 100 );
- add_action( 'save_post', array(&$this, 'edit_meta_value'), 100, 2 );
- //add_action( 'publish_post', array(&$this, 'edit_meta_value'), 100 );
-
- add_action( 'delete_post', array(&$this, 'custom_field_template_delete_post'), 100 );
-
- add_filter( 'media_send_to_editor', array(&$this, 'media_send_to_custom_field'), 15 );
- add_filter( 'plugin_action_links', array(&$this, 'wpaq_filter_plugin_actions'), 100, 2 );
-
- add_filter( 'get_the_excerpt', array(&$this, 'custom_field_template_get_the_excerpt'), 1 );
- add_filter( 'the_content', array(&$this, 'custom_field_template_the_content') );
- add_filter( 'the_content_rss', array(&$this, 'custom_field_template_the_content') );
-
- add_filter( 'attachment_fields_to_edit', array(&$this, 'custom_field_template_attachment_fields_to_edit'), 10, 2 );
-
- if ( isset($_REQUEST['cftsearch_submit']) ) :
- if ( !empty($_REQUEST['limit']) )
- add_action( 'post_limits', array(&$this, 'custom_field_template_post_limits'));
- add_filter( 'posts_join', array(&$this, 'custom_field_template_posts_join') );
- add_filter( 'posts_where', array(&$this, 'custom_field_template_posts_where'), 100 );
- add_filter( 'posts_orderby', array(&$this, 'custom_field_template_posts_orderby' ) );
- endif;
-
- if ( function_exists('add_shortcode') ) :
- add_shortcode( 'cft', array(&$this, 'output_custom_field_values') );
- add_shortcode( 'cftsearch', array(&$this, 'search_custom_field_values') );
- endif;
- }
-
- function custom_field_template_init() {
- global $wp_version;
- $options = $this->get_custom_field_template_data();
-
- if ( function_exists('load_plugin_textdomain') ) {
- if ( !defined('WP_PLUGIN_DIR') ) {
- load_plugin_textdomain('custom-field-template', str_replace( ABSPATH, '', dirname(__FILE__) ) );
- } else {
- load_plugin_textdomain('custom-field-template', false, dirname( plugin_basename(__FILE__) ) );
- }
- }
-
- if ( is_user_logged_in() && isset($_REQUEST['post']) && isset($_REQUEST['page']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' && $_REQUEST['cft_mode'] == 'selectbox' ) {
- echo $this->custom_field_template_selectbox();
- exit();
- }
-
- if ( is_user_logged_in() && isset($_REQUEST['post']) && isset($_REQUEST['page']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' && $_REQUEST['cft_mode'] == 'ajaxsave' ) {
- if ( $_REQUEST['post'] > 0 )
- $this->edit_meta_value( $_REQUEST['post'], '' );
- exit();
- }
-
- if ( is_user_logged_in() && isset($_REQUEST['page']) && $_REQUEST['page'] == 'custom-field-template/custom-field-template.php' && $_REQUEST['cft_mode'] == 'ajaxload') {
- if ( isset($_REQUEST['id']) ) :
- $id = $_REQUEST['id'];
- elseif ( isset($options['posts'][$_REQUEST['post']]) ) :
- $id = $options['posts'][$_REQUEST['post']];
- else :
- $filtered_cfts = $this->custom_field_template_filter();
- if ( count($filtered_cfts)>0 ) :
- $id = $filtered_cfts[0]['id'];
- else :
- $id = 0;
- endif;
- endif;
- list($body, $init_id) = $this->load_custom_field( $id );
- echo $body;
- exit();
- }
-
- if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/plugins.php') && ((isset($_GET['activate']) && $_GET['activate'] == 'true') || (isset($_GET['activate-multi']) && $_GET['activate-multi'] == 'true') ) ) {
- $options = $this->get_custom_field_template_data();
- if( !$options ) {
- $this->install_custom_field_template_data();
- $this->install_custom_field_template_css();
- }
- }
-
- if ( function_exists('current_user_can') && current_user_can('edit_plugins') ) :
- if ( isset($_POST['custom_field_template_export_options_submit']) ) :
- $filename = "cft".date('Ymd');
- header("Accept-Ranges: none");
- header("Content-Disposition: attachment; filename=$filename");
- header('Content-Type: application/octet-stream');
- echo maybe_serialize($options);
- exit();
- endif;
- endif;
-
- if ( !empty($options['custom_field_template_widget_shortcode']) )
- add_filter('widget_text', 'do_shortcode');
-
- if ( substr($wp_version, 0, 3) >= '2.7' ) {
- if ( empty($options['custom_field_template_disable_custom_field_column']) ) :
- add_action( 'manage_posts_custom_column', array(&$this, 'add_manage_posts_custom_column'), 10, 2 );
- add_filter( 'manage_posts_columns', array(&$this, 'add_manage_posts_columns') );
- add_action( 'manage_pages_custom_column', array(&$this, 'add_manage_posts_custom_column'), 10, 2 );
- add_filter( 'manage_pages_columns', array(&$this, 'add_manage_pages_columns') );
- endif;
- if ( empty($options['custom_field_template_disable_quick_edit']) )
- add_action( 'quick_edit_custom_box', array(&$this, 'add_quick_edit_custom_box'), 10, 2 );
- }
-
- if ( substr($wp_version, 0, 3) < '2.5' ) {
- add_action( 'simple_edit_form', array(&$this, 'insert_custom_field'), 1 );
- add_action( 'edit_form_advanced', array(&$this, 'insert_custom_field'), 1 );
- add_action( 'edit_page_form', array(&$this, 'insert_custom_field'), 1 );
- } else {
- require_once(ABSPATH . 'wp-admin/includes/template.php');
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'post', 'normal', 'core');
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), 'page', 'normal', 'core');
- if ( function_exists('remove_meta_box') && !empty($options['custom_field_template_disable_default_custom_fields']) ) :
- remove_meta_box('postcustom', 'post', 'normal');
- remove_meta_box('postcustom', 'page', 'normal');
- remove_meta_box('pagecustomdiv', 'page', 'normal');
- endif;
-
- if ( is_array($options['custom_fields']) ) :
- $custom_post_type = array();
- foreach($options['custom_fields'] as $key => $val ) :
- if ( isset($options['custom_fields'][$key]['custom_post_type']) ) :
- $tmp_custom_post_type = explode(',', $options['custom_fields'][$key]['custom_post_type']);
- $tmp_custom_post_type = array_filter( $tmp_custom_post_type );
- $tmp_custom_post_type = array_unique(array_filter(array_map('trim', $tmp_custom_post_type)));
- $custom_post_type = array_merge($custom_post_type, $tmp_custom_post_type);
- endif;
- endforeach;
- if ( isset($custom_post_type) && is_array($custom_post_type) ) :
- foreach( $custom_post_type as $val ) :
- if ( function_exists('remove_meta_box') && $options['custom_field_template_disable_default_custom_fields'] ) :
- remove_meta_box('postcustom', $val, 'normal');
- endif;
- add_meta_box('cftdiv', __('Custom Field Template', 'custom-field-template'), array(&$this, 'insert_custom_field'), $val, 'normal', 'core');
- if ( empty($options['custom_field_template_disable_custom_field_column']) ) :
- add_filter( 'manage_'.$val.'_posts_columns', array(&$this, 'add_manage_pages_columns') );
- endif;
- endforeach;
- endif;
- endif;
- }
-
- if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') ) :
- add_action('admin_head', array(&$this, 'custom_field_template_admin_head_buffer') );
- add_action('admin_footer', array(&$this, 'custom_field_template_admin_footer_buffer') );
- endif;
- }
-
- function custom_field_template_attachment_fields_to_edit($form_fields, $post) {
- $form_fields["custom_field_template"]["label"] = __('Media Picker', 'custom-field-template');
- $form_fields["custom_field_template"]["input"] = "html";
- $form_fields["custom_field_template"]["html"] = '<a href="javascript:void(0);" onclick="var win = window.dialogArguments || opener || parent || top;win.cft_use_this('.$post->ID.');return false;">'.__('Use this', 'custom-field-template').'</a>';
-
- return $form_fields;
- }
-
- function custom_field_template_add_enctype($buffer) {
- $buffer = preg_replace('/<form name="post"/', '<form enctype="multipart/form-data" name="post"', $buffer);
- return $buffer;
- }
-
- function custom_field_template_admin_head_buffer() {
- ob_start(array(&$this, 'custom_field_template_add_enctype'));
- }
-
- function custom_field_template_admin_footer_buffer() {
- ob_end_flush();
- }
-
- function has_meta( $postid ) {
- global $wpdb;
-
- return $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value, meta_id, post_id FROM $wpdb->postmeta WHERE post_id = %d ORDER BY meta_key,meta_id", $postid), ARRAY_A );
- }
-
- function get_post_meta($post_id, $key, $single = false) {
- if ( !$post_id || !$key )
- return '';
-
- $post_id = (int) $post_id;
-
- $meta_cache = wp_cache_get($post_id, 'cft_post_meta');
-
- if ( !$meta_cache ) {
- if ( $meta_list = $this->has_meta( $post_id ) ) {
- foreach ( (array) $meta_list as $metarow) {
- $mpid = (int) $metarow['post_id'];
- $mkey = $metarow['meta_key'];
- $mval = $metarow['meta_value'];
-
- if ( !isset($cache[$mpid]) || !is_array($cache[$mpid]) )
- $cache[$mpid] = array();
- if ( !isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey]) )
- $cache[$mpid][$mkey] = array();
-
- $cache[$mpid][$mkey][] = $mval;
- }
- }
-
- /*foreach ( (array) $ids as $id ) {
- if ( ! isset($cache[$id]) )
- $cache[$id] = array();
- }*/
-
- if ( !empty($cache) && is_array($cache) ) :
- foreach ( (array) array_keys($cache) as $post)
- wp_cache_set($post, $cache[$post], 'cft_post_meta');
-
- $meta_cache = wp_cache_get($post_id, 'cft_post_meta');
- endif;
- }
-
- if ( isset($meta_cache[$key]) ) {
- if ( $single ) {
- return maybe_unserialize( $meta_cache[$key][0] );
- } else {
- return array_map('maybe_unserialize', $meta_cache[$key]);
- }
- }
-
- return '';
- }
-
- function add_quick_edit_custom_box($column_name, $type) {
- if( $column_name == 'custom-fields' ) :
- global $wp_version;
- $options = $this->get_custom_field_template_data();
-
- if( $options == null)
- return;
-
- if ( !$options['css'] ) {
- $this->install_custom_field_template_css();
- $options = $this->get_custom_field_template_data();
- }
-
- $out .= '<fieldset style="clear:both;">' . "\n";
- $out .= '<div class="inline-edit-group">';
- $out .= '<style type="text/css">' . "\n" .
- '<!--' . "\n";
- $out .= $options['css'] . "\n";
- $out .= '-->' . "\n" .
- '</style>';
-
- if ( count($options['custom_fields'])>1 ) {
- $out .= '<select id="custom_field_template_select">';
- for ( $i=0; $i < count($options['custom_fields']); $i++ ) {
- if ( $i == $options['posts'][$_REQUEST['post']] ) {
- $out .= '<option value="' . $i . '" selected="selected">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
- } else
- $out .= '<option value="' . $i . '">' . stripcslashes($options['custom_fields'][$i]['title']) . '</option>';
- }
- $out .= '</select>';
- $out .= '<input type="button" class="button" value="' . __('Load', 'custom-field-template') . '" onclick="var post = jQuery(this).parent().parent().parent().parent().attr(\'id\').replace(\'edit-\',\'\'); var cftloading_select = function() {jQuery.ajax({type: \'GET\', url: \'?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&id=\'+jQuery(\'#custom_field_template_select\').val()+\'&post=\'+post, success: function(html) {jQuery(\'#cft\').html(html);}});};cftloading_select(post);" />';
- }
-
- $out .= '<input type="hidden" name="custom-field-template-verify-key" id="custom-field-template-verify-key" value="' . wp_create_nonce('custom-field-template') . '" />';
- $out .= '<div id="cft">';
- $out .= '</div>';
-
- $out .= '</div>' . "\n";
- $out .= '</fieldset>' . "\n";
-
- echo $out;
- endif;
- }
-
- function custom_field_template_admin_head() {
- global $wp_version;
- $options = $this->get_custom_field_template_data();
-
- if ( !defined('WP_PLUGIN_DIR') )
- $plugin_dir = str_replace( ABSPATH, '', dirname(__FILE__) );
- else
- $plugin_dir = dirname( plugin_basename(__FILE__) );
-
- echo '<link rel="stylesheet" type="text/css" href="' . wp_guess_url() . '/' . PLUGINDIR . '/' . $plugin_dir . '/js/datePicker.css" />'."\n";
-
- if ( !empty($options['custom_field_template_use_validation']) ) :
- ?>
- <script type="text/javascript">
- // <![CDATA[
- jQuery(document).ready(function() {
- jQuery("#post").validate();
- });
- //-->
- </script>
- <style type="text/css">
- <!--
- label.error { color:#FF0000; }
- -->
- </style>
-
- <?php
- endif;
-
- if ( substr($wp_version, 0, 3) >= '2.7' && is_user_logged_in() && ( strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php') ) && !strstr($_SERVER['REQUEST_URI'], 'page=') ) {
- ?>
- <script type="text/javascript">
- // <![CDATA[
- jQuery(document).ready(function() {
- jQuery('.hide-if-no-js-cft').show();
- jQuery('.hide-if-js-cft').hide();
-
- inlineEditPost.addEvents = function(r) {
- r.each(function() {
- var row = jQuery(this);
- jQuery('a.editinline', row).click(function() {
- inlineEditPost.edit(this);
- post_id = jQuery(this).parent().parent().parent().parent().attr('id').replace('post-','');
- inlineEditPost.cft_load(post_id);
- return false;
- });
- });
- }
-
- inlineEditPost.save = function(id) {
- if( typeof(id) == 'object' )
- id = this.getId(id);
-
- jQuery('table.widefat .inline-edit-save .waiting').show();
-
- var params = {
- action: 'inline-save',
- post_type: <?php if ( substr($wp_version, 0, 3) >= '3.0' ) echo 'typenow'; else echo 'this.type'; ?>,
- post_ID: id,
- edit_date: 'true'
- };
-
- var fields = jQuery('#edit-'+id+' :input').fieldSerialize();
- params = fields + '&' + jQuery.param(params);
-
- // make ajax request
- jQuery.post('admin-ajax.php', params,
- function(r) {
- jQuery('table.widefat .inline-edit-save .waiting').hide();
-
- if (r) {
- if ( -1 != r.indexOf('<tr') ) {
- jQuery(inlineEditPost.what+id).remove();
- jQuery('#edit-'+id).before(r).remove();
-
- var row = jQuery(inlineEditPost.what+id);
- row.hide();
-
- if ( 'draft' == jQuery('input[name="post_status"]').val() )
- row.find('td.column-comments').hide();
-
- row.find('.hide-if-no-js').removeClass('hide-if-no-js');
- jQuery('.hide-if-no-js-cft').show();
- jQuery('.hide-if-js-cft').hide();
-
- inlineEditPost.addEvents(row);
- row.fadeIn();
- } else {
- r = r.replace( /<.[^<>]*?>/g, '' );
- jQuery('#edit-'+id+' .inline-edit-save').append('<span class="error">'+r+'</span>');
- }
- } else {
- jQuery('#edit-'+id+' .inline-edit-save').append('<span class="error">'+inlineEditL10n.error+'</span>');
- }
- }
- , 'html');
- return false;
- }
-
- jQuery('.editinline').click(function () {post_id = jQuery(this).parent().parent().parent().parent().attr('id').replace('post-',''); inlineEditPost.cft_load(post_id);});
- inlineEditPost.cft_load = function (post_id) {
- jQuery.ajax({type: 'GET', url: '?page=custom-field-template/custom-field-template.php&cft_mode=ajaxload&post='+post_id, success: function(html) {jQuery('#cft').html(html);}});
- };
- });
- //-->
- </script>
- <style type="text/css">
- <!--
- div.cft_list p.key { font-weight:bold; margin: 0; }
- div.cft_list p.value { margin: 0 0 0 10px; }
- .cft-actions { visibility: hidden; padding: 2px 0 0; }
- tr:hover .cft-actions { visibility: visible; }
- .inline-edit-row fieldset label { display:inline; }
- label.error { color:#FF0000; }
- -->
- </style>
- <?php
- }
- }
-
- function add_manage_posts_custom_column($column_name, $post_id) {
- $data = get_post_custom($post_id);
-
- if( is_array($data) && $column_name == 'custom-fields' ) :
- $flag = 0;
- foreach($data as $key => $val) :
- if ( substr($key, 0, 1) == '_' || !$val[0] ) continue;
- $content .= '<p class="key">' . $key . '</p>' . "\n";
- foreach($val as $val2) :
- $val2 = htmlspecialchars($val2, ENT_QUOTES);
- if ( $flag ) :
- $content .= '<p class="value">' . $val2 . '</p>' . "\n";
- else :
- if ( function_exists( mb_strlen ) ) :
- if ( mb_strlen($val2) > 50 ) :
- $before_content = mb_substr($val2, 0, 50);
- $after_content = mb_substr($val2, 50);
- $content .= '<p class="value">' . $before_content . '[[[break]]]' . '<p class="value">' . $after_content . '</p>' . "\n";
- $flag = 1;
- else :
- $content .= '<p class="value">' . $val2 . '</p>' . "\n";
- endif;
- else :
- if ( strlen($val2) > 50 ) :
- $before_content = substr($val2, 0, 50);
- $after_content = substr($val2, 50);
- $content .= '<p class="value">' . $before_content . '[[[break]]]' . '<p class="value">' . $after_content . '</p>' . "\n";
- $flag = 1;
- else :
- $content .= '<p class="value">' . $val2 . '</p>' . "\n";
- endif;
- endif;
- endif;
- endforeach;
- endforeach;
- if ( $content ) :
- $content = preg_replace('/([^\n]+)\n([^\n]+)\n([^\n]+)\n([^\n]+)\n([^$]+)/', '\1\2\3\4[[[break]]]\5', $content);
- list($before, $after) = explode('[[[break]]]', $content, 2);
- $after = preg_replace('/\[\[\[break\]\]\]/', '', $after);
- $output .= '<div class="cft_list">';
- $output .= balanceTags($before, true);
- if ( $after ) :
- $output .= '<span class="hide-if-no-js-cft"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().show(); jQuery(this).parent().next().next().show(); jQuery(this).parent().hide();">... ' . __('read more', 'custom-field-template') . '</a></span>';
- $output .= '<span class="hide-if-js-cft">' . balanceTags($after, true) . '</span>';
- $output .= '<span style="display:none;"><a href="javascript:void(0);" onclick="jQuery(this).parent().prev().hide(); jQuery(this).parent().prev().prev().show(); jQuery(this).parent().hide();">[^]</a></span>';
- endif;
- $output .= '</div>';
- else :
- $output .= ' ';
- endif;
- endif;
-
- echo $output;
- }
-
- function add_manage_posts_columns($columns) {
- $new_columns = array();
- foreach($columns as $key => $val) :
- $new_columns[$key] = $val;
- if ( $key == 'tags' )
- $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
- endforeach;
- return $new_columns;
- }
-
- function add_manage_pages_columns($columns) {
- $new_columns = array();
- foreach($columns as $key => $val) :
- $new_columns[$key] = $val;
- if ( $key == 'author' )
- $new_columns['custom-fields'] = __('Custom Fields', 'custom-field-template');
- endforeach;
- return $new_columns;
- }
-
- function media_send_to_custom_field($html) {
- $out = '<script type="text/javascript">' . "\n" .
- ' /* <![CDATA[ */' . "\n" .
- ' var win = window.dialogArguments || opener || parent || top;' . "\n" .
- ' if ( typeof win.send_to_custom_field == "function" ) ' . "\n" .
- ' win.send_to_custom_field("' . addslashes($html) . '");' . "\n" .
- ' else ' . "\n" .
- ' win.send_to_editor("' . addslashes($html) . '");' . "\n" .
- '/* ]]> */' . "\n" .
- '</script>' . "\n";
-
- echo $out;
- exit();
-
- /*if ($options['custom_field_template_use_multiple_insert']) {
- return;
- } else {
- exit();
- }*/
- }
-
- function wpaq_filter_plugin_actions($links, $file){
- static $this_plugin;
-
- if( ! $this_plugin ) $this_plugin = plugin_basename(__FILE__);
-
- if( $file == $this_plugin ){
- $settings_link = '<a href="options-general.php?page=custom-field-template.php">' . __('Settings') . '</a>';
- $links = array_merge( array($settings_link), $links);
- }
- return $links;
- }
-
- function custom_field_template_admin_scripts() {
- global $post;
- $options = $this->get_custom_field_template_data();
-
- if ( !defined('WP_PLUGIN_DIR') )
- $plugin_dir = str_replace( ABSPATH, '', dirname(__FILE__) );
- else
- $plugin_dir = dirname( plugin_basename(__FILE__) );
-
- wp_enqueue_script( 'jquery' );
- wp_enqueue_script( 'jquery-form' );
- wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') );
- wp_enqueue_script( 'bgiframe', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.bgiframe.js', array('jquery') ) ;
- wp_enqueue_script( 'datePicker', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.datePicker.js', array('jquery') );
- wp_enqueue_script( 'textarearesizer', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.textarearesizer.js', array('jquery') );
- if( strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || (is_object($post) && $post->post_type=='page') ) :
- wp_enqueue_script( 'editor' );
- endif;
-
- if ( !empty($options['custom_field_template_use_validation']) ) :
- wp_enqueue_script( 'jquery-validate', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/jquery.validate.js', array('jquery') );
- wp_enqueue_script( 'additiona-methods', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/additiona-methods.js', array('jquery') );
- if ( file_exists(ABSPATH . PLUGINDIR . '/' . $plugin_dir . '/js/messages_' . WPLANG . '.js') )
- wp_enqueue_script( 'messages_' . WPLANG, '/' . PLUGINDIR . '/' . $plugin_dir . '/js/messages_' . WPLANG .'.js', array('jquery') );
- endif;
- }
-
- function install_custom_field_template_data() {
- $options['custom_field_template_before_list'] = '<ul>';
- $options['custom_field_template_after_list'] = '</ul>';
- $options['custom_field_template_before_value'] = '<li>';
- $options['custom_field_template_after_value'] = '</li>';
- $options['custom_fields'][0]['title'] = __('Default Template', 'custom-field-template');
- $options['custom_fields'][0]['content'] = '[Plan]
- type = text
- size = 35
- label = Where are you going to go?
-
- [Plan]
- type = textfield
- size = 35
- hideKey = true
-
- [Favorite Fruits]
- type = checkbox
- value = apple # orange # banana # grape
- default = orange # grape
-
- [Miles Walked]
- type = radio
- value = 0-9 # 10-19 # 20+
- default = 10-19
- clearButton = true
-
- [Temper Level]
- type = select
- value = High # Medium # Low
- default = Low
-
- [Hidden Thought]
- type = textarea
- rows = 4
- cols = 40
- tinyMCE = true
- htmlEditor = true
- mediaButton = true
-
- [File Upload]
- type = file';
- $options['shortcode_format'][0] = '<table class="cft">
- <tbody>
- <tr>
- <th>Plan</th><td colspan="3">[Plan]</td>
- </tr>
- <tr>
- <th>Favorite Fruits</th><td>[Favorite Fruits]</td>
- <th>Miles Walked</th><td>[Miles Walked]</td>
- </tr>
- <tr>
- <th>Temper Level</th><td colspan="3">[Temper Level]</td>
- </tr>
- <tr>
- <th>Hidden Thought</th><td colspan="3">[Hidden Thought]</td>
- </tr>
- </tbody>
- </table>';
- update_option('custom_field_template_data', $options);
- }
-
- function install_custom_field_template_css() {
- $options = get_option('custom_field_template_data');
- $options['css'] = '#cft dl { margin:10px 0; }
- #cft dl:after { content:" "; clear:both; height:0; display:block; visibility:hidden; }
- #cft dt { width:20%; clear:both; float:left; display:inline; font-weight:bold; text-align:center; }
- #cft dt .hideKey { visibility:hidden; }
- #cft dd { margin:0 0 0 21%; }
- #cft dd p.label { font-weight:bold; margin:0; }
- #cft_instruction { margin:10px; }
- #cft fieldset { border:1px solid #CCC; margin:5px; padding:5px; }
- #cft .mceStatusbar { padding-bottom:22px; }
- #cft .dl_checkbox { margin:0; }
- ';
- update_option('custom_field_template_data', $options);
- }
-
-
- function get_custom_field_template_data() {
- $options = get_option('custom_field_template_data');
- return $options;
- }
-
- function custom_field_template_admin_menu() {
- add_options_page(__('Custom Field Template', 'custom-field-template'), __('Custom Field Template', 'custom-field-template'), 'manage_options', basename(__FILE__), array(&$this, 'custom_field_template_admin'));
- }
-
-
- function custom_field_template_get_the_excerpt($excerpt) {
- $options = $this->get_custom_field_template_data();
-
- if ( empty($excerpt) ) $this->is_excerpt = true;
- if ( !empty($options['custom_field_template_excerpt_shortcode']) ) return do_shortcode($excerpt);
- else return $excerpt;
- }
-
- function custom_field_template_the_content($content) {
- global $wp_query, $post, $shortcode_tags, $wp_version;
- $options = $this->get_custom_field_template_data();
-
- if ( $this->is_excerpt ) :
- $this->is_excerpt = false;
-
- return $post->post_excerpt ? $post->post_excerpt : strip_shortcodes($content);
- endif;
-
- if ( isset($options['hook']) && count($options['hook']) > 0 ) :
- $categories = get_the_category();
- $cats = array();
- foreach( $categories as $val ) :
- $cats[] = $val->cat_ID;
- endforeach;
-
- if ( !empty($options['custom_fields'][$id]['post_type']) ) :
- if ( substr($wp_version, 0, 3) < '3.0' ) :
- if ( $options['custom_fields'][$id]['post_type'] == 'post' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/page-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/page.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit-pages.php')) ) :
- return;
- endif;
- if ( $options['custom_fields'][$id]['post_type'] == 'page' && (strstr($_SERVER['REQUEST_URI'], 'wp-admin/post-new.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') || strstr($_SERVER['REQUEST_URI'], 'wp-admin/edit.php')) ) :
- return;
- endif;
- else :
- if ( $post->post_type!=$options['custom_fields'][$id]['post_type'] ) :
- return;
- endif;
- endif;
- endif;
-
- for ( $i=0; $i<count($options['hook']); $i++ ) :
- $options['hook'][$i]['content'] = stripslashes($options['hook'][$i]['content']);
- if ( is_feed() && !$options['hook'][$i]['feed'] ) break;
- if ( !empty($options['hook'][$i]['category']) ) :
- if ( is_category() || is_single() || is_feed() ) :
- if ( $options['hook'][$i]['use_php'] ) :
- $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
- endif;
- $needle = explode(',', $options['hook'][$i]['category']);
- $needle = array_filter($needle);
- $needle = array_unique(array_filter(array_map('trim', $needle)));
- foreach ( $needle as $val ) :
- if ( in_array($val, $cats ) ) :
- if ( $options['hook'][$i]['position'] == 0 )
- $content .= $options['hook'][$i]['content'];
- elseif ( $options['hook'][$i]['position'] == 2 )
- $content = preg_replace('/\[cfthook hook='.$i.'\]/', $options['hook'][$i]['content'], $content);
- else
- $content = $options['hook'][$i]['content'] . $content;
- break;
- endif;
- endforeach;
- endif;
- elseif ( $options['hook'][$i]['post_type']=='post' ) :
- if ( is_category() || is_single() ) :
- if ( $options['hook'][$i]['use_php'] ) :
- $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
- endif;
- if ( $options['hook'][$i]['position'] == 0 )
- $content .= $options['hook'][$i]['content'];
- elseif ( $options['hook'][$i]['position'] == 2 )
- $content = preg_replace('/\[cfthook hook='.$i.'\]/', $options['hook'][$i]['content'], $content);
- else
- $content = $options['hook'][$i]['content'] . $content;
- endif;
- elseif ( $options['hook'][$i]['post_type']=='page' ) :
- if ( is_page() ) :
- if ( $options['hook'][$i]['use_php'] ) :
- $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
- endif;
- if ( $options['hook'][$i]['position'] == 0 )
- $content .= $options['hook'][$i]['content'];
- elseif ( $options['hook'][$i]['position'] == 2 )
- $content = preg_replace('/\[cfthook hook='.$i.'\]/', $options['hook'][$i]['content'], $content);
- else
- $content = $options['hook'][$i]['content'] . $content;
- endif;
- elseif ( $options['hook'][$i]['custom_post_type'] ) :
- $custom_post_type = explode(',', $options['hook'][$i]['custom_post_type']);
- $custom_post_type = array_filter( $custom_post_type );
- array_walk( $custom_post_type, create_function('&$v', '$v = trim($v);') );
- if ( in_array($post->post_type, $custom_post_type) ) :
- if ( $options['hook'][$i]['use_php'] ) :
- $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
- endif;
- if ( $options['hook'][$i]['position'] == 0 )
- $content .= $options['hook'][$i]['content'];
- elseif ( $options['hook'][$i]['position'] == 2 )
- $content = preg_replace('/\[cfthook hook='.$i.'\]/', $options['hook'][$i]['content'], $content);
- else
- $content = $options['hook'][$i]['content'] . $content;
- endif;
- else :
- if ( $options['hook'][$i]['use_php'] ) :
- $options['hook'][$i]['content'] = $this->EvalBuffer(stripcslashes($options['hook'][$i]['content']));
- endif;
- if ( $options['hook'][$i]['position'] == 0 )
- $content .= $options['hook'][$i]['content'];
- elseif ( $options['hook'][$i]['position'] == 2 )
- $content = preg_replace('/\[cfthook hook='.$i.'\]/', $options['hook'][$i]['content'], $content);
- else
- $content = $options['hook'][$i]['content'] . $content;
- endif;
- endfor;
- endif;
-
- return do_shortcode($content);
- }
-
- function custom_field_template_admin() {
- global $wp_version;
-
- $options = $this->get_custom_field_template_data();
-
- if( !empty($_POST["custom_field_template_set_options_submit"]) ) :
- unset($options['custom_fields']);
- $j = 0;
- for($i=0;$i<count($_POST["custom_field_template_content"]);$i++) {
- if( $_POST["custom_field_template_content"][$i] ) {
- if ( preg_match('/\[content\]|\[post_title\]|\[excerpt\]|\[action\]/i', $_POST["custom_field_template_content"][$i]) ) :
- $errormessage = __('You can not use the following words as the field key: `content`, `post_title`, and `excerpt`, and `action`.', 'custom-field-template');
- endif;
- if ( isset($_POST["custom_field_template_title"][$i]) ) $options['custom_fields'][$j]['title'] = $_POST["custom_field_template_title"][$i];
- if ( isset($_POST["custom_field_template_content"][$i]) ) $options['custom_fields'][$j]['content'] = $_POST["custom_field_template_content"][$i];
- if ( isset($_POST["custom_field_template_instruction"][$i]) ) $options['custom_fields'][$j]['instruction'] = $_POST["custom_field_template_instruction"][$i];
- if ( isset($_POST["custom_field_template_category"][$i]) ) $options['custom_fields'][$j]['category'] = $_POST["custom_field_template_category"][$i];
- if ( isset($_POST["custom_field_template_post"][$i]) ) $options['custom_fields'][$j]['post'] = $_POST["custom_field_template_post"][$i];
- if ( isset($_POST["custom_field_template_post_type"][$i]) ) $options['custom_fields'][$j]['post_type'] = $_POST["custom_field_template_post_type"][$i];
- if ( isset($_POST["custom_field_template_custom_post_type"][$i]) ) $options['custom_fields'][$j]['custom_post_type'] = $_POST["custom_field_template_custom_post_type"][$i];
- if ( isset($_POST["custom_field_template_template_files"][$i]) ) $options['custom_fields'][$j]['template_files'] = $_POST["custom_field_template_template_files"][$i];
- if ( isset($_POST["custom_field_template_disable"][$i]) ) $options['custom_fields'][$j]['disable'] = $_POST["custom_field_template_disable"][$i];
- $j++;
- }
- }
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif( !empty($_POST["custom_field_template_global_settings_submit"]) ) :
- $options['custom_field_template_replace_keys_by_labels'] = isset($_POST['custom_field_template_replace_keys_by_labels']) ? 1 : '';
- $options['custom_field_template_use_multiple_insert'] = isset($_POST['custom_field_template_use_multiple_insert']) ? 1 : '';
- $options['custom_field_template_use_wpautop'] = isset($_POST['custom_field_template_use_wpautop']) ? 1 : '';
- $options['custom_field_template_use_autosave'] = isset($_POST['custom_field_template_use_autosave']) ? 1 : '';
- $options['custom_field_template_use_disable_button'] = isset($_POST['custom_field_template_use_disable_button']) ? 1 : '';
- $options['custom_field_template_disable_initialize_button'] = isset($_POST['custom_field_template_disable_initialize_button']) ? 1 : '';
- $options['custom_field_template_disable_save_button'] = isset($_POST['custom_field_template_disable_save_button']) ? 1 : '';
- $options['custom_field_template_disable_default_custom_fields'] = isset($_POST['custom_field_template_disable_default_custom_fields']) ? 1 : '';
- $options['custom_field_template_disable_quick_edit'] = isset($_POST['custom_field_template_disable_quick_edit']) ? 1 : '';
- $options['custom_field_template_disable_custom_field_column'] = isset($_POST['custom_field_template_disable_custom_field_column']) ? 1 : '';
- $options['custom_field_template_replace_the_title'] = isset($_POST['custom_field_template_replace_the_title']) ? 1 : '';
- $options['custom_field_template_widget_shortcode'] = isset($_POST['custom_field_template_widget_shortcode']) ? 1 : '';
- $options['custom_field_template_excerpt_shortcode'] = isset($_POST['custom_field_template_excerpt_shortcode']) ? 1 : '';
- $options['custom_field_template_use_validation'] = isset($_POST['custom_field_template_use_validation']) ? 1 : '';
- $options['custom_field_template_before_list'] = isset($_POST['custom_field_template_before_list']) ? $_POST['custom_field_template_before_list'] : '';
- $options['custom_field_template_after_list'] = isset($_POST['custom_field_template_after_list']) ? $_POST['custom_field_template_after_list'] : '';
- $options['custom_field_template_before_value'] = isset($_POST['custom_field_template_before_value']) ? $_POST['custom_field_template_before_value'] : '';
- $options['custom_field_template_after_value'] = isset($_POST['custom_field_template_after_value']) ? $_POST['custom_field_template_after_value'] : '';
- $options['custom_field_template_replace_keys_by_labels'] = isset($_POST['custom_field_template_replace_keys_by_labels']) ? 1 : '';
- $options['custom_field_template_replace_keys_by_labels'] = isset($_POST['custom_field_template_replace_keys_by_labels']) ? 1 : '';
- $options['custom_field_template_replace_keys_by_labels'] = isset($_POST['custom_field_template_replace_keys_by_labels']) ? 1 : '';
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_css_submit']) ) :
- $options['css'] = $_POST['custom_field_template_css'];
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_shortcode_format_submit']) ) :
- unset($options['shortcode_format'], $options['shortcode_format_use_php']);
- $j = 0;
- for($i=0;$i<count($_POST["custom_field_template_shortcode_format"]);$i++) {
- if( $_POST["custom_field_template_shortcode_format"][$i] ) :
- $options['shortcode_format'][$j] = $_POST["custom_field_template_shortcode_format"][$i];
- $options['shortcode_format_use_php'][$j] = $_POST["custom_field_template_shortcode_format_use_php"][$i];
- $j++;
- endif;
- }
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_php_submit']) ) :
- unset($options['php']);
- for($i=0;$i<count($_POST["custom_field_template_php"]);$i++) {
- if( $_POST["custom_field_template_php"][$i] )
- $options['php'][] = $_POST["custom_field_template_php"][$i];
- }
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif( !empty($_POST["custom_field_template_hook_submit"]) ) :
- unset($options['hook']);
- $j = 0;
- for($i=0;$i<count($_POST["custom_field_template_hook_content"]);$i++) {
- if( $_POST["custom_field_template_hook_content"][$i] ) {
- $options['hook'][$j]['position'] = $_POST["custom_field_template_hook_position"][$i];
- $options['hook'][$j]['content'] = $_POST["custom_field_template_hook_content"][$i];
- $options['hook'][$j]['custom_post_type'] = preg_replace('/\s/', '', $_POST["custom_field_template_hook_custom_post_type"][$i]);
- $options['hook'][$j]['category'] = preg_replace('/\s/', '', $_POST["custom_field_template_hook_category"][$i]);
- $options['hook'][$j]['use_php'] = $_POST["custom_field_template_hook_use_php"][$i];
- $options['hook'][$j]['feed'] = $_POST["custom_field_template_hook_feed"][$i];
- $options['hook'][$j]['post_type'] = $_POST["custom_field_template_hook_post_type"][$i];
- $j++;
- }
- }
- update_option('custom_field_template_data', $options);
- $message = __('Options updated.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_rebuild_value_counts_submit']) ) :
- $this->custom_field_template_rebuild_value_counts();
- $options = $this->get_custom_field_template_data();
- $message = __('Value Counts rebuilt.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_rebuild_tags_submit']) ) :
- $options = $this->get_custom_field_template_data();
- $message = __('Tags rebuilt.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_import_options_submit']) ) :
- if ( is_uploaded_file($_FILES['cftfile']['tmp_name']) ) :
- ob_start();
- readfile ($_FILES['cftfile']['tmp_name']);
- $import = ob_get_contents();
- ob_end_clean();
- $import = maybe_unserialize($import);
- update_option('custom_field_template_data', $import);
- $message = __('Options imported.', 'custom-field-template');
- $options = $this->get_custom_field_template_data();
- endif;
- elseif ( !empty($_POST['custom_field_template_reset_options_submit']) ) :
- $this->install_custom_field_template_data();
- $this->install_custom_field_template_css();
- $options = $this->get_custom_field_template_data();
- $message = __('Options resetted.', 'custom-field-template');
- elseif ( !empty($_POST['custom_field_template_delete_options_submit']) ) :
- delete_option('custom_field_template_data');
- $options = $this->get_custom_field_template_data();
- $message = __('Options deleted.', 'custom-field-template');
- endif;
-
- if ( !defined('WP_PLUGIN_DIR') )
- $plugin_dir = str_replace( ABSPATH, '', dirname(__FILE__) );
- else
- $plugin_dir = dirname( plugin_basename(__FILE__) );
- ?>
- <style type="text/css">
- div.grippie {
- background:#EEEEEE url(<?php echo '../' . PLUGINDIR . '/' . $plugin_dir . '/js/'; ?>grippie.png) no-repeat scroll center 2px;
- border-color:#DDDDDD;
- border-style:solid;
- border-width:0pt 1px 1px;
- cursor:s-resize;
- height:9px;
- overflow:hidden;
- }
- .resizable-textarea textarea {
- display:block;
- margin-bottom:0pt;
- }
- </style>
- <script type="text/javascript">
- jQuery(document).ready(function() {
- jQuery('textarea.resizable:not(.processed)').TextAreaResizer();
- });
- </script>
- <?php if ( !empty($message) ) : ?>
- <div id="message" class="updated"><p><?php echo $message; ?></p></div>
- <?php endif; ?>
- <?php if ( !empty($errormessage) ) : ?>
- <div id="errormessage" class="error"><p><?php echo $errormessage; ?></p></div>
- <?php endif; ?>
- <div class="wrap">
- <div id="icon-plugins" class="icon32"><br/></div>
- <h2><?php _e('Custom Field Template', 'custom-field-template'); ?></h2>
-
- <br class="clear"/>
-
- <div id="poststuff" class="meta-box-sortables" style="position: relative; margin-top:10px;">
- <div class="postbox">
- <div class="handlediv" title="<?php _e('Click to toggle', 'custom-field-template'); ?>"><br /></div>
- <h3><?php _e('Custom Field Template Options', 'custom-field-template'); ?></h3>
- <div class="inside">
- <form method="post">
- <table class="form-table" style="margin-bottom:5px;">
- <tbody>
- <?php
- for ( $i = 0; $i < count($options['custom_fields'])+1; $i++ ) {
- ?>
- <tr><td>
- <p><strong>TEMPLATE #<?php echo $i; ?></strong>
- <label for="custom_field_template_disable[<?php echo $i; ?>]"><input type="checkbox" name="custom_field_template_disable[<?php echo $i; ?>]" id="custom_field_template_disable[<?php echo $i; ?>]" value="1" <?php if ( isset($options['custom_fields'][$i]['disable']) ) checked(1, $options['custom_fields'][$i]['disable']); ?> /> <?php _e('Disable', 'custom-field-template'); ?></label>
- </p>
- <p><label for="custom_field_template_title[<?php echo $i; ?>]"><?php echo sprintf(__('Template Title', 'custom-field-template'), $i); ?></label>:<br />
- <input type="text" name="custom_field_template_title[<?php echo $i; ?>]" id="custom_field_template_title[<?php echo $i; ?>]" value="<?php if ( isset($options['custom_fields'][$i]['title']) ) echo esc_attr(stripcslashes($options['custom_fields'][$i]['title'])); ?>" size="80" /></p>
- <p><label for="custom_field_template_instruction[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Template Instruction', 'custom-field-template'), $i); ?></a></label>:<br />
- <textarea class="large-text" name="custom_field_template_instruction[<?php echo $i; ?>]" id="custom_field_template_instruction[<?php echo $i; ?>]" rows="5" cols="80"<?php if ( empty($options['custom_fields'][$i]['instruction']) ) : echo ' style="display:none;"'; endif; ?>><?php if ( isset($options['custom_fields'][$i]['instruction']) ) echo stripcslashes($options['custom_fields'][$i]['instruction']); ?></textarea></p>
- <p><label for="custom_field_template_post_type[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Post Type', 'custom-field-template'), $i); ?></a></label>:<br />
- <span<?php if ( empty($options['custom_fields'][$i]['post_type']) ) : echo ' style="display:none;"'; endif; ?>>
- <input type="radio" name="custom_field_template_post_type[<?php echo $i; ?>]" id="custom_field_template_post_type[<?php echo $i; ?>]" value=""<?php if ( !isset($options['custom_fields'][$i]['post_type']) ) : echo ' checked="checked"'; endif; ?> /> <?php _e('Both', 'custom-field-template'); ?>
- <input type="radio" name="custom_field_template_post_type[<?php echo $i; ?>]" id="custom_field_template_post_type[<?php echo $i; ?>]" value="post"<?php if ( !empty($options['custom_fields'][$i]['post_type']) && $options['custom_fields'][$i]['post_type']=='post') : echo ' checked="checked"'; endif; ?> /> <?php _e('Post', 'custom-field-template'); ?>
- <input type="radio" name="custom_field_template_post_type[<?php echo $i; ?>]" id="custom_field_template_post_type[<?php echo $i; ?>]" value="page"<?php if ( !empty($options['custom_fields'][$i]['post_type']) && $options['custom_fields'][$i]['post_type']=='page') : echo ' checked="checked"'; endif; ?> /> <?php _e('Page', 'custom-field-template'); ?></span></p>
- <p><label for="custom_field_template_custom_post_type[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Custom Post Type (comma-deliminated)', 'custom-field-template'), $i); ?></a></label>:<br />
- <input type="text" name="custom_field_template_custom_post_type[<?php echo $i; ?>]" id="custom_field_template_custom_post_type[<?php echo $i; ?>]" value="<?php if ( isset($options['custom_fields'][$i]['custom_post_type']) ) echo esc_attr(stripcslashes($options['custom_fields'][$i]['custom_post_type'])); ?>" size="80"<?php if ( empty($options['custom_fields'][$i]['custom_post_type']) ) : echo ' style="display:none;"'; endif; ?> /></p>
- <p><label for="custom_field_template_post[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Post ID (comma-deliminated)', 'custom-field-template'), $i); ?></a></label>:<br />
- <input type="text" name="custom_field_template_post[<?php echo $i; ?>]" id="custom_field_template_post[<?php echo $i; ?>]" value="<?php if ( isset($options['custom_fields'][$i]['post']) ) echo esc_attr(stripcslashes($options['custom_fields'][$i]['post'])); ?>" size="80"<?php if ( empty($options['custom_fields'][$i]['post']) ) : echo ' style="display:none;"'; endif; ?> /></p>
- <p><label for="custom_field_template_category[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Category ID (comma-deliminated)', 'custom-field-template'), $i); ?></a></label>:<br />
- <input type="text" name="custom_field_template_category[<?php echo $i; ?>]" id="custom_field_template_category[<?php echo $i; ?>]" value="<?php if ( isset($options['custom_fields'][$i]['category']) ) echo esc_attr(stripcslashes($options['custom_fields'][$i]['category'])); ?>" size="80"<?php if ( empty($options['custom_fields'][$i]['category']) ) : echo ' style="display:none;"'; endif; ?> /></p>
- <p><label for="custom_field_template_template_files[<?php echo $i; ?>]"><a href="javascript:void(0);" onclick="jQuery(this).parent().next().next().toggle();"><?php echo sprintf(__('Page Template file name(s) (comma-deliminated)', 'custom-field-template'), $i); ?></a></label>:<br />
- <input type="text" name="custom_field_template_template_files[<?php echo $i; ?>]" id="custom_field_template_template_files[<?php echo $i; ?>]" value="<?php if ( isset($options['custom_fields'][$i]['template_files']) ) echo esc_attr(stripcslashes($options['custom_fields'][$i]['template_files'])); ?>" size="80"<?php if ( empty($options['custom_fields'][$i]['template_files']) ) : echo ' style="display:none;"'; endif; ?> /></p>
- <p><label for="custom_field_template_content[<?php echo $i; ?>]"><?php echo sprintf(__('Template Content', 'custom-field-template'), $i); ?></label>:<br />
- <textarea name="custom_field_template_content[<?php echo $i; ?>]" class="resizable large-text" id="custom_field_template_content[<?php echo $i; ?>]" rows="10" cols="80"><?php if ( isset($options['custom_fields'][$i]['content']) ) echo stripcslashes($options['custom_fields'][$i]['content']); ?></textarea></p>
- </td></tr>
- <?php
- }
- ?>
- <tr><td>
- <p><input type="submit" name="custom_field_template_set_options_submit" value="<?php _e('Update Options »', 'custom-field-template'); ?>" class="button-primary" /></p>
- </td></tr>
- </tbody>
- </table>
- </form>
- </div>
- </div>
-
- <div class="postbox closed">
- <div class="handlediv" title="<?php _e('Click to toggle', 'custom-field-template'); ?>"><br /></div>
- <h3><?php _e('Global Settings', 'custom-field-template'); ?></h3>
- <div class="inside">
- <form method="post">
- <table class="form-table" style="margin-bottom:5px;">
- <tbody>
- <?php
- /*
- <tr><td>
- <p><label for="custom_field_template_use_multiple_insert"><?php _e('In case that you would like to insert multiple images at once in use of the custom field media buttons', 'custom-field-template'); ?></label>:<br />
- <input type="checkbox" name="custom_field_template_use_multiple_insert" id="custom_field_template_use_multiple_insert" value="1" <?php if ($options['custom_field_template_use_multiple_insert']) { echo 'checked="checked"'; } ?> /> <?php _e('Use multiple image inset', 'custom-field-template'); ?><br /><span style="color:#FF0000; font-weight:bold;"><?php _e('Caution:', 'custom-field-teplate'); ?> <?php _e('You need to edit `wp-admin/includes/media.php`. Delete or comment out the code in the function media_send_to_editor.', 'custom-field-template'); ?></span></p>
- </td>
- </tr>
- */
- ?>
- <tr><td>
- <p><label for="custom_field_template_replace_keys_by_labels"><?php _e('In case that you would like to replace custom keys by labels if `lab…
Large files files are truncated, but you can click here to view the full file