From 131dcefea7242fc3f5378976c0c26ae8d1a25f25 Mon Sep 17 00:00:00 2001 From: evkos Date: Fri, 2 Jun 2017 18:03:07 +0300 Subject: [PATCH 01/16] refactor main plugin file --- controllers/AdminController.php | 8 +-- controllers/MigrateController.php | 2 +- core/JustField.php | 40 ++++++------ just-custom-fields.php | 100 +++++++++++++++--------------- models/Field.php | 2 +- views/fields/form.php | 6 +- 6 files changed, 79 insertions(+), 79 deletions(-) diff --git a/controllers/AdminController.php b/controllers/AdminController.php index 7fd65e8..c92af58 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -31,8 +31,8 @@ public function __construct() */ public function adminMenu() { - $page_title = \JustCustomFields::$pluginName; - $page_slug = \JustCustomFields::$pluginSlug; + $page_title = \JustCustomFields::$plugin_name; + $page_slug = \JustCustomFields::$plugin_slug; add_options_page($page_title, $page_title, 'manage_options', 'jcf_admin', array( $this, 'actionIndex' )); } @@ -59,7 +59,7 @@ public function actionIndex() */ public function addScripts() { - $slug = \JustCustomFields::$pluginSlug; + $slug = \JustCustomFields::$plugin_slug; wp_register_script( $slug, jcf_plugin_url('assets/just_custom_fields.js'), @@ -86,7 +86,7 @@ public function localizeScripts() */ public function addStyles() { - $slug = \JustCustomFields::$pluginName; + $slug = \JustCustomFields::$plugin_name; wp_register_style($slug, jcf_plugin_url('assets/styles.css'), array( 'media-views' )); wp_enqueue_style($slug); } diff --git a/controllers/MigrateController.php b/controllers/MigrateController.php index 5de6774..e3c07c4 100644 --- a/controllers/MigrateController.php +++ b/controllers/MigrateController.php @@ -28,7 +28,7 @@ public function __construct() */ public function initRoutes() { - $page_title = \JustCustomFields::$pluginName; + $page_title = \JustCustomFields::$plugin_name; add_options_page($page_title, $page_title, 'manage_options', 'jcf_upgrade', array( $this, 'actionIndex' )); } diff --git a/core/JustField.php b/core/JustField.php index 3149b0f..08133eb 100644 --- a/core/JustField.php +++ b/core/JustField.php @@ -11,7 +11,7 @@ class JustField * Root id for all fields of this type (field type) * @var string */ - public $idBase; + public $id_base; public static $compatibility = '3.0+'; // compatibility with WP version + it >=, - it < public $title; // Name for this field type. public $slug = null; @@ -73,7 +73,7 @@ class JustField */ public function __construct( $id_base, $title, $field_options = array() ) { - $this->idBase = $id_base; + $this->id_base = $id_base; $this->title = $title; $this->fieldOptions = array_merge($this->fieldOptions, $field_options); @@ -141,13 +141,13 @@ public function setId( $id ) $this->id = $id; // this is add request. so number is 0 - if ( $this->id == $this->idBase ) { + if ( $this->id == $this->id_base ) { $this->number = 0; $this->isNew = true; } // parse number else { - $this->number = str_replace($this->idBase . '-', '', $this->id); + $this->number = str_replace($this->id_base . '-', '', $this->id); // load instance data $fields = $this->_dL->getFields(); @@ -232,10 +232,10 @@ public function getFieldId( $str, $delimeter = '-' ) if ( $this->isCollectionField() && $this->isPostEdit ) { $collection = core\JustFieldFactory::create($field_model); - return str_replace('-', $delimeter, 'field' . $delimeter . $collection->idBase . $delimeter . $collection->number . $delimeter + return str_replace('-', $delimeter, 'field' . $delimeter . $collection->id_base . $delimeter . $collection->number . $delimeter . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . $delimeter . $this->id . $delimeter . $str); } - return 'field' . $delimeter . $this->idBase . $delimeter . $this->number . $delimeter . $str; + return 'field' . $delimeter . $this->id_base . $delimeter . $this->number . $delimeter . $str; } /** @@ -258,9 +258,9 @@ public function getFieldName( $str ) if ( $this->isCollectionField() && $this->isPostEdit ) { $collection = core\JustFieldFactory::create($field_model); - return 'field-' . $collection->idBase . '[' . $collection->number . '][' . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . '][' . $this->id . '][' . $str . ']'; + return 'field-' . $collection->id_base . '[' . $collection->number . '][' . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . '][' . $this->id . '][' . $str . ']'; } - return 'field-' . $this->idBase . '[' . $this->number . '][' . $str . ']'; + return 'field-' . $this->id_base . '[' . $this->number . '][' . $str . ']'; } /** @@ -310,7 +310,7 @@ public function getInstanceVersion( $instance ) */ public function doUpdate( $field_index, $params = null ) { - $input = !is_null($params) ? $params : $_POST['field-' . $this->idBase][$this->number]; + $input = !is_null($params) ? $params : $_POST['field-' . $this->id_base][$this->number]; // remove all slashed from values foreach ( $input as $var => $value ) { if ( is_string($value) ) { @@ -328,7 +328,7 @@ public function doUpdate( $field_index, $params = null ) $instance['slug'] = strip_tags($input['slug']); $instance['enabled'] = (int) @$input['enabled']; - if ( $this->idBase == 'inputtext' ) + if ( $this->id_base == 'inputtext' ) $instance['group_title'] = (int) @$input['group_title']; // starting from vers. 1.4 all new fields should be marked with version of the plugin @@ -339,7 +339,7 @@ public function doUpdate( $field_index, $params = null ) if ( empty($instance['_version']) ) { $instance['_version'] = 1.34; } - $instance['_type'] = $this->idBase; + $instance['_type'] = $this->id_base; // new from version 1.4: validation/normalization $this->validateInstance($instance); @@ -353,12 +353,12 @@ public function doUpdate( $field_index, $params = null ) if ( $this->isNew ) { $this->number = $field_index; - $this->id = $this->idBase . '-' . $this->number; + $this->id = $this->id_base . '-' . $this->number; } // check slug field if ( empty($instance['slug']) ) { - $instance['slug'] = '_field_' . $this->idBase . '__' . $this->number; + $instance['slug'] = '_field_' . $this->id_base . '__' . $this->number; } $fields = $this->_dL->getFields(); @@ -393,7 +393,7 @@ public function doUpdate( $field_index, $params = null ) $res = array( 'status' => '1', 'id' => $this->id, - 'id_base' => $this->idBase, + 'id_base' => $this->id_base, 'fieldset_id' => $this->fieldsetId, 'collection_id' => $this->collectionId, 'is_new' => $this->isNew, @@ -443,15 +443,15 @@ public function doSave() return false; // check that we have data in POST - if ( $this->idBase != 'checkbox' && ( - empty($_POST['field-' . $this->idBase][$this->number]) || - !is_array($_POST['field-' . $this->idBase][$this->number]) + if ( $this->id_base != 'checkbox' && ( + empty($_POST['field-' . $this->id_base][$this->number]) || + !is_array($_POST['field-' . $this->id_base][$this->number]) ) ) { return false; } - $input = @$_POST['field-' . $this->idBase][$this->number]; + $input = @$_POST['field-' . $this->id_base][$this->number]; // get real values $values = $this->save($input); @@ -566,8 +566,8 @@ public function doShortcode( $args ) $class_names = array( "jcf-value", - "jcf-value-{$this->idBase}", - "jcf-value-{$this->idBase}-{$this->slug}", + "jcf-value-{$this->id_base}", + "jcf-value-{$this->id_base}-{$this->slug}", ); if ( !empty($args['class']) ) { diff --git a/just-custom-fields.php b/just-custom-fields.php index 5f3bf24..e6fc67a 100755 --- a/just-custom-fields.php +++ b/just-custom-fields.php @@ -15,8 +15,7 @@ use jcf\core; use jcf\controllers; -class JustCustomFields extends core\Singleton -{ +class JustCustomFields extends core\Singleton { /** * Plugin text domain for translations @@ -29,14 +28,14 @@ class JustCustomFields extends core\Singleton * * @var string */ - public static $pluginName; + public static $plugin_name; /** * Variable-style plugin name * * @var string */ - public static $pluginSlug = 'just_custom_fields'; + public static $plugin_slug = 'just_custom_fields'; /** * Current plugin version @@ -55,36 +54,35 @@ class JustCustomFields extends core\Singleton /** * Plugin main entry point * - * protected constructor prevents creating another plugin instance with "new" operator + * Protected constructor prevents creating another plugin instance with "new" operator */ - protected function __construct() - { - // init plugin name and version - self::$pluginName = __('Just Custom Fields', JustCustomFields::TEXTDOMAIN); - self::$version = self::VERSION; + protected function __construct() { + /* init plugin name and version */ + self::$plugin_name = __( 'Just Custom Fields', JustCustomFields::TEXTDOMAIN ); + self::$version = self::VERSION; - // init features, which this plugin is created for + /* init features, which this plugin is created for */ $this->initControllers(); $this->initFields(); - add_action('plugins_loaded', array($this, 'registerCustomComponents')); + add_action( 'plugins_loaded', array( $this, 'registerCustomComponents' ) ); } /** * Init all controllers to support post edit pages and admin configuration pages */ - public function initControllers() - { + public function initControllers() { $loader = new core\PluginLoader(); - // we use wp_doing_ajax to prevent version check under ajax + /* we use wp_doing_ajax to prevent version check under ajax */ if ( ! wp_doing_ajax() && $loader->checkMigrationsAvailable() ) { new controllers\MigrateController(); new controllers\AdminController(); - } - else { + } else { new controllers\PostTypeController(); - if ( !is_admin() ) return; + if ( ! is_admin() ) { + return; + } new controllers\AdminController(); new controllers\SettingsController(); @@ -97,8 +95,7 @@ public function initControllers() /** * Init field components (field types, which can be added to post type) */ - public function initFields() - { + public function initFields() { $this->registerField( 'jcf\components\inputtext\JustField_InputText', true ); $this->registerField( 'jcf\components\textarea\JustField_Textarea', true ); $this->registerField( 'jcf\components\select\JustField_Select', true ); @@ -115,68 +112,71 @@ public function initFields() /** * Launch hook to be able to register mode components from themes and other plugins * - * to add more field components with your custom code: + * To add more field components with your custom code: * - add_action 'jcf_register_fields' * - include your components files * - run * $jcf = new \JustCustomFields(); * $jcf->registerField('namespace\className', $collection_field = true|false); - * */ - public function registerCustomComponents() - { + public function registerCustomComponents() { do_action( 'jcf_register_fields' ); } /** - * register field component - * - * @param $class_name - * @param bool $collection_field - * @return bool - */ - public function registerField( $class_name, $collection_field = false ) - { - if ( strpos($class_name, '\\') === FALSE ) $class_name = '\\' . $class_name; + * Register field component + * + * @param $class_name + * @param bool $collection_field + * @return bool + */ + public function registerField( $class_name, $collection_field = false ) { + if ( strpos( $class_name, '\\' ) === false ) { + $class_name = '\\' . $class_name; + } $field_obj = new $class_name(); $field = array( - 'id_base' => $field_obj->idBase, + 'id_base' => $field_obj->id_base, 'class' => $class_name, 'title' => $field_obj->title, 'collection_field' => $collection_field, ); - $this->_fields[$field_obj->idBase] = $field; + $this->_fields[ $field_obj->id_base ] = $field; } - + /** - * return array of registered fields + * Return array of registered fields + * + * @param bool $collection_only + * @return array $collection_fields */ - public function getFields( $collection_only = false ) - { - if ( ! $collection_only ) + public function getFields( $collection_only = false ) { + if ( ! $collection_only ) { return $this->_fields; - - // filter by collection availability + } + /* filter by collection availability */ $collection_fields = array(); - foreach ($this->_fields as $f) { - if ( !$f['collection_field'] ) continue; + foreach ( $this->_fields as $f ) { + if ( ! $f['collection_field'] ) { + continue; + } $collection_fields[] = $f; } - + return $collection_fields; } - + /** * Field info (title, id_base, class) + * * @param string $id_base * @return array */ - public function getFieldInfo($id_base) - { - if ( !empty($this->_fields[$id_base]) ) { - return $this->_fields[$id_base]; + public function getFieldInfo( $id_base ) { + if ( ! empty( $this->_fields[ $id_base ] ) ) { + return $this->_fields[ $id_base ]; } return null; } diff --git a/models/Field.php b/models/Field.php index b4dae2d..f10ee8c 100644 --- a/models/Field.php +++ b/models/Field.php @@ -64,7 +64,7 @@ public function findCollectionsByPostType( $post_type ) public function save( $import = null ) { $field_obj = core\JustFieldFactory::create($this); - $field_index = core\JustFieldFactory::createFieldIndex($field_obj->idBase); + $field_index = core\JustFieldFactory::createFieldIndex($field_obj->id_base); return $field_obj->doUpdate($field_index, $import); } diff --git a/views/fields/form.php b/views/fields/form.php index d09eb72..8278a8a 100644 --- a/views/fields/form.php +++ b/views/fields/form.php @@ -1,4 +1,4 @@ -idBase == $field->id) ? __('Add', \JustCustomFields::TEXTDOMAIN) : __('Edit', \JustCustomFields::TEXTDOMAIN); ?> +id_base == $field->id) ? __('Add', \JustCustomFields::TEXTDOMAIN) : __('Edit', \JustCustomFields::TEXTDOMAIN); ?>

title; ?>

@@ -8,7 +8,7 @@
- + isCollectionField() ) : ?> @@ -38,7 +38,7 @@

isCollectionField()) : ?> - idBase == 'inputtext') : ?> + id_base == 'inputtext') : ?>

' . __('Please check settings. Values are empty', \JustCustomFields::TEXTDOMAIN) . '

'; + if ( empty( $values ) ) { + echo '

' . __( 'Please check settings. Values are empty', \JustCustomFields::TEXTDOMAIN ) . '

'; return false; } - $single_checkbox = (count($values) == 1) ? true : false; + $single_checkbox = ( count( $values ) === 1 ) ? true : false; ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?>
@@ -45,118 +43,108 @@ public function field() entry) ? true : false; - } - else { - $checked = in_array($val, (array) $this->entry); + } else { + $checked = in_array( $val, (array) $this->entry ); } ?> - +
- instance['description']) ) : ?> -

instance['description']); ?>

+ instance['description'] ) ) : ?> +

instance['description'] ); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
instance, array( 'title' => '', 'settings' => '', 'description' => '' )); - - $title = esc_attr($instance['title']); - $settings = esc_attr($instance['settings']); - $description = esc_html($instance['description']); + public function form() { + /* Defaults */ + $instance = wp_parse_args( (array) $this->instance, array( 'title' => '', 'settings' => '', 'description' => '' ) ); ?>

- - + +

- - -
label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN); ?>
+ + +
label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>

- - + +

parsedSelectOptions($this->instance); - $options = array_flip($options); + public function shortcodeValue( $args ) { + $options = $this->parsedSelectOptions( $this->instance ); + $options = array_flip( $options ); - if ( empty($this->entry) ) + if ( empty( $this->entry ) ) { return ''; + } $html = '
    '; foreach ( $this->entry as $value ) { - $key = preg_replace('/\s+/', '-', $value); - $key = preg_replace('/[^0-9a-z\-\_]/i', '', $key); - if ( isset($options[$value]) ) { - $value = $options[$value]; + $key = preg_replace( '/\s+/', '-', $value ); + $key = preg_replace( '/[^0-9a-z\-\_]/i', '', $key ); + if ( isset( $options[ $value ] ) ) { + $value = $options[ $value ]; } - $key = esc_attr($key); - $value = esc_html($value); + $key = esc_attr( $key ); + $value = esc_html( $value ); $html .= "
  • $value
  • \r\n"; } $html .= '
'; diff --git a/components/collection/JustField_Collection.php b/components/collection/JustField_Collection.php index 3215ab7..a2d2fed 100644 --- a/components/collection/JustField_Collection.php +++ b/components/collection/JustField_Collection.php @@ -55,9 +55,9 @@ public function field() $entries = (array) $this->entry; ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> instance['fields']) ) : ?>

Collection element has no fields registered. Please check component settings

@@ -101,8 +101,8 @@ public function field() $field_obj->entry = $fields[$field['slug']]; } - $field_obj->isPostEdit = true; - $field_obj->fieldOptions['after_title'] = ':'; + $field_obj->isPostEdit = true; + $field_obj->field_options['after_title'] = ':'; $field_obj->field(); ?>
@@ -123,7 +123,7 @@ class="button button-large jcf_add_more_collection"
- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
setSlug($field['slug']); - $field_obj->instance = $field; - $field_obj->isPostEdit = true; - $field_obj->fieldOptions['after_title'] = ':'; + $field_obj->instance = $field; + $field_obj->isPostEdit = true; + $field_obj->field_options['after_title'] = ':'; ?>
field(); ?> diff --git a/components/datepicker/JustField_DatePicker.php b/components/datepicker/JustField_DatePicker.php index ba915e9..c12276b 100644 --- a/components/datepicker/JustField_DatePicker.php +++ b/components/datepicker/JustField_DatePicker.php @@ -21,9 +21,9 @@ public function __construct() public function field() { ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
@@ -43,7 +43,7 @@ public function field()

instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
entry = wp_parse_args($this->entry, array('lat' => '', 'lng' => '', 'address' => '',)); ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
@@ -99,7 +99,7 @@ public function field() - fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
-
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
-
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
$entry ) : ?> @@ -126,7 +126,7 @@ public function field()
- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
parsedSelectOptions($this->instance); ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
$val ): ?> @@ -43,7 +43,7 @@ public function field() instance['description'] != '' ) : ?>

instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
entry) ) $this->entry = 0; ?> -
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
entry) ) { @@ -87,7 +87,7 @@ public function field() instance['description'] != '' ) : ?>

instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
-
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
@@ -98,7 +98,7 @@ public function field() instance['description'] != '' ): ?>

instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
-
- fieldOptions['before_widget']; ?> - fieldOptions['before_title'] . esc_html($this->instance['title']) . $this->fieldOptions['after_title']; ?> +
+ field_options['before_widget']; ?> + field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> instance['editor']) ) : // check editor @@ -77,7 +77,7 @@ public function field() instance['description']) ) : ?>

instance['description']); ?>

- fieldOptions['after_widget']; ?> + field_options['after_widget']; ?>
doAddJs(); $field_obj->doAddCss(); - $field_obj->fieldOptions['after_title'] = ': '; + $field_obj->field_options['after_title'] = ': '; ob_start(); $field_obj->field(); $htmlFields .= ob_get_clean(); diff --git a/core/JustField.php b/core/JustField.php index 6c1f115..c606f82 100644 --- a/core/JustField.php +++ b/core/JustField.php @@ -21,7 +21,7 @@ class JustField public static $compatibility = '3.0+'; // compatibility with WP version + it >=, - it < public $title; // Name for this field type. public $slug = null; - public $fieldOptions = array( + public $field_options = array( 'classname' => 'jcf_custom_field', 'before_widget' => '
', 'after_widget' => '
', @@ -80,9 +80,9 @@ class JustField */ public function __construct( $id_base, $title, $field_options = array() ) { - $this->id_base = $id_base; - $this->title = $title; - $this->fieldOptions = array_merge($this->fieldOptions, $field_options); + $this->id_base = $id_base; + $this->title = $title; + $this->field_options = array_merge($this->field_options, $field_options); // init data layer $this->_dL = DataLayerFactory::create(); @@ -170,8 +170,8 @@ public function setId( $id ) $this->instance = (array) $fields[$this->postType][$this->id]; if ( !empty($this->instance) ) { - $this->slug = $this->instance['slug']; - $this->fieldOptions['after_title'] .= '
+ $this->slug = $this->instance['slug']; + $this->field_options['after_title'] .= '
'; } diff --git a/just-custom-fields.php b/just-custom-fields.php index a8e07af..cb2e099 100755 --- a/just-custom-fields.php +++ b/just-custom-fields.php @@ -8,9 +8,9 @@ Author URI: http://justcoded.com/ Version: 3.2 */ -define('JCF_ROOT', dirname(__FILE__)); -require_once( JCF_ROOT.'/core/Autoload.php' ); -require_once( JCF_ROOT.'/functions/helpers.php' ); +define( 'JCF_ROOT', dirname( __FILE__ ) ); +require_once( JCF_ROOT . '/core/Autoload.php' ); +require_once( JCF_ROOT . '/functions/helpers.php' ); use jcf\core; use jcf\controllers; @@ -183,4 +183,4 @@ public function getFieldInfo( $id_base ) { } -JustCustomFields::run(); \ No newline at end of file +JustCustomFields::run(); From 49db74a80c1754d3914032aae15f8bb5149bac35 Mon Sep 17 00:00:00 2001 From: evkos Date: Thu, 8 Jun 2017 15:40:41 +0300 Subject: [PATCH 03/16] correct methods names form main plugin file --- controllers/FieldController.php | 2 +- controllers/FieldsetController.php | 4 +-- core/DataLayer.php | 4 +-- core/JustField.php | 12 ++++---- core/JustFieldFactory.php | 2 +- core/PluginLoader.php | 2 +- just-custom-fields.php | 46 +++++++++++++++--------------- models/Field.php | 10 +++---- models/Fieldset.php | 18 ++++++------ models/FieldsetVisibility.php | 14 ++++----- models/ImportExport.php | 4 +-- models/Migrate.php | 2 +- models/Shortcodes.php | 2 +- 13 files changed, 61 insertions(+), 61 deletions(-) diff --git a/controllers/FieldController.php b/controllers/FieldController.php index 8951ca1..c00c6be 100644 --- a/controllers/FieldController.php +++ b/controllers/FieldController.php @@ -48,7 +48,7 @@ public function ajaxSave() if ( $model->load($_POST) && $success = $model->save() ) { if ( isset($success['id_base']) && $success['id_base'] == 'collection' ) { $jcf = \JustCustomFields::getInstance(); - $registered_fields = $jcf->getFields('collection'); + $registered_fields = $jcf->get_fields('collection'); $post_type_kind = models\Field::getPostTypeKind($model->post_type); if ( JustField::POSTTYPE_KIND_TAXONOMY == $post_type_kind ) { diff --git a/controllers/FieldsetController.php b/controllers/FieldsetController.php index aaecf09..dc5843c 100644 --- a/controllers/FieldsetController.php +++ b/controllers/FieldsetController.php @@ -56,8 +56,8 @@ public function actionIndex() $fieldsets = $fieldset_model->findByPostType($post_type_id); $fields = $field_model->findByPostType($post_type_id); $collections = $field_model->findCollectionsByPostType($post_type_id); - $collections['registered_fields'] = $jcf->getFields('collection'); - $registered_fields = $jcf->getFields(); + $collections['registered_fields'] = $jcf->get_fields('collection'); + $registered_fields = $jcf->get_fields(); if ( core\JustField::POSTTYPE_KIND_TAXONOMY == $post_type_kind ) { $post_types = jcf_get_taxonomies('objects'); diff --git a/core/DataLayer.php b/core/DataLayer.php index 7768a1e..e37ec69 100755 --- a/core/DataLayer.php +++ b/core/DataLayer.php @@ -38,7 +38,7 @@ public function __construct() * * @return array */ - public function getFields() + public function get_fields() { return $this->_fields; } @@ -48,7 +48,7 @@ public function getFields() * * @return array */ - public function getFieldsets() + public function get_fieldsets() { return $this->_fieldsets; } diff --git a/core/JustField.php b/core/JustField.php index c606f82..00b7d05 100644 --- a/core/JustField.php +++ b/core/JustField.php @@ -165,7 +165,7 @@ public function setId( $id ) $this->number = str_replace($this->id_base . '-', '', $this->id); // load instance data - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); if ( isset($fields[$this->postType][$this->id]) ) $this->instance = (array) $fields[$this->postType][$this->id]; @@ -198,7 +198,7 @@ public function setPostID( $post_ID, $key_from_collection = FALSE ) if ( !empty($this->collectionId) ) { // load entry if ( !empty($this->slug) ) { - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); if ( empty($fields[$this->postType][$this->collectionId]) ) return; @@ -401,11 +401,11 @@ public function doUpdate( $field_index, $params = null ) $instance['slug'] = '_field_' . $this->id_base . '__' . $this->number; } - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); if ( !$this->isCollectionField() ) { // update fieldset - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); $fieldsets[$this->postType][$this->fieldsetId]['fields'][$this->id] = $instance['enabled']; $this->_dL->setFieldsets($fieldsets); $this->_dL->saveFieldsetsData(); @@ -448,13 +448,13 @@ public function doUpdate( $field_index, $params = null ) */ public function doDelete() { - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); if ( !empty($this->collectionId) ) { unset($fields[$this->postType][$this->collectionId]['fields'][$this->id]); } else { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); unset($fieldsets[$this->postType][$this->fieldsetId]['fields'][$this->id]); unset($fields[$this->postType][$this->id]); diff --git a/core/JustFieldFactory.php b/core/JustFieldFactory.php index 430f24f..36c1a4b 100644 --- a/core/JustFieldFactory.php +++ b/core/JustFieldFactory.php @@ -23,7 +23,7 @@ public static function create( \jcf\models\Field $field ) $id_base = preg_replace('/\-([0-9]+)/', '', $field_mixed); $jcf = \JustCustomFields::run(); - $field_info = $jcf->getFieldInfo($id_base); + $field_info = $jcf->get_field_info($id_base); if ( empty($field_info['class']) || !class_exists($field_info['class']) ) { return null; diff --git a/core/PluginLoader.php b/core/PluginLoader.php index 4b32c46..15b4a92 100644 --- a/core/PluginLoader.php +++ b/core/PluginLoader.php @@ -30,7 +30,7 @@ public function __construct() * * @return bool */ - public function checkMigrationsAvailable() + public function check_migrations_available() { $version = $this->getStorageVersion(); diff --git a/just-custom-fields.php b/just-custom-fields.php index cb2e099..6830784 100755 --- a/just-custom-fields.php +++ b/just-custom-fields.php @@ -20,7 +20,7 @@ class JustCustomFields extends core\Singleton { /** * Plugin text domain for translations */ - const TEXTDOMAIN = 'just-custom-fields'; + const TEXTDOMAIN = 'jcf'; const VERSION = '3.200'; /** @@ -62,19 +62,19 @@ protected function __construct() { self::$version = self::VERSION; /* init features, which this plugin is created for */ - $this->initControllers(); + $this->init_controllers(); - $this->initFields(); - add_action( 'plugins_loaded', array( $this, 'registerCustomComponents' ) ); + $this->init_fields(); + add_action( 'plugins_loaded', array( $this, 'register_custom_components' ) ); } /** * Init all controllers to support post edit pages and admin configuration pages */ - public function initControllers() { + public function init_controllers() { $loader = new core\PluginLoader(); /* we use wp_doing_ajax to prevent version check under ajax */ - if ( ! wp_doing_ajax() && $loader->checkMigrationsAvailable() ) { + if ( ! wp_doing_ajax() && $loader->check_migrations_available() ) { new controllers\MigrateController(); new controllers\AdminController(); } else { @@ -95,18 +95,18 @@ public function initControllers() { /** * Init field components (field types, which can be added to post type) */ - public function initFields() { - $this->registerField( 'jcf\components\inputtext\JustField_InputText', true ); - $this->registerField( 'jcf\components\textarea\JustField_Textarea', true ); - $this->registerField( 'jcf\components\select\JustField_Select', true ); - $this->registerField( 'jcf\components\selectmultiple\JustField_SelectMultiple', true ); - $this->registerField( 'jcf\components\checkbox\JustField_Checkbox', true ); - $this->registerField( 'jcf\components\datepicker\JustField_DatePicker', true ); - $this->registerField( 'jcf\components\simplemedia\JustField_SimpleMedia', true ); - $this->registerField( 'jcf\components\collection\JustField_Collection' ); - $this->registerField( 'jcf\components\table\JustField_Table', true ); - $this->registerField( 'jcf\components\relatedcontent\JustField_RelatedContent', true ); - $this->registerField( 'jcf\components\googlemaps\JustField_GoogleMaps', true ); + public function init_fields() { + $this->register_field( 'jcf\components\inputtext\JustField_InputText', true ); + $this->register_field( 'jcf\components\textarea\JustField_Textarea', true ); + $this->register_field( 'jcf\components\select\JustField_Select', true ); + $this->register_field( 'jcf\components\selectmultiple\JustField_SelectMultiple', true ); + $this->register_field( 'jcf\components\checkbox\JustField_Checkbox', true ); + $this->register_field( 'jcf\components\datepicker\JustField_DatePicker', true ); + $this->register_field( 'jcf\components\simplemedia\JustField_SimpleMedia', true ); + $this->register_field( 'jcf\components\collection\JustField_Collection' ); + $this->register_field( 'jcf\components\table\JustField_Table', true ); + $this->register_field( 'jcf\components\relatedcontent\JustField_RelatedContent', true ); + $this->register_field( 'jcf\components\googlemaps\JustField_GoogleMaps', true ); } /** @@ -117,9 +117,9 @@ public function initFields() { * - include your components files * - run * $jcf = new \JustCustomFields(); - * $jcf->registerField('namespace\className', $collection_field = true|false); + * $jcf->register_field('namespace\className', $collection_field = true|false); */ - public function registerCustomComponents() { + public function register_custom_components() { do_action( 'jcf_register_fields' ); } @@ -130,7 +130,7 @@ public function registerCustomComponents() { * @param bool $collection_field * @return bool */ - public function registerField( $class_name, $collection_field = false ) { + public function register_field( $class_name, $collection_field = false ) { if ( strpos( $class_name, '\\' ) === false ) { $class_name = '\\' . $class_name; } @@ -152,7 +152,7 @@ public function registerField( $class_name, $collection_field = false ) { * @param bool $collection_only * @return array $collection_fields */ - public function getFields( $collection_only = false ) { + public function get_fields( $collection_only = false ) { if ( ! $collection_only ) { return $this->_fields; } @@ -174,7 +174,7 @@ public function getFields( $collection_only = false ) { * @param string $id_base * @return array */ - public function getFieldInfo( $id_base ) { + public function get_field_info( $id_base ) { if ( ! empty( $this->_fields[ $id_base ] ) ) { return $this->_fields[ $id_base ]; } diff --git a/models/Field.php b/models/Field.php index 5ef7a68..6524b90 100644 --- a/models/Field.php +++ b/models/Field.php @@ -21,7 +21,7 @@ class Field extends core\Model */ public function findAll() { - return $this->_dL->getFields(); + return $this->_dL->get_fields(); } /** @@ -31,7 +31,7 @@ public function findAll() */ public function findByPostType( $post_type ) { - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); if ( !empty($fields[$post_type]) ) return $fields[$post_type]; @@ -45,7 +45,7 @@ public function findByPostType( $post_type ) */ public function findCollectionsByPostType( $post_type ) { - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); $collections = array(); if ( !empty($fields[$post_type]) ) { @@ -88,7 +88,7 @@ public function delete() public function sort() { $order = trim($this->fields_order, ','); - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); $new_fields = explode(',', $order); $fieldsets[$this->post_type][$this->fieldset_id]['fields'] = array(); @@ -112,7 +112,7 @@ public function sort() */ public function sortCollection() { - $fields = $this->_dL->getFields(); + $fields = $this->_dL->get_fields(); $order = trim($this->fields_order, ','); $new_sort = explode(',', $order); $new_fields = array(); diff --git a/models/Fieldset.php b/models/Fieldset.php index 9dc62eb..3b5a940 100755 --- a/models/Fieldset.php +++ b/models/Fieldset.php @@ -28,8 +28,8 @@ class Fieldset extends core\Model */ public function getFieldsCounter() { - $fields = $this->_dL->getFields(); - $fieldsets = $this->_dL->getFieldsets(); + $fields = $this->_dL->get_fields(); + $fieldsets = $this->_dL->get_fieldsets(); $post_types = jcf_get_post_types(); $taxonomies = jcf_get_taxonomies(); @@ -87,7 +87,7 @@ public function getFieldsCounter() */ public function findByPostType( $post_type ) { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); if ( !empty($fieldsets[$post_type]) ) return $fieldsets[$post_type]; @@ -100,7 +100,7 @@ public function findByPostType( $post_type ) */ public function findAll() { - return $this->_dL->getFieldsets(); + return $this->_dL->get_fieldsets(); } /** @@ -110,7 +110,7 @@ public function findAll() */ public function findById( $fieldset_id ) { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); if ( empty($fieldsets[$this->post_type][$fieldset_id]) ) { $this->addError(__('Fieldset not found', \JustCustomFields::TEXTDOMAIN)); return false; @@ -131,7 +131,7 @@ public function create() $slug = $this->createSlug(); - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); // check exists if ( isset($fieldsets[$this->post_type][$slug]) ) { @@ -161,7 +161,7 @@ public function delete() return false; } - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); if ( isset($fieldsets[$this->post_type][$this->fieldset_id]) ) unset($fieldsets[$this->post_type][$this->fieldset_id]); @@ -174,7 +174,7 @@ public function delete() */ public function update() { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); if ( empty($fieldsets[$this->post_type][$this->fieldset_id]) ) { $this->addError(__('Wrong data passed.', \JustCustomFields::TEXTDOMAIN)); @@ -200,7 +200,7 @@ public function update() public function sort() { $sort = explode(',', trim($this->fieldsets_order, ',')); - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); $ordered_fieldsets = array(); foreach ( $sort as $key ) { diff --git a/models/FieldsetVisibility.php b/models/FieldsetVisibility.php index 03ba882..cf215b4 100644 --- a/models/FieldsetVisibility.php +++ b/models/FieldsetVisibility.php @@ -36,7 +36,7 @@ class FieldsetVisibility extends core\Model */ public function findByPostType($post_type) { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); $visibility_rules = array(); if ( empty($fieldsets[$post_type]) ) return; @@ -95,7 +95,7 @@ public function getForm() if ( !empty($this->scenario) && $this->scenario == self::SCENARIO_UPDATE ) { - $visibility_rule = $this->_getFieldsetVisibility($this->fieldset_id, $this->rule_id); + $visibility_rule = $this->_get_fieldset_visibility($this->fieldset_id, $this->rule_id); if ( empty($visibility_rule) ) { $this->addError(__('Visibility rule not found.', \JustCustomFields::TEXTDOMAIN)); @@ -137,7 +137,7 @@ public function getBasedOnOptions() */ public function update() { - $visibility_rules = $this->_getFieldsetVisibility($this->fieldset_id); + $visibility_rules = $this->_get_fieldset_visibility($this->fieldset_id); if ( empty($this->rule_id) ) $this->rule_id = time(); @@ -159,7 +159,7 @@ public function update() */ public function delete() { - $visibility_rules = $this->_getFieldsetVisibility($this->fieldset_id); + $visibility_rules = $this->_get_fieldset_visibility($this->fieldset_id); if ( isset($visibility_rules[$this->rule_id]) ) unset($visibility_rules[$this->rule_id]); @@ -210,9 +210,9 @@ public static function findTaxonomyTerms($taxonomy, $term) * @param integer|null $rule_id * @return mixed */ - protected function _getFieldsetVisibility( $fieldset_id, $rule_id = null ) + protected function _get_fieldset_visibility( $fieldset_id, $rule_id = null ) { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); // if we take only fieldset settings - return it if ( is_null($rule_id) ) { @@ -239,7 +239,7 @@ protected function _getFieldsetVisibility( $fieldset_id, $rule_id = null ) */ protected function _saveFieldsetVisibility( $fieldset_id, $rules ) { - $fieldsets = $this->_dL->getFieldsets(); + $fieldsets = $this->_dL->get_fieldsets(); $fieldsets[$this->post_type][$fieldset_id]['visibility_rules'] = $rules; return $this->_save($fieldsets); } diff --git a/models/ImportExport.php b/models/ImportExport.php index 22369a7..7fbcd7a 100644 --- a/models/ImportExport.php +++ b/models/ImportExport.php @@ -74,8 +74,8 @@ public function import() { if ( $this->action != 'jcf_import_fields' || empty($this->selected_data) || empty($this->import_source) ) return; - $dl_fields = $this->_dL->getFields(); - $dl_fieldsets = $this->_dL->getFieldsets(); + $dl_fields = $this->_dL->get_fields(); + $dl_fieldsets = $this->_dL->get_fieldsets(); // we take origin import source and remove elements which are not selected $import_source = json_decode(stripslashes($this->import_source), true); diff --git a/models/Migrate.php b/models/Migrate.php index e0a4853..cc0ce2e 100644 --- a/models/Migrate.php +++ b/models/Migrate.php @@ -247,7 +247,7 @@ public static function guessFields() { // try to get fields from current data layer. maybe we don't have much changes $data_layer = DataLayerFactory::create(); - if ( $fields = $data_layer->getFields() ) { + if ( $fields = $data_layer->get_fields() ) { return $fields; } diff --git a/models/Shortcodes.php b/models/Shortcodes.php index d0a54a7..746825b 100755 --- a/models/Shortcodes.php +++ b/models/Shortcodes.php @@ -24,7 +24,7 @@ protected function _initShortcode( $args ) //get post type $post_type = get_post_type($post_id); //get field settings - $field_settings = $this->_dL->getFields(); + $field_settings = $this->_dL->get_fields(); if ( empty($field_settings[$post_type]) ) return false; From 42f7dbe5dc28c6ff4d6c9edf08483f5f0fdaf57a Mon Sep 17 00:00:00 2001 From: evkos Date: Thu, 8 Jun 2017 17:51:23 +0300 Subject: [PATCH 04/16] refactor field params name --- components/checkbox/JustField_Checkbox.php | 20 +++++------ .../collection/JustField_Collection.php | 4 +-- .../datepicker/JustField_DatePicker.php | 14 ++++---- .../googlemaps/JustField_GoogleMaps.php | 36 +++++++++---------- components/inputtext/JustField_InputText.php | 8 ++--- .../JustField_RelatedContent.php | 20 +++++------ components/select/JustField_Select.php | 12 +++---- .../JustField_SelectMultiple.php | 10 +++--- components/selectmultiple/views/field.tpl.php | 2 +- components/selectmultiple/views/form.tpl.php | 8 ++--- .../simplemedia/JustField_SimpleMedia.php | 30 ++++++++-------- components/table/JustField_Table.php | 16 ++++----- components/textarea/JustField_Textarea.php | 16 ++++----- core/JustField.php | 4 +-- views/fields/form.php | 22 ++++++------ 15 files changed, 111 insertions(+), 111 deletions(-) diff --git a/components/checkbox/JustField_Checkbox.php b/components/checkbox/JustField_Checkbox.php index 452f679..b6dd3e1 100644 --- a/components/checkbox/JustField_Checkbox.php +++ b/components/checkbox/JustField_Checkbox.php @@ -24,7 +24,7 @@ public function __construct() { */ public function field() { /* prepare options array */ - $values = $this->parsedSelectOptions( $this->instance ); + $values = $this->parsed_select_options( $this->instance ); if ( empty( $values ) ) { echo '

' . __( 'Please check settings. Values are empty', \JustCustomFields::TEXTDOMAIN ) . '

'; @@ -47,7 +47,7 @@ public function field() { $checked = in_array( $val, (array) $this->entry ); } ?> - +
@@ -68,17 +68,17 @@ public function form() { $instance = wp_parse_args( (array) $this->instance, array( 'title' => '', 'settings' => '', 'description' => '' ) ); ?>

- - + +

- - + +
label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>

- - + +

parsedSelectOptions( $this->instance ); + $options = $this->parsed_select_options( $this->instance ); $options = array_flip( $options ); if ( empty( $this->entry ) ) { diff --git a/components/collection/JustField_Collection.php b/components/collection/JustField_Collection.php index a2d2fed..7d44ce7 100644 --- a/components/collection/JustField_Collection.php +++ b/components/collection/JustField_Collection.php @@ -62,7 +62,7 @@ public function field() instance['fields']) ) : ?>

Collection element has no fields registered. Please check component settings

- +
$fields ) : ?> @@ -138,7 +138,7 @@ public function form() $description = esc_html($instance['description']); $title = esc_attr($instance['title']); ?> -

+

field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?>
- +
diff --git a/components/textarea/JustField_Textarea.php b/components/textarea/JustField_Textarea.php index 8bc9dd3..3b82e2d 100644 --- a/components/textarea/JustField_Textarea.php +++ b/components/textarea/JustField_Textarea.php @@ -59,7 +59,7 @@ public function field() - isTaxonomyField() ) : ?> + is_taxonomy_field() ) : ?> diff --git a/core/Autoload.php b/core/Autoload.php index 664c0de..7315191 100644 --- a/core/Autoload.php +++ b/core/Autoload.php @@ -5,38 +5,35 @@ /** * SPL autoload registration for plugin to prevent using file includes */ -class Autoloader -{ +class Autoload { /** * Class contructor register SPL autoload callback function */ - public function __construct() - { - spl_autoload_register(array( $this, 'loader' )); + public function __construct() { + spl_autoload_register( array( $this, 'loader' ) ); } /** * Search for the class by namespace path and include it if found. - * - * @param string $class_name + * + * @param string $class_name Class name. */ - public function loader( $class_name ) - { - $class_path = str_replace('\\', '/', $class_name); + public function loader( $class_name ) { + $class_path = str_replace( '\\', '/', $class_name ); - // check if this class is related to the plugin namespace. exit if not - if ( strpos($class_path, 'jcf') !== 0 ) { + /* check if this class is related to the plugin namespace. exit if not */ + if ( strpos( $class_path, 'jcf' ) !== 0 ) { return; } - $path = preg_replace('/^jcf\//', JCF_ROOT . '/', $class_path) . '.php'; + $path = preg_replace( '/^jcf\//', JCF_ROOT . '/', $class_path ) . '.php'; - if ( is_file($path) ) { + if ( is_file( $path ) ) { require_once( $path ); } } } -new Autoloader(); +new Autoload(); diff --git a/core/Controller.php b/core/Controller.php index a5eca21..3462089 100755 --- a/core/Controller.php +++ b/core/Controller.php @@ -5,26 +5,22 @@ /** * Main controller */ -class Controller -{ +class Controller { /** * Controller constructor. */ - public function __construct() - { - - } + public function __construct(){} /** * Function for render views - * @param string $template file name to be rendered - * @param array $params array of variables to be passed to the view file + * + * @param string $template file name to be rendered. + * @param array $params array of variables to be passed to the view file. * @return boolean */ - protected function _render( $template, $params = array() ) - { - extract($params); + protected function _render( $template, $params = array() ) { + extract( $params ); include( JCF_ROOT . '/views/' . $template . '.php' ); return true; @@ -34,20 +30,18 @@ protected function _render( $template, $params = array() ) * Function for render views inside AJAX request * Echo rendered content directly in output buffer * - * @param string $template file name to be rendered - * @param string $format json|html control which header content type should be sent - * @param array $params array of variables to be passed to the view file + * @param string $template file name to be rendered. + * @param string $format json|html control which header content type should be sent. + * @param array $params array of variables to be passed to the view file. */ - protected function _render_ajax( $template = null, $format, $params = array() ) - { - if ( $format == 'json' ) { - $responce = json_encode($params); - header("Content-Type: application/json; charset=" . get_bloginfo('charset')); - } - else { - header("Content-Type: text/html; charset=" . get_bloginfo('charset')); + protected function _render_ajax( $template = null, $format, $params = array() ) { + if ( 'json' === $format ) { + $responce = json_encode( $params ); + header( 'Content-Type: application/json; charset=' . get_bloginfo( 'charset' ) ); + } else { + header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) ); ob_start(); - $this->_render($template, $params); + $this->_render( $template, $params ); $responce = ob_get_clean(); } echo $responce; diff --git a/core/DataLayer.php b/core/DataLayer.php index e37ec69..5d2dd48 100755 --- a/core/DataLayer.php +++ b/core/DataLayer.php @@ -6,17 +6,16 @@ * Abstract class for all data layers * Define methods to be defined in every child DataLayer */ -abstract class DataLayer -{ +abstract class DataLayer { /** - * fields settings + * Fields settings * * @var array */ protected $_fields = array(); /** - * fieldset settings + * Fieldset settings * * @var array */ @@ -27,10 +26,9 @@ abstract class DataLayer * * On create find fields and fieldsets */ - public function __construct() - { - $this->setFields(); - $this->setFieldsets(); + public function __construct() { + $this->set_fields(); + $this->set_fieldsets(); } /** @@ -38,8 +36,7 @@ public function __construct() * * @return array */ - public function get_fields() - { + public function get_fields() { return $this->_fields; } @@ -48,53 +45,52 @@ public function get_fields() * * @return array */ - public function get_fieldsets() - { + public function get_fieldsets() { return $this->_fieldsets; } /** * Method to get version of storage - * + * * @return array */ - abstract public function getStorageVersion(); + abstract public function get_storage_version(); /** * Method to update version of storage till last * - * @param float|null $version + * @param float|null $version Version. * @return boolean */ - abstract public function saveStorageVersion( $version = null ); + abstract public function save_storage_version( $version = null ); /** * Fields settings setter * - * @param array|null $fields + * @param array|null $fields Fields. * @return mixed */ - abstract public function setFields( $fields = null ); + abstract public function set_fields( $fields = null ); /** * Method to save fields settings into the storage collector * * @return mixed */ - abstract public function saveFieldsData(); + abstract public function save_fields_data(); /** * Fieldsets settings setter * - * @param array|null $fields + * @param array|null $fieldsets Fieldsets. * @return mixed */ - abstract public function setFieldsets( $fieldsets = null ); + abstract public function set_fieldsets( $fieldsets = null ); /** * Method to save fieldsets settings into the storage collector * * @return mixed */ - abstract public function saveFieldsetsData(); + abstract public function save_fieldsets_data(); } diff --git a/core/DataLayerFactory.php b/core/DataLayerFactory.php index 9d69b19..dcd0cc7 100755 --- a/core/DataLayerFactory.php +++ b/core/DataLayerFactory.php @@ -8,22 +8,21 @@ * Class DataLayerFactory * Factory to create DataLater object based on plugin settings */ -class DataLayerFactory -{ +class DataLayerFactory { /** * Create data layer object - * @param string $source_type database|fs_theme|fs_global / similar to models\Settings::CONF_SOURCE_* + * + * @param string $source_type database|fs_theme|fs_global / similar to models\Settings::CONF_SOURCE_*. * @return \jcf\core\DataLayer */ - public static function create( $source_type = null ) - { - if ( is_null($source_type) ) { - $source_type = models\Settings::getDataSourceType(); + public static function create( $source_type = null ) { + if ( is_null( $source_type ) ) { + $source_type = models\Settings::get_data_source_type(); } - $layer_class = ($source_type == models\Settings::CONF_SOURCE_DB) ? 'DBDataLayer' : 'FilesDataLayer'; + $layer_class = ( models\Settings::CONF_SOURCE_DB === $source_type ) ? 'DBDataLayer' : 'FilesDataLayer'; $layer_class = '\\jcf\\models\\' . $layer_class; + return new $layer_class(); } - } diff --git a/core/JustField.php b/core/JustField.php index 05f5eea..f3ee4dc 100644 --- a/core/JustField.php +++ b/core/JustField.php @@ -5,8 +5,10 @@ use jcf\models; use jcf\core; -class JustField -{ +/** + * Class JustField + */ +class JustField { const POSTTYPE_KIND_PREFIX_TAXONOMY = 'TAX_'; const POSTTYPE_KIND_PREFIX_POST = ''; @@ -15,135 +17,209 @@ class JustField /** * Root id for all fields of this type (field type) + * * @var string */ public $id_base; - public static $compatibility = '3.0+'; // compatibility with WP version + it >=, - it < - public $title; // Name for this field type. + + /** + * Compatibility with WP version + it >=, - it < + * + * @var string + */ + public static $compatibility = '3.0+'; + + /** + * Name for this field type + * + * @var string + */ + public $title; + + /** + * Slug for this field type. + * + * @var string + */ public $slug = null; + + /** + * Field options for this field type. + * + * @var array + */ public $field_options = array( 'classname' => 'jcf_custom_field', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '' + 'after_title' => ':', ); - public $isNew = false; /** - * check for change field name if it edit on post edit page + * Root id for all fields of this type (field type) + * + * @var string + */ + public $is_new = false; + + /** + * Check for change field name if it edit on post edit page + * + * @var bool */ - public $isPostEdit = false; + public $is_post_edit = false; /** * Unique ID number of the current instance - * - * @var integer + * + * @var integer */ public $number = false; /** * Unique ID string of the current instance (id_base-number) - * + * * @var string */ public $id = false; - public $fieldsetId = ''; - public $collectionId = ''; - public $postType; - public $postTypeKind = 'post'; /** - * this is field settings (like title, slug etc) - * + * Unique fieldset ID string of the current instance (id_base-number) + * + * @var string + */ + public $fieldset_id = ''; + + /** + * Unique collection ID string of the current instance (id_base-number) + * + * @var string + */ + public $collection_id = ''; + + /** + * Post type + * + * @var string + */ + public $post_type; + + /** + * Post type kind + * + * @var string + */ + public $post_type_kind = 'post'; + + /** + * This is field settings (like title, slug etc) + * * @var array */ public $instance = array(); - public $postID = 0; + + /** + * Unique post ID string of the current instance (id_base-number) + * + * @var int + */ + public $post_id = 0; /** * Field data for each post + * * @var mixed */ public $entry = null; - public $fieldErrors = array(); + + /** + * Field errors for each post + * + * @var array + */ + public $field_errors = array(); /** * DataLayer to save instances to * * @var \jcf\core\DataLayer */ - protected $_dL; + protected $_dl; /** * Constructor + * + * @param int $id_base ID base. + * @param string $title Title. + * @param array $field_options Field options. */ - public function __construct( $id_base, $title, $field_options = array() ) - { + public function __construct( $id_base, $title, $field_options = array() ) { $this->id_base = $id_base; $this->title = $title; - $this->field_options = array_merge($this->field_options, $field_options); + $this->field_options = array_merge( $this->field_options, $field_options ); - // init data layer - $this->_dL = DataLayerFactory::create(); + /* init data layer */ + $this->_dl = DataLayerFactory::create(); } /** - * check field compatibility with WP version + * Check field compatibility with WP version + * + * @param string $compatibility Compability. + * @return bool * @deprecated */ - public static function checkCompatibility( $compatibility ) - { + public static function check_compatibility( $compatibility ) { global $wp_version; $operator = '<'; - if ( strpos($compatibility, '+') ) { - $compatibility = substr($compatibility, 0, -1); + if ( strpos( $compatibility, '+' ) ) { + $compatibility = substr( $compatibility, 0, -1 ); $operator = '>='; - } - elseif ( strpos($compatibility, '-') ) { - $compatibility = substr($compatibility, 0, -1); + } elseif ( strpos( $compatibility, '-' ) ) { + $compatibility = substr( $compatibility, 0, -1 ); } - if ( !version_compare($wp_version, $compatibility, $operator) ) + if ( ! version_compare( $wp_version, $compatibility, $operator ) ) { return false; + } return true; } /** - * check, that this field is part of collection + * Check, that this field is part of collection */ - public function isCollectionField() - { - if ( !empty($this->collectionId) ) + public function is_collection_field() { + if ( ! empty( $this->collection_id ) ) { return true; + } return false; } /** * Check if this field is created for taxonomy. */ - public function isTaxonomyField() - { - return ( self::POSTTYPE_KIND_TAXONOMY === $this->postTypeKind ); + public function is_taxonomy_field() { + return ( self::POSTTYPE_KIND_TAXONOMY === $this->post_type_kind ); } /** - * set class property $this->fieldsetId - * @param string $fieldset_id fieldset string ID + * Set class property $this->fieldset_id + * + * @param string $fieldset_id fieldset string ID. */ - public function setFieldset( $fieldset_id ) - { - $this->fieldsetId = $fieldset_id; + public function set_fieldset( $fieldset_id ) { + $this->fieldset_id = $fieldset_id; } /** - * set class property $this->collectionId - * @param string $fieldset_id fieldset string ID + * Set class property $this->collection_id + * + * @param string $collection_id fieldset string ID. */ - public function setCollection( $collection_id ) - { - $this->collectionId = $collection_id; + public function set_collection( $collection_id ) { + $this->collection_id = $collection_id; } /** @@ -158,16 +234,16 @@ public function setId( $id ) // this is add request. so number is 0 if ( $this->id == $this->id_base ) { $this->number = 0; - $this->isNew = true; + $this->is_new = true; } // parse number else { $this->number = str_replace($this->id_base . '-', '', $this->id); // load instance data - $fields = $this->_dL->get_fields(); - if ( isset($fields[$this->postType][$this->id]) ) - $this->instance = (array) $fields[$this->postType][$this->id]; + $fields = $this->_dl->get_fields(); + if ( isset($fields[$this->post_type][$this->id]) ) + $this->instance = (array) $fields[$this->post_type][$this->id]; if ( !empty($this->instance) ) { $this->slug = $this->instance['slug']; @@ -191,19 +267,19 @@ public function setSlug( $slug ) * set post ID and load entry from wp-postmeta * @param int $post_ID post ID variable */ - public function set_post_id( $post_ID, $key_from_collection = FALSE ) + public function setPostID( $post_ID, $key_from_collection = FALSE ) { - $this->postID = $post_ID; + $this->post_id = $post_ID; - if ( !empty($this->collectionId) ) { + if ( !empty($this->collection_id) ) { // load entry if ( !empty($this->slug) ) { - $fields = $this->_dL->get_fields(); - if ( empty($fields[$this->postType][$this->collectionId]) ) + $fields = $this->_dl->get_fields(); + if ( empty($fields[$this->post_type][$this->collection_id]) ) return; - $collection_slug = $fields[$this->postType][$this->collectionId]['slug']; - $data = $this->get_meta_data($this->postID, $collection_slug, true); + $collection_slug = $fields[$this->post_type][$this->collection_id]['slug']; + $data = $this->get_meta_data($this->post_id, $collection_slug, true); if ( isset($data[$key_from_collection][$this->slug]) ) { $this->entry = $data[$key_from_collection][$this->slug]; @@ -213,13 +289,13 @@ public function set_post_id( $post_ID, $key_from_collection = FALSE ) else { // load entry if ( !empty($this->slug) ) { - $this->entry = $this->get_meta_data($this->postID, $this->slug, true); + $this->entry = $this->get_meta_data($this->post_id, $this->slug, true); } } } /** - * Get meta data from post or term based on current postTypeKind + * Get meta data from post or term based on current post_type_kind * * @param int $object_id Post or Term ID * @param string $meta_key Meta data key (identifier) @@ -229,26 +305,26 @@ public function set_post_id( $post_ID, $key_from_collection = FALSE ) */ public function get_meta_data($object_id, $meta_key, $single = false) { - if ( self::POSTTYPE_KIND_POST == $this->postTypeKind ) { + if ( self::POSTTYPE_KIND_POST == $this->post_type_kind ) { return get_post_meta($object_id, $meta_key, $single); - } elseif ( self::POSTTYPE_KIND_TAXONOMY == $this->postTypeKind ) { + } elseif ( self::POSTTYPE_KIND_TAXONOMY == $this->post_type_kind ) { return get_term_meta($object_id, $meta_key, $single); } else { return null; } } - + /** * Set post type * @param string $post_type */ public function setPostType( $post_type ) { - $this->postType = $post_type; - if ( 0 === strpos($this->postType, self::POSTTYPE_KIND_PREFIX_TAXONOMY) ) { - $this->postTypeKind = self::POSTTYPE_KIND_TAXONOMY; + $this->post_type = $post_type; + if ( 0 === strpos($this->post_type, self::POSTTYPE_KIND_PREFIX_TAXONOMY) ) { + $this->post_type_kind = self::POSTTYPE_KIND_TAXONOMY; } else { - $this->postTypeKind = self::POSTTYPE_KIND_POST; + $this->post_type_kind = self::POSTTYPE_KIND_POST; } } @@ -263,17 +339,17 @@ public function get_field_id( $str, $delimeter = '-' ) * if is field of collection and itst post edit page create collection field id */ $params = array( - 'post_type' => $this->postType, - 'field_id' => $this->collectionId, - 'fieldset_id' => $this->fieldsetId + 'post_type' => $this->post_type, + 'field_id' => $this->collection_id, + 'fieldset_id' => $this->fieldset_id ); $field_model = new models\Field(); $field_model->load($params); - if ( $this->isCollectionField() && $this->isPostEdit ) { + if ( $this->is_collection_field() && $this->is_post_edit ) { $collection = core\JustFieldFactory::create($field_model); return str_replace('-', $delimeter, 'field' . $delimeter . $collection->id_base . $delimeter . $collection->number . $delimeter - . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . $delimeter . $this->id . $delimeter . $str); + . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . $delimeter . $this->id . $delimeter . $str); } return 'field' . $delimeter . $this->id_base . $delimeter . $this->number . $delimeter . $str; } @@ -289,14 +365,14 @@ public function get_field_name( $str ) * if is field of collection and itst post edit page create collection field name */ $params = array( - 'post_type' => $this->postType, - 'field_id' => $this->collectionId, - 'fieldset_id' => $this->fieldsetId + 'post_type' => $this->post_type, + 'field_id' => $this->collection_id, + 'fieldset_id' => $this->fieldset_id ); $field_model = new models\Field(); $field_model->load($params); - if ( $this->isCollectionField() && $this->isPostEdit ) { + if ( $this->is_collection_field() && $this->is_post_edit ) { $collection = core\JustFieldFactory::create($field_model); return 'field-' . $collection->id_base . '[' . $collection->number . '][' . \jcf\components\collection\JustField_Collection::$currentCollectionFieldKey . '][' . $this->id . '][' . $str . ']'; } @@ -323,7 +399,7 @@ public function validateInstanceSlug( $slug ) { $slug = trim($slug); - if ( !empty($slug) && $slug{0} != '_' && !$this->isCollectionField() ) { + if ( !empty($slug) && $slug{0} != '_' && !$this->is_collection_field() ) { $slug = '_' . $slug; } return $slug; @@ -372,7 +448,7 @@ public function doUpdate( $field_index, $params = null ) $instance['group_title'] = (int) @$input['group_title']; // starting from vers. 1.4 all new fields should be marked with version of the plugin - if ( $this->isNew ) { + if ( $this->is_new ) { $instance['_version'] = \JustCustomFields::VERSION; } // for old records: set 1.34 - last version without versioning the fields @@ -386,12 +462,12 @@ public function doUpdate( $field_index, $params = null ) // check for errors // IMPORTANT: experimental function - if ( !empty($this->fieldErrors) ) { - $errors = implode('\n', $this->fieldErrors); + if ( !empty($this->field_errors) ) { + $errors = implode('\n', $this->field_errors); return array( 'status' => '0', 'error' => $errors ); } - if ( $this->isNew ) { + if ( $this->is_new ) { $this->number = $field_index; $this->id = $this->id_base . '-' . $this->number; } @@ -401,16 +477,16 @@ public function doUpdate( $field_index, $params = null ) $instance['slug'] = '_field_' . $this->id_base . '__' . $this->number; } - $fields = $this->_dL->get_fields(); + $fields = $this->_dl->get_fields(); - if ( !$this->isCollectionField() ) { + if ( !$this->is_collection_field() ) { // update fieldset - $fieldsets = $this->_dL->get_fieldsets(); - $fieldsets[$this->postType][$this->fieldsetId]['fields'][$this->id] = $instance['enabled']; - $this->_dL->setFieldsets($fieldsets); - $this->_dL->saveFieldsetsData(); + $fieldsets = $this->_dl->get_fieldsets(); + $fieldsets[$this->post_type][$this->fieldset_id]['fields'][$this->id] = $instance['enabled']; + $this->_dl->set_fieldsets($fieldsets); + $this->_dl->save_fieldsets_data(); - $fields[$this->postType][$this->id] = $instance; + $fields[$this->post_type][$this->id] = $instance; } else { $instance['field_width'] = $input['field_width']; @@ -418,11 +494,11 @@ public function doUpdate( $field_index, $params = null ) if ( isset($input['group_title']) ) $instance['group_title'] = true; - $fields[$this->postType][$this->collectionId]['fields'][$this->id] = $instance; + $fields[$this->post_type][$this->collection_id]['fields'][$this->id] = $instance; } - $this->_dL->setFields($fields); - if ( !$this->_dL->saveFieldsData() ) { + $this->_dl->set_fields($fields); + if ( !$this->_dl->save_fields_data() ) { return array( 'status' => 0, 'error' => __('Unable to write changes to storage.', \JustCustomFields::TEXTDOMAIN) @@ -434,9 +510,9 @@ public function doUpdate( $field_index, $params = null ) 'status' => '1', 'id' => $this->id, 'id_base' => $this->id_base, - 'fieldset_id' => $this->fieldsetId, - 'collection_id' => $this->collectionId, - 'is_new' => $this->isNew, + 'fieldset_id' => $this->fieldset_id, + 'collection_id' => $this->collection_id, + 'is_new' => $this->is_new, 'instance' => $instance ); return $res; @@ -448,22 +524,22 @@ public function doUpdate( $field_index, $params = null ) */ public function doDelete() { - $fields = $this->_dL->get_fields(); + $fields = $this->_dl->get_fields(); - if ( !empty($this->collectionId) ) { - unset($fields[$this->postType][$this->collectionId]['fields'][$this->id]); + if ( !empty($this->collection_id) ) { + unset($fields[$this->post_type][$this->collection_id]['fields'][$this->id]); } else { - $fieldsets = $this->_dL->get_fieldsets(); - unset($fieldsets[$this->postType][$this->fieldsetId]['fields'][$this->id]); - unset($fields[$this->postType][$this->id]); + $fieldsets = $this->_dl->get_fieldsets(); + unset($fieldsets[$this->post_type][$this->fieldset_id]['fields'][$this->id]); + unset($fields[$this->post_type][$this->id]); - $this->_dL->setFieldsets($fieldsets); - $this->_dL->saveFieldsetsData(); + $this->_dl->set_fieldsets($fieldsets); + $this->_dl->save_fieldsets_data(); } - $this->_dL->setFields($fields); - if ( !$this->_dL->saveFieldsData() ) { + $this->_dl->set_fields($fields); + if ( !$this->_dl->save_fields_data() ) { return false; } @@ -479,14 +555,14 @@ public function doDelete() public function do_save() { // check that number and post_ID is set - if ( empty($this->postID) || empty($this->number) ) + if ( empty($this->post_id) || empty($this->number) ) return false; // check that we have data in POST if ( $this->id_base != 'checkbox' && ( empty($_POST['field-' . $this->id_base][$this->number]) || !is_array($_POST['field-' . $this->id_base][$this->number]) - ) + ) ) { return false; } @@ -496,13 +572,13 @@ public function do_save() // get real values $values = $this->save($input); // save to post meta - $this->update_meta_data($this->postID, $this->slug, $values); + $this->update_meta_data($this->post_id, $this->slug, $values); return true; } /** - * Update meta data for post or term based on current postTypeKind + * Update meta data for post or term based on current post_type_kind * * @param int $object_id Post or Term ID * @param string $meta_key Meta data key (identifier) @@ -512,15 +588,15 @@ public function do_save() */ public function update_meta_data($object_id, $meta_key, $meta_value) { - if ( self::POSTTYPE_KIND_POST == $this->postTypeKind ) { + if ( self::POSTTYPE_KIND_POST == $this->post_type_kind ) { return update_post_meta($object_id, $meta_key, $meta_value); - } elseif ( self::POSTTYPE_KIND_TAXONOMY == $this->postTypeKind ) { + } elseif ( self::POSTTYPE_KIND_TAXONOMY == $this->post_type_kind ) { return update_term_meta($object_id, $meta_key, $meta_value); } else { return null; } } - + /** * method that call $this->add_js to enqueue scripts in head section * do this only on post edit page and if at least one field is exists. @@ -599,7 +675,7 @@ public function form() /** * Print shortcode - * + * * @param array $args shortcode attributes * @return string */ @@ -611,7 +687,7 @@ public function doShortcode( $args ) 'field' => '', 'post_id' => '', 'label' => false, - ), $args); + ), $args); $class_names = array( "jcf-value", @@ -646,7 +722,7 @@ public function doShortcode( $args ) /** * Print field label inside shortcode call - * + * * @param array $args shortcode args * @return string */ @@ -657,7 +733,7 @@ public function shortcodeLabel( $args ) /** * Print fields values from shortcode - * + * * @param array $args shortcode args * @return string */ diff --git a/core/JustFieldFactory.php b/core/JustFieldFactory.php index 36c1a4b..2e861d9 100644 --- a/core/JustFieldFactory.php +++ b/core/JustFieldFactory.php @@ -31,14 +31,14 @@ public static function create( \jcf\models\Field $field ) $model = new $field_info['class'](); $model->setPostType($field->post_type); - $model->setFieldset($field->fieldset_id); - $model->setCollection($field->collection_id); + $model->set_fieldset($field->fieldset_id); + $model->set_collection($field->collection_id); $model->setId($field_mixed); - if ( !$model->isNew && $field->collection_id ) { + if ( !$model->is_new && $field->collection_id ) { $collection = new \jcf\components\collection\JustField_Collection(); $collection->setPostType($field->post_type); - $collection->setFieldset($field->fieldset_id); + $collection->set_fieldset($field->fieldset_id); $collection->setId($field->collection_id); $field_instance = $collection->instance['fields'][$field_mixed]; diff --git a/core/Migration.php b/core/Migration.php index e81f532..047887d 100644 --- a/core/Migration.php +++ b/core/Migration.php @@ -51,7 +51,7 @@ abstract class Migration */ public function __construct() { - $this->_data_source = Settings::getDataSourceType(); + $this->_data_source = Settings::get_data_source_type(); $this->_network_mode = Settings::getNetworkMode(); } diff --git a/core/Model.php b/core/Model.php index e31e7cc..7febee8 100755 --- a/core/Model.php +++ b/core/Model.php @@ -25,7 +25,7 @@ class Model /** * @var \jcf\models\DataLayer */ - protected $_dL; + protected $_dl; /** * Model constructor. @@ -33,7 +33,7 @@ class Model */ public function __construct() { - $this->_dL = DataLayerFactory::create(); + $this->_dl = DataLayerFactory::create(); } /** @@ -136,6 +136,6 @@ public function setAttributes( $params ) */ public function get_storage_version() { - return $this->_dL->getStorageVersion(); + return $this->_dl->get_storage_version(); } } diff --git a/core/PluginLoader.php b/core/PluginLoader.php index 15b4a92..c71a271 100644 --- a/core/PluginLoader.php +++ b/core/PluginLoader.php @@ -15,14 +15,14 @@ class PluginLoader /** * @var DataLayer */ - private $_dL; + private $_dl; /** * PluginLoader constructor. */ public function __construct() { - $this->_dL = DataLayerFactory::create(); + $this->_dl = DataLayerFactory::create(); } /** @@ -36,7 +36,7 @@ public function check_migrations_available() // if we can't define version at all - it seems to be a new installation. just write current version if ( empty($version) ) { - $this->_dL->saveStorageVersion(); + $this->_dl->save_storage_version(); return false; } @@ -60,7 +60,7 @@ public function check_migrations_available() */ public function getStorageVersion() { - if ( ! $version = $this->_dL->getStorageVersion() ) { + if ( ! $version = $this->_dl->get_storage_version() ) { $version = Migrate::guessVersion(); } diff --git a/models/DBDataLayer.php b/models/DBDataLayer.php index 6197bb9..4522fac 100755 --- a/models/DBDataLayer.php +++ b/models/DBDataLayer.php @@ -39,7 +39,7 @@ public function __construct() * Setter/Init for $this->_fields property * @param array $fields */ - public function setFields( $fields = null ) + public function set_fields( $fields = null ) { if ( !is_null($fields) ) { $this->_fields = $fields; @@ -52,7 +52,7 @@ public function setFields( $fields = null ) /** * Update fields in wp-options or wp-site-options table */ - public function saveFieldsData() + public function save_fields_data() { return $this->_updateOptions(self::FIELDS_OPTION, $this->_fields); } @@ -61,7 +61,7 @@ public function saveFieldsData() * Setter/Init for Fieldsets * @param array $fieldsets */ - public function setFieldsets( $fieldsets = null ) + public function set_fieldsets( $fieldsets = null ) { if ( !is_null($fieldsets) ) { $this->_fieldsets = $fieldsets; @@ -74,7 +74,7 @@ public function setFieldsets( $fieldsets = null ) /** * Save fieldsets */ - public function saveFieldsetsData() + public function save_fieldsets_data() { return $this->_updateOptions(self::FIELDSETS_OPTION, $this->_fieldsets); } @@ -83,7 +83,7 @@ public function saveFieldsetsData() * Get storage version * @return array */ - public function getStorageVersion() + public function get_storage_version() { return $this->_getOptions( self::STORAGEVER_OPTION, '' ); } @@ -93,7 +93,7 @@ public function getStorageVersion() * @param float|null $version * @return boolean */ - public function saveStorageVersion($version = null) + public function save_storage_version($version = null) { if ( empty($version) ) { $version = \JustCustomFields::VERSION; diff --git a/models/Field.php b/models/Field.php index 0bae3d4..69e8388 100644 --- a/models/Field.php +++ b/models/Field.php @@ -21,7 +21,7 @@ class Field extends core\Model */ public function findAll() { - return $this->_dL->get_fields(); + return $this->_dl->get_fields(); } /** @@ -31,7 +31,7 @@ public function findAll() */ public function find_by_post_type( $post_type ) { - $fields = $this->_dL->get_fields(); + $fields = $this->_dl->get_fields(); if ( !empty($fields[$post_type]) ) return $fields[$post_type]; @@ -45,7 +45,7 @@ public function find_by_post_type( $post_type ) */ public function find_collections_by_post_type( $post_type ) { - $fields = $this->_dL->get_fields(); + $fields = $this->_dl->get_fields(); $collections = array(); if ( !empty($fields[$post_type]) ) { @@ -88,7 +88,7 @@ public function delete() public function sort() { $order = trim($this->fields_order, ','); - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); $new_fields = explode(',', $order); $fieldsets[$this->post_type][$this->fieldset_id]['fields'] = array(); @@ -96,9 +96,9 @@ public function sort() $fieldsets[$this->post_type][$this->fieldset_id]['fields'][$field_id] = $field_id; } - $this->_dL->setFieldsets($fieldsets); + $this->_dl->set_fieldsets($fieldsets); - if ( !$this->_dL->saveFieldsetsData() ) { + if ( !$this->_dl->save_fieldsets_data() ) { $this->addError(__('Sorting isn\'t changed.', \JustCustomFields::TEXTDOMAIN)); return false; } @@ -112,7 +112,7 @@ public function sort() */ public function sortCollection() { - $fields = $this->_dL->get_fields(); + $fields = $this->_dl->get_fields(); $order = trim($this->fields_order, ','); $new_sort = explode(',', $order); $new_fields = array(); @@ -126,9 +126,9 @@ public function sortCollection() } $fields[$this->post_type][$this->collection_id]['fields'] = $new_fields; - $this->_dL->setFields($fields); + $this->_dl->set_fields($fields); - if ( !$this->_dL->saveFieldsData() ) { + if ( !$this->_dl->save_fields_data() ) { $this->addError(__('Sorting isn\'t changed.', \JustCustomFields::TEXTDOMAIN)); return false; } diff --git a/models/Fieldset.php b/models/Fieldset.php index 2b85aec..399c49f 100755 --- a/models/Fieldset.php +++ b/models/Fieldset.php @@ -28,8 +28,8 @@ class Fieldset extends core\Model */ public function get_fields_counter() { - $fields = $this->_dL->get_fields(); - $fieldsets = $this->_dL->get_fieldsets(); + $fields = $this->_dl->get_fields(); + $fieldsets = $this->_dl->get_fieldsets(); $post_types = jcf_get_post_types(); $taxonomies = jcf_get_taxonomies(); @@ -87,7 +87,7 @@ public function get_fields_counter() */ public function find_by_post_type( $post_type ) { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); if ( !empty($fieldsets[$post_type]) ) return $fieldsets[$post_type]; @@ -100,7 +100,7 @@ public function find_by_post_type( $post_type ) */ public function findAll() { - return $this->_dL->get_fieldsets(); + return $this->_dl->get_fieldsets(); } /** @@ -110,7 +110,7 @@ public function findAll() */ public function find_by_id( $fieldset_id ) { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); if ( empty($fieldsets[$this->post_type][$fieldset_id]) ) { $this->addError(__('Fieldset not found', \JustCustomFields::TEXTDOMAIN)); return false; @@ -131,7 +131,7 @@ public function create() $slug = $this->createSlug(); - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); // check exists if ( isset($fieldsets[$this->post_type][$slug]) ) { @@ -161,7 +161,7 @@ public function delete() return false; } - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); if ( isset($fieldsets[$this->post_type][$this->fieldset_id]) ) unset($fieldsets[$this->post_type][$this->fieldset_id]); @@ -174,7 +174,7 @@ public function delete() */ public function update() { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); if ( empty($fieldsets[$this->post_type][$this->fieldset_id]) ) { $this->addError(__('Wrong data passed.', \JustCustomFields::TEXTDOMAIN)); @@ -200,7 +200,7 @@ public function update() public function sort() { $sort = explode(',', trim($this->fieldsets_order, ',')); - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); $ordered_fieldsets = array(); foreach ( $sort as $key ) { @@ -242,8 +242,8 @@ public function createSlug() */ protected function _save( $fieldsets ) { - $this->_dL->setFieldsets($fieldsets); - $save = $this->_dL->saveFieldsetsData(); + $this->_dl->set_fieldsets($fieldsets); + $save = $this->_dl->save_fieldsets_data(); return !empty($save); } diff --git a/models/FieldsetVisibility.php b/models/FieldsetVisibility.php index 7c4a6d7..ab7fd7b 100644 --- a/models/FieldsetVisibility.php +++ b/models/FieldsetVisibility.php @@ -36,7 +36,7 @@ class FieldsetVisibility extends core\Model */ public function find_by_post_type($post_type) { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); $visibility_rules = array(); if ( empty($fieldsets[$post_type]) ) return; @@ -212,7 +212,7 @@ public static function find_taxonomy_terms($taxonomy, $term) */ protected function _get_fieldset_visibility( $fieldset_id, $rule_id = null ) { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); // if we take only fieldset settings - return it if ( is_null($rule_id) ) { @@ -239,7 +239,7 @@ protected function _get_fieldset_visibility( $fieldset_id, $rule_id = null ) */ protected function _saveFieldsetVisibility( $fieldset_id, $rules ) { - $fieldsets = $this->_dL->get_fieldsets(); + $fieldsets = $this->_dl->get_fieldsets(); $fieldsets[$this->post_type][$fieldset_id]['visibility_rules'] = $rules; return $this->_save($fieldsets); } @@ -252,8 +252,8 @@ protected function _saveFieldsetVisibility( $fieldset_id, $rules ) */ protected function _save( $fieldsets ) { - $this->_dL->setFieldsets($fieldsets); - $saved = $this->_dL->saveFieldsetsData(); + $this->_dl->set_fieldsets($fieldsets); + $saved = $this->_dl->save_fieldsets_data(); return !empty($saved); } diff --git a/models/FilesDataLayer.php b/models/FilesDataLayer.php index b67c94e..ea7a4c2 100755 --- a/models/FilesDataLayer.php +++ b/models/FilesDataLayer.php @@ -21,7 +21,7 @@ class FilesDataLayer extends core\DataLayer */ public function __construct() { - $this->_sourceSettings = models\Settings::getDataSourceType(); + $this->_sourceSettings = models\Settings::get_data_source_type(); parent::__construct(); } @@ -30,7 +30,7 @@ public function __construct() * Set $this->_fields property * @param array $fields */ - public function setFields( $fields = null ) + public function set_fields( $fields = null ) { if ( !is_null($fields) ) { $this->_fields = $fields; @@ -47,7 +47,7 @@ public function setFields( $fields = null ) * Update fields * @return boolean */ - public function saveFieldsData() + public function save_fields_data() { $data = $this->getDataFromFile(); $data[self::FIELDS_KEY] = $this->_fields; @@ -58,7 +58,7 @@ public function saveFieldsData() * Get storage version * @return array */ - public function getStorageVersion() + public function get_storage_version() { $data = $this->getDataFromFile(); return !empty($data[self::STORAGEVER_KEY]) ? $data[self::STORAGEVER_KEY] : false; @@ -69,7 +69,7 @@ public function getStorageVersion() * @param float|null $version * @return boolean */ - public function saveStorageVersion($version = null) + public function save_storage_version($version = null) { $data = $this->getDataFromFile(); @@ -86,7 +86,7 @@ public function saveStorageVersion($version = null) * Get Fieldsets * @param array $fieldsets */ - public function setFieldsets( $fieldsets = null ) + public function set_fieldsets( $fieldsets = null ) { if ( !is_null($fieldsets) ) { $this->_fieldsets = $fieldsets; @@ -103,7 +103,7 @@ public function setFieldsets( $fieldsets = null ) * Save fieldsets * @return boolean */ - public function saveFieldsetsData() + public function save_fieldsets_data() { $data = $this->getDataFromFile(); $data[self::FIELDSETS_KEY] = $this->_fieldsets; diff --git a/models/ImportExport.php b/models/ImportExport.php index 950b822..3d0ca23 100644 --- a/models/ImportExport.php +++ b/models/ImportExport.php @@ -19,10 +19,10 @@ public function get_import_fields() { if ( $this->action != 'jcf_import_fields_form' || !$this->validateImportFile() ) return; - /* @var $files_dL FilesDataLayer */ + /* @var $files_dl FilesDataLayer */ $import_file = $_FILES['import_data']['tmp_name']; - $files_dL = core\DataLayerFactory::create('file'); - $data = $files_dL->getDataFromFile( $import_file ); + $files_dl = core\DataLayerFactory::create('file'); + $data = $files_dl->getDataFromFile( $import_file ); unlink($import_file); if ( empty($data['post_types']) ) { @@ -74,8 +74,8 @@ public function import() { if ( $this->action != 'jcf_import_fields' || empty($this->selected_data) || empty($this->import_source) ) return; - $dl_fields = $this->_dL->get_fields(); - $dl_fieldsets = $this->_dL->get_fieldsets(); + $dl_fields = $this->_dl->get_fields(); + $dl_fieldsets = $this->_dl->get_fieldsets(); // we take origin import source and remove elements which are not selected $import_source = json_decode(stripslashes($this->import_source), true); @@ -124,9 +124,9 @@ public function import() } // save to data layer - $this->_dL->setFields($dl_fields); - $this->_dL->setFieldsets($dl_fieldsets); - $import_status = $this->_dL->saveFieldsData() && $this->_dL->saveFieldsetsData(); + $this->_dl->set_fields($dl_fields); + $this->_dl->set_fieldsets($dl_fieldsets); + $import_status = $this->_dl->save_fields_data() && $this->_dl->save_fieldsets_data(); if ( $import_status ) { $this->addMessage(__('Import has been completed successfully!', \JustCustomFields::TEXTDOMAIN)); diff --git a/models/Migrate.php b/models/Migrate.php index f2b435c..be9c8f6 100644 --- a/models/Migrate.php +++ b/models/Migrate.php @@ -37,7 +37,7 @@ public static function adminUpgradeNotice() */ public function find_migrations() { - $version = $this->_dL->getStorageVersion(); + $version = $this->_dl->get_storage_version(); if ( ! $version ) { $version = self::guessVersion(); } @@ -130,9 +130,9 @@ public function migrate($migrations) $fields = $this->_updateFieldsVersion($fields); - $this->_dL->setFields($fields); - $this->_dL->setFieldsets($fieldsets); - $updated = $this->_dL->saveFieldsData() && $this->_dL->saveFieldsetsData(); + $this->_dl->set_fields($fields); + $this->_dl->set_fieldsets($fieldsets); + $updated = $this->_dl->save_fields_data() && $this->_dl->save_fieldsets_data(); } else { $migrations = array(); @@ -141,7 +141,7 @@ public function migrate($migrations) // do cleanup if ( $updated ) { - $this->_dL->saveStorageVersion(); + $this->_dl->save_storage_version(); foreach ($migrations as $ver => $m) { $m->runCleanup(); } @@ -161,11 +161,11 @@ public function migrate($migrations) */ public function is_storage_writable() { - $data_source = Settings::getDataSourceType(); + $data_source = Settings::get_data_source_type(); // if we use filesystem we need to know it's writable if ( $data_source !== Settings::CONF_SOURCE_DB ) { - $filepath = $this->_dL->getConfigFilePath(); + $filepath = $this->_dl->getConfigFilePath(); $filedir = dirname($filepath); if ( (!is_dir($filedir) && !wp_mkdir_p($filedir)) || !wp_is_writable($filedir) ) { $this->addError('Error! Please check that settings directory is writable "' . dirname($filepath) . '"'); @@ -215,7 +215,7 @@ public function _updateFieldsVersion($fields_data) public static function guessVersion() { // check data source key exists. in v2.3 it was different key - if ( ! $data_source = Settings::getDataSourceType( '' ) ) { + if ( ! $data_source = Settings::get_data_source_type( '' ) ) { $data_source = get_site_option('jcf_read_settings', Settings::CONF_SOURCE_DB); update_site_option(Settings::OPT_SOURCE, $data_source); } @@ -252,7 +252,7 @@ public static function guessFields() } // we can't find the fields now we should try to search them manually - $data_source = Settings::getDataSourceType(); + $data_source = Settings::get_data_source_type(); $network_mode = Settings::getNetworkMode(); $post_types = jcf_get_post_types(); diff --git a/models/Settings.php b/models/Settings.php index 3c514b6..67924f0 100755 --- a/models/Settings.php +++ b/models/Settings.php @@ -28,7 +28,7 @@ class Settings extends core\Model * @param string $default * @return string */ - public static function getDataSourceType( $default = null ) + public static function get_data_source_type( $default = null ) { if ( is_null($default) ) { $default = self::CONF_SOURCE_DB; diff --git a/models/Shortcodes.php b/models/Shortcodes.php index fd880de..15133a2 100755 --- a/models/Shortcodes.php +++ b/models/Shortcodes.php @@ -24,7 +24,7 @@ protected function _initShortcode( $args ) //get post type $post_type = get_post_type($post_id); //get field settings - $field_settings = $this->_dL->get_fields(); + $field_settings = $this->_dl->get_fields(); if ( empty($field_settings[$post_type]) ) return false; @@ -43,7 +43,7 @@ protected function _initShortcode( $args ) $field_obj = core\JustFieldFactory::create($field_model); if ( !$field_obj ) return false; - $field_obj->set_post_id($post_id); + $field_obj->setPostId($post_id); unset($args['field']); return $field_obj->doShortcode($args); diff --git a/views/fields/form.php b/views/fields/form.php index 2097060..4128e78 100644 --- a/views/fields/form.php +++ b/views/fields/form.php @@ -4,14 +4,14 @@

title; ?>

-
+
- - isCollectionField() ) : ?> - + + is_collection_field() ) : ?> + form(); @@ -25,7 +25,7 @@

isNew ){ + if( $field->is_new ){ $field->instance['enabled'] = 1; } ?> @@ -37,7 +37,7 @@ value="1" instance['enabled']); ?> />

- isCollectionField()) : ?> + is_collection_field()) : ?> id_base == 'inputtext') : ?>


From 9e4cb0c1f3ff5d918ac2aa06021f1433c3519f44 Mon Sep 17 00:00:00 2001 From: evkos Date: Tue, 13 Jun 2017 11:20:34 +0300 Subject: [PATCH 07/16] correct ajax error --- assets/edit_post.js | 6 +- assets/just_custom_fields.js | 26 +- components/collection/assets/collection.js | 10 +- .../collection/assets/collection_post_edit.js | 2 +- .../googlemaps/JustField_GoogleMaps.php | 2 +- components/googlemaps/assets/googlemaps.js | 4 +- components/relatedcontent/related-content.js | 2 +- .../simplemedia/assets/simplemedia-modal.js | 6 +- components/table/table.js | 2 +- controllers/AdminController.php | 31 +- controllers/FieldController.php | 41 +- controllers/FieldsetController.php | 109 +++-- controllers/ImportExportController.php | 28 +- controllers/MigrateController.php | 10 +- controllers/PostTypeController.php | 62 +-- controllers/SettingsController.php | 25 +- controllers/TaxonomyController.php | 57 +-- core/JustField.php | 377 +++++++++--------- core/Model.php | 82 ++-- 19 files changed, 491 insertions(+), 391 deletions(-) diff --git a/assets/edit_post.js b/assets/edit_post.js index 4cb767b..cc51c06 100755 --- a/assets/edit_post.js +++ b/assets/edit_post.js @@ -228,7 +228,7 @@ function jcf_do_action(action, _this) { } //console.log({tags: selected_tags, categories: selected_cats, page_tpl: selected_page_template}); - } + }; /** * Check if rule settings match the real situation on screen @@ -294,7 +294,7 @@ function jcf_do_action(action, _this) { var taxonomy = $(this).attr('id').replace('tax-input-', ''); var tags = tags.split(','); selected[taxonomy] = tags; - }) + }); return selected; } @@ -319,7 +319,7 @@ function jcf_do_action(action, _this) { selected[taxonomy] = []; selected[taxonomy].push(term); - }) + }); return selected; } diff --git a/assets/just_custom_fields.js b/assets/just_custom_fields.js index 242a27e..abe68de 100755 --- a/assets/just_custom_fields.js +++ b/assets/just_custom_fields.js @@ -74,7 +74,7 @@ function initFieldsetsEdit() { jcf_hide_ajax_container(); }); } - }) + }); // change jQuery('#jcf_fieldsets a.jcf_fieldset_change').click(function(e) { @@ -89,7 +89,7 @@ function initFieldsetsEdit() { jcf_ajax(data, 'html', null, function( response ) { jcf_show_ajax_container(response); }); - }) + }); // init delete button on change popup jQuery('#jcf_ajax_content .jcf_edit_fieldset a.field-control-remove').live('click', function() { @@ -198,7 +198,7 @@ function initFieldsetsEdit() { msg_invalid_input = jcf_textdomain.err_fieldset_visibility_invalid_page; } alert( msg_invalid_input ); - return; + }); // add form for new visibility rule @@ -208,7 +208,7 @@ function initFieldsetsEdit() { var data = { 'action': 'jcf_add_visibility_rules_form', 'scenario': 'create' - } + }; jcf_ajax(data, 'html', null, function( response ) { jQuery('div#visibility').append(response); jQuery('.add_rule_btn').hide(); @@ -224,7 +224,7 @@ function initFieldsetsEdit() { 'action': 'jcf_delete_visibility_rule', 'rule_id': rule_id, 'fieldset_id': f_id - } + }; jcf_ajax(data, 'html', null, function( response ) { jQuery('div.rules').remove(); jQuery('div#visibility').append(response); @@ -242,7 +242,7 @@ function initFieldsetsEdit() { 'rule_id': rule_id, 'fieldset_id': f_id, 'scenario': 'update' - } + }; jcf_ajax(data, 'html', null, function( response ) { jQuery('fieldset#fieldset_visibility_rules').remove(); jQuery('div#visibility').append(response); @@ -337,13 +337,13 @@ function initFieldset_fields() { jQuery(this).find('input,select').each(function( i, input ) { data[ jQuery(input).attr('name') ] = jQuery(input).val(); - }) + }); var loader = jQuery(this).find('img.ajax-feedback'); jcf_ajax(data, 'html', loader, function( response ) { jcf_show_ajax_container(response); - }) + }); return false; }); @@ -425,7 +425,7 @@ function initFieldset_fields() { } // close add box at the end jcf_hide_ajax_container(); - }) + }); return false; }); @@ -449,7 +449,7 @@ function initFieldset_fields() { }); } return false; - }) + }); // edit button jQuery('#jcf_fieldsets tbody span.edit a, #jcf_fieldsets tbody strong > a').live('click', function() { @@ -467,7 +467,7 @@ function initFieldset_fields() { }); return false; - }) + }); // delete button in edit form jQuery('#jcform_edit_field a.field-control-remove').live('click', function( e ) { @@ -542,7 +542,7 @@ function initExport() { var data = { 'action': 'jcf_export_fields_form' - } + }; jcf_ajax(data, 'html', null, function( response ) { modalWindow(response); }); @@ -778,7 +778,7 @@ function jcf_form_serialize_object( obj ) { } else if ( jQuery(input).attr('type') == 'checkbox' ) { if ( typeof data[ jQuery(input).attr('name') ] === 'undefined' ) { - data[ jQuery(input).attr('name') ] = new Array(); + data[ jQuery(input).attr('name') ] = []; } if ( jQuery(input).is(':checked') ) { data[ jQuery(input).attr('name') ].push(jQuery(this).val()); diff --git a/components/collection/assets/collection.js b/components/collection/assets/collection.js index d26e726..756a5fe 100755 --- a/components/collection/assets/collection.js +++ b/components/collection/assets/collection.js @@ -15,14 +15,14 @@ function initCollectionFields() { jQuery(this).find('input,select').each(function( i, input ) { data[ jQuery(input).attr('name') ] = jQuery(input).val(); - }) + }); data['fieldset_id'] = jQuery(this).find('input[name=fieldset_id]').val(); var loader = jQuery(this).find('img.ajax-feedback'); jcf_ajax(data, 'html', loader, function( response ) { jcf_show_ajax_container(response); - }) + }); return false; }); @@ -69,7 +69,7 @@ function initCollectionFields() { // close add box at the end jcf_hide_ajax_container(); - }) + }); return false; }); @@ -91,7 +91,7 @@ function initCollectionFields() { }); return false; - }) + }); // delete button jQuery('#jcf_fieldsets tbody span.delete_collection a').live('click', function() { if ( confirm(jcf_textdomain.confirm_field_delete) ) { @@ -112,7 +112,7 @@ function initCollectionFields() { }); } return false; - }) + }); // delete button in edit form jQuery('#jcform_edit_collection_field a.field-control-remove').live('click', function( e ) { diff --git a/components/collection/assets/collection_post_edit.js b/components/collection/assets/collection_post_edit.js index 659d55f..f13d45a 100755 --- a/components/collection/assets/collection_post_edit.js +++ b/components/collection/assets/collection_post_edit.js @@ -63,7 +63,7 @@ function jcf_collection_fields_control() { }); return false; - }) + }); jQuery('div.collection_field_group h3 span.dashicons-trash').live('click', function( e ) { e.preventDefault(); diff --git a/components/googlemaps/JustField_GoogleMaps.php b/components/googlemaps/JustField_GoogleMaps.php index 424fce3..56f651e 100644 --- a/components/googlemaps/JustField_GoogleMaps.php +++ b/components/googlemaps/JustField_GoogleMaps.php @@ -92,7 +92,7 @@ public function field() 'lat': entry['lat']; ?>, 'lng': entry['lng']; ?>, 'markers': [] - }) + }); is_collection_field() && defined('DOING_AJAX') && DOING_AJAX ) : ?> jcf_googlemaps_init_field( window.jcf_googlemaps.length -1 ); diff --git a/components/googlemaps/assets/googlemaps.js b/components/googlemaps/assets/googlemaps.js index 0c8a960..1cfcd51 100644 --- a/components/googlemaps/assets/googlemaps.js +++ b/components/googlemaps/assets/googlemaps.js @@ -63,7 +63,7 @@ function jcf_googlemaps_init_field(i) { jQuery( '#' + jcf_googlemap.address_id ).val(''); return false; - }) + }); // set button document.getElementById( jcf_googlemap.set_btn_id ).addEventListener('click', function (e) { @@ -179,4 +179,4 @@ jQuery(document).ready(function(){ jQuery(this).closest('.form-field').find('.jcf_googlemaps_coordinates').toggle(); }) -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/components/relatedcontent/related-content.js b/components/relatedcontent/related-content.js index 38d9834..ba906a6 100755 --- a/components/relatedcontent/related-content.js +++ b/components/relatedcontent/related-content.js @@ -68,7 +68,7 @@ function jcf_relatedcontent_init() { jcf_relatedcontent_init_sortable(container); return false; - }) + }); function jcf_attach_autocomplete_event( input ) { var post_types = jQuery(input).attr('alt'); diff --git a/components/simplemedia/assets/simplemedia-modal.js b/components/simplemedia/assets/simplemedia-modal.js index dcce0e3..dff8835 100755 --- a/components/simplemedia/assets/simplemedia-modal.js +++ b/components/simplemedia/assets/simplemedia-modal.js @@ -85,7 +85,7 @@ window.JcfSimpleMedia = { row.find('p:first').html(html).removeClass('jcf-hide').show(); row.find('a.jcf_simple_delete').removeClass('jcf-hide').show(); } -} +}; jQuery(document).ready(function() { if ( jQuery('body').hasClass('edit-tags-php') ) { @@ -108,7 +108,7 @@ jQuery(document).ready(function() { // rename upload control row.find('#simplemedia-' + value_id).text( jcf_textdomain.select_image ); // reset image - row.find('.jcf-simple-image a').attr('href', '#') + row.find('.jcf-simple-image a').attr('href', '#'); var img = row.find('.jcf-simple-image img'); img.attr('src', img.data('noimage')); @@ -124,4 +124,4 @@ jQuery(document).ready(function() { row.find('#simplemedia-' + value_id).show(); return false; }); -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/components/table/table.js b/components/table/table.js index 14422b3..98c5b95 100755 --- a/components/table/table.js +++ b/components/table/table.js @@ -18,7 +18,7 @@ jQuery(document).ready(function() { table.find('tr.no-rows').show(); } jQuery(this).parent().parent().remove(); - }) + }); jQuery('table.sortable').each(function() { jQuery(this).find('tbody').sortable({containment: jQuery(this), scroll: false, items: 'tr[class!=table-header]'}); diff --git a/controllers/AdminController.php b/controllers/AdminController.php index 8f0d8e6..a13a70f 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -5,8 +5,10 @@ use jcf\models; use jcf\core; -class AdminController extends core\Controller -{ +/** + * Admin controller + */ +class AdminController extends core\Controller { /** * Init all wp-actions @@ -32,7 +34,7 @@ public function __construct() { */ public function admin_menu() { $page_title = \JustCustomFields::$plugin_name; - $page_slug = \JustCustomFields::$plugin_slug; + $page_slug = \JustCustomFields::$plugin_slug; add_options_page( $page_title, $page_title, 'manage_options', 'jcf_admin', array( $this, 'action_index' ) ); } @@ -41,18 +43,19 @@ public function admin_menu() { * Render index page */ public function action_index() { - $model = new models\Fieldset(); + $model = new models\Fieldset(); $count_fields = $model->get_fields_counter(); - $post_types = jcf_get_post_types( 'object' ); - $taxonomies = jcf_get_taxonomies( 'objects' ); + $post_types = jcf_get_post_types( 'object' ); + $taxonomies = jcf_get_taxonomies( 'objects' ); /*load template*/ - return $this->_render('admin/index', array( - 'tab' => 'fields', - 'post_types' => $post_types, - 'taxonomies' => $taxonomies, - 'count_fields' => $count_fields, - )); + + return $this->_render( 'admin/index', array( + 'tab' => 'fields', + 'post_types' => $post_types, + 'taxonomies' => $taxonomies, + 'count_fields' => $count_fields, + ) ); } /** @@ -95,8 +98,8 @@ public function add_styles() { public function register_edit_assets() { wp_register_script( 'jcf_edit_post', - jcf_plugin_url( 'assets/edit_post.js' ), - array( 'jquery', 'tags-box' ) + jcf_plugin_url( 'assets/edit_post.js' ), + array( 'jquery', 'tags-box' ) ); wp_register_style( 'jcf_edit_post', jcf_plugin_url( 'assets/edit_post.css' ) ); diff --git a/controllers/FieldController.php b/controllers/FieldController.php index fe487cc..9d5599a 100644 --- a/controllers/FieldController.php +++ b/controllers/FieldController.php @@ -1,15 +1,16 @@ _render_ajax( 'fields/form', 'html', array( 'field' => $field ) ); } - return $this->_render_ajax( null, 'json', array( 'status' => !empty( $field ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $field ), + 'error' => $model->get_errors(), + ) ); } /** @@ -46,7 +50,7 @@ public function ajax_save() { if ( $model->load( $_POST ) && $success = $model->save() ) { if ( isset( $success['id_base'] ) && 'collection' === $success['id_base'] ) { - $jcf = \JustCustomFields::get_instance(); + $jcf = \JustCustomFields::get_instance(); $registered_fields = $jcf->get_fields( 'collection' ); $post_type_kind = models\Field::get_post_type_kind( $model->post_type ); @@ -55,13 +59,13 @@ public function ajax_save() { } ob_start(); - $this->_render('fields/collection', array( - 'collection' => $success['instance'], - 'collection_id' => $success['id'], - 'fieldset_id' => $success['fieldset_id'], + $this->_render( 'fields/collection', array( + 'collection' => $success['instance'], + 'collection_id' => $success['id'], + 'fieldset_id' => $success['fieldset_id'], 'registered_fields' => $registered_fields, - 'post_type_kind' => $post_type_kind, - )); + 'post_type_kind' => $post_type_kind, + ) ); $success['collection_fields'] = ob_get_clean(); } @@ -78,7 +82,10 @@ public function ajax_delete() { $model = new models\Field(); $model->load( $_POST ) && $success = $model->delete(); - return $this->_render_ajax( null, 'json', array( 'status' => !empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } /** @@ -88,7 +95,10 @@ public function ajax_sort() { $model = new models\Field(); $model->load( $_POST ) && $success = $model->sort(); - return $this->_render_ajax( null, 'json', array( 'status' => !empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } /** @@ -98,7 +108,10 @@ public function ajax_collection_sort() { $model = new models\Field(); $model->load( $_POST ) && $success = $model->sortCollection(); - return $this->_render_ajax( null, 'json', array( 'status' => !empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } } diff --git a/controllers/FieldsetController.php b/controllers/FieldsetController.php index 1e00e8d..ebaaf09 100644 --- a/controllers/FieldsetController.php +++ b/controllers/FieldsetController.php @@ -5,6 +5,9 @@ use jcf\models; use jcf\core; +/** + * Fieldset controller + */ class FieldsetController extends core\Controller { /** @@ -36,25 +39,28 @@ public function __construct() { */ public function init_routes() { $page_title = __( 'Fields', \JustCustomFields::TEXTDOMAIN ); - add_submenu_page( null, $page_title, $page_title, 'manage_options', 'jcf_fieldset_index', array( $this, 'actionIndex' ) ); + add_submenu_page( null, $page_title, $page_title, 'manage_options', 'jcf_fieldset_index', array( + $this, + 'actionIndex', + ) ); } /** * Render settings page with fieldsets and fields */ public function actionIndex() { - $post_type_id = $_GET['pt']; + $post_type_id = $_GET['pt']; $post_type_kind = models\Fieldset::get_post_type_kind( $post_type_id ); - $jcf = \JustCustomFields::get_instance(); + $jcf = \JustCustomFields::get_instance(); $fieldset_model = new models\Fieldset(); - $field_model = new models\Field(); + $field_model = new models\Field(); - $fieldsets = $fieldset_model->find_by_post_type( $post_type_id ); - $fields = $field_model->find_by_post_type( $post_type_id ); - $collections = $field_model->find_collections_by_post_type( $post_type_id ); + $fieldsets = $fieldset_model->find_by_post_type( $post_type_id ); + $fields = $field_model->find_by_post_type( $post_type_id ); + $collections = $field_model->find_collections_by_post_type( $post_type_id ); $collections['registered_fields'] = $jcf->get_fields( 'collection' ); - $registered_fields = $jcf->get_fields(); + $registered_fields = $jcf->get_fields(); if ( core\JustField::POSTTYPE_KIND_TAXONOMY === $post_type_kind ) { $post_types = jcf_get_taxonomies( 'objects' ); @@ -68,15 +74,16 @@ public function actionIndex() { /* load template */ $template_params = array( - 'tab' => 'fields', - 'post_type' => $post_types[ $post_type_id ], - 'post_type_id' => $post_type_id, - 'post_type_kind' => $post_type_kind, - 'fieldsets' => $fieldsets, - 'field_settings' => $fields, - 'collections' => $collections, + 'tab' => 'fields', + 'post_type' => $post_types[ $post_type_id ], + 'post_type_id' => $post_type_id, + 'post_type_kind' => $post_type_kind, + 'fieldsets' => $fieldsets, + 'field_settings' => $fields, + 'collections' => $collections, 'registered_fields' => $registered_fields, ); + return $this->_render( 'fieldsets/index', $template_params ); } @@ -85,9 +92,12 @@ public function actionIndex() { */ public function ajax_create() { $model = new models\Fieldset(); - $model->load($_POST) && $success = $model->create(); + $model->load( $_POST ) && $success = $model->create(); - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } /** @@ -95,34 +105,39 @@ public function ajax_create() { */ public function ajax_delete() { $model = new models\Fieldset(); - $model->load($_POST) && $success = $model->delete(); + $model->load( $_POST ) && $success = $model->delete(); - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } /** * Form html on fieldset Update request */ public function ajax_get_form() { - //ini_set('display_errors',1); $model = new models\Fieldset(); if ( $model->load( $_POST ) && $fieldset = $model->find_by_id( $model->fieldset_id ) ) { $taxonomies = get_object_taxonomies( $model->post_type, 'objects' ); - $templates = jcf_get_page_templates( $model->post_type ); + $templates = jcf_get_page_templates( $model->post_type ); $post_type_kind = $model->get_post_type_kind( $model->post_type ); return $this->_render_ajax( 'fieldsets/form', 'html', array( - 'fieldset' => $fieldset, - 'post_type' => $model->post_type, - 'taxonomies' => $taxonomies, - 'templates' => $templates, + 'fieldset' => $fieldset, + 'post_type' => $model->post_type, + 'taxonomies' => $taxonomies, + 'templates' => $templates, 'post_type_kind' => $post_type_kind, ) ); } - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $fieldset ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $fieldset ), + 'error' => $model->get_errors(), + ) ); } /** @@ -134,8 +149,8 @@ public function ajax_update() { return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $success ), - 'title' => $model->title, - 'error' => $model->get_errors(), + 'title' => $model->title, + 'error' => $model->get_errors(), ) ); } @@ -146,7 +161,10 @@ public function ajax_sort() { $model = new models\Fieldset(); $model->load( $_POST ) && $success = $model->sort(); - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $success ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $success ), + 'error' => $model->get_errors(), + ) ); } /** @@ -163,7 +181,10 @@ public function ajax_get_visibility_form() { return $this->_render( 'fieldsets/visibility/form', $form_data ); } - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $form_data ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $form_data ), + 'error' => $model->get_errors(), + ) ); } /** @@ -174,17 +195,20 @@ public function ajax_get_visibility_options() { if ( $model->load( $_POST ) && $result = $model->get_based_on_options() ) { $template = 'taxonomies_list'; - $options = array( 'taxonomies' => $result ); + $options = array( 'taxonomies' => $result ); if ( models\FieldsetVisibility::BASEDON_PAGE_TPL === $model->based_on ) { $template = 'templates_list'; - $options = array( 'templates' => $result ); + $options = array( 'templates' => $result ); } return $this->_render_ajax( 'fieldsets/visibility/' . $template, 'html', $options ); } - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $result ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $result ), + 'error' => $model->get_errors(), + ) ); } /** @@ -192,11 +216,11 @@ public function ajax_get_visibility_options() { */ public function ajax_get_taxonomy_terms() { $taxonomy = $_POST['taxonomy']; - $terms = get_terms( $taxonomy, array( 'hide_empty' => false ) ); + $terms = get_terms( $taxonomy, array( 'hide_empty' => false ) ); return $this->_render_ajax( 'fieldsets/visibility/terms_list', 'html', array( - 'terms' => $terms, - 'taxonomy' => $taxonomy, + 'terms' => $terms, + 'taxonomy' => $taxonomy, 'current_term' => array(), ) ); } @@ -210,11 +234,14 @@ public function ajax_save_visibility() { if ( $model->load( $_POST ) && $rules = $model->update() ) { return $this->_render_ajax( 'fieldsets/visibility/rules', 'html', array( 'visibility_rules' => $rules, - 'post_type' => $model->post_type, + 'post_type' => $model->post_type, ) ); } - return $this->_render_ajax(null, 'json', array( 'status' => ! empty( $rules ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $rules ), + 'error' => $model->get_errors(), + ) ); } /** @@ -226,7 +253,7 @@ public function ajax_delete_visibility() { if ( $model->load( $_POST ) && $rules = $model->delete() ) { return $this->_render_ajax( 'fieldsets/visibility/rules', 'html', array( 'visibility_rules' => $rules, - 'post_type' => $model->post_type + 'post_type' => $model->post_type, ) ); } @@ -238,8 +265,8 @@ public function ajax_delete_visibility() { */ public function ajax_visibility_autocomplete() { $taxonomy = strip_tags( trim( $_POST['taxonomy'] ) ); - $term = strip_tags( trim( $_POST['term'] ) ); - $result = models\FieldsetVisibility::find_taxonomy_terms( $taxonomy, $term ); + $term = strip_tags( trim( $_POST['term'] ) ); + $result = models\FieldsetVisibility::find_taxonomy_terms( $taxonomy, $term ); return $this->_render_ajax( null, 'json', $result ); } diff --git a/controllers/ImportExportController.php b/controllers/ImportExportController.php index 9eda776..6a1ce6f 100644 --- a/controllers/ImportExportController.php +++ b/controllers/ImportExportController.php @@ -5,6 +5,9 @@ use jcf\models; use jcf\core; +/** + * Import/Export controller + */ class ImportExportController extends core\Controller { /** @@ -24,7 +27,10 @@ public function __construct() { */ public function init_routes() { $page_title = __( 'Import/Export', \JustCustomFields::TEXTDOMAIN ); - add_submenu_page( null, $page_title, $page_title, 'manage_options', 'jcf_import_export', array( $this, 'actionIndex' ) ); + add_submenu_page( null, $page_title, $page_title, 'manage_options', 'jcf_import_export', array( + $this, + 'actionIndex', + ) ); } /** @@ -37,6 +43,7 @@ public function actionIndex() { $model->load( $_POST ) && $model->import(); /* load template */ + return $this->_render( 'import_export/index', array( 'tab' => 'import_export' ) ); } @@ -47,11 +54,14 @@ public function actionIndex() { public function ajax_import_form() { $model = new models\ImportExport(); - if ( $model->load($_POST) && $import_data = $model->get_import_fields() ) { + if ( $model->load( $_POST ) && $import_data = $model->get_import_fields() ) { return $this->_render_ajax( 'import_export/import', 'html', array( 'import_data' => $import_data ) ); } - return $this->_render_ajax( null, 'json', array( 'status' => ! empty( $import_data ), 'error' => $model->get_errors() ) ); + return $this->_render_ajax( null, 'json', array( + 'status' => ! empty( $import_data ), + 'error' => $model->get_errors(), + ) ); } /** @@ -59,16 +69,17 @@ public function ajax_import_form() { */ public function ajax_export_form() { $fieldsets_model = new models\Fieldset(); - $fieldsets = $fieldsets_model->findAll(); + $fieldsets = $fieldsets_model->findAll(); $fields_model = new models\Field(); - $fields = $fields_model->findAll(); + $fields = $fields_model->findAll(); /* load template */ + return $this->_render_ajax( 'import_export/export', 'html', array( 'field_settings' => $fields, - 'fieldsets' => $fieldsets, - 'post_types' => jcf_get_post_types(), + 'fieldsets' => $fieldsets, + 'post_types' => jcf_get_post_types(), ) ); } @@ -78,10 +89,11 @@ public function ajax_export_form() { public function ajax_export() { $model = new models\ImportExport(); - if ( $model->load($_POST) && $data = $model->export() ) { + if ( $model->load( $_POST ) && $data = $model->export() ) { $filename = 'jcf_export' . date( 'Ymd-his' ) . '.json'; header( 'Content-Disposition: attachment;filename=' . $filename ); header( 'Content-Transfer-Encoding: binary' ); + return $this->_render_ajax( null, 'json', $data ); } diff --git a/controllers/MigrateController.php b/controllers/MigrateController.php index 9cde1a2..2031f42 100644 --- a/controllers/MigrateController.php +++ b/controllers/MigrateController.php @@ -47,7 +47,7 @@ public function action_index() { $migrations = $model->find_migrations(); /* check form submit and migrate */ - if ( $model->load($_POST) ) { + if ( $model->load( $_POST ) ) { if ( $model->migrate( $migrations ) ) { return $this->action_upgraded(); } @@ -59,11 +59,11 @@ public function action_index() { $model->is_storage_writable(); $errors = $model->get_errors(); - return $this->_render('migrate/index', array( + return $this->_render( 'migrate/index', array( 'migrations' => $migrations, - 'warnings' => $warnings, - 'errors' => $errors, - )); + 'warnings' => $warnings, + 'errors' => $errors, + ) ); } /** diff --git a/controllers/PostTypeController.php b/controllers/PostTypeController.php index 18381ce..3b9eb00 100644 --- a/controllers/PostTypeController.php +++ b/controllers/PostTypeController.php @@ -5,6 +5,9 @@ use jcf\models; use jcf\core; +/** + * Post Type controller + */ class PostTypeController extends core\Controller { /** @@ -51,11 +54,11 @@ protected function _is_post_edit() { * @param string $post_type post type. */ public function action_render( $post_type = '' ) { - $model = new models\Fieldset(); + $model = new models\Fieldset(); $fieldsets = $model->find_by_post_type( $post_type ); $field_model = new models\Field(); - $fields = $field_model->find_by_post_type( $post_type ); + $fields = $field_model->find_by_post_type( $post_type ); $visibility_model = new models\FieldsetVisibility(); $visibility_rules = $visibility_model->find_by_post_type( $post_type ); @@ -72,8 +75,8 @@ public function action_render( $post_type = '' ) { continue; } $params = array( - 'post_type' => $post_type, - 'field_id' => $field_id, + 'post_type' => $post_type, + 'field_id' => $field_id, 'fieldset_id' => $fieldset['id'], ); $field_model->load( $params ) && $field_obj = core\JustFieldFactory::create( $field_model ); @@ -85,10 +88,13 @@ public function action_render( $post_type = '' ) { $field_obj->doAddCss(); } - $pos = isset( $fieldset['position'] )? $fieldset['position'] : models\Fieldset::POSITION_ADVANCED; - $prio = isset( $fieldset['priority'] )? $fieldset['priority'] : models\Fieldset::PRIO_DEFAULT; + $pos = isset( $fieldset['position'] ) ? $fieldset['position'] : models\Fieldset::POSITION_ADVANCED; + $prio = isset( $fieldset['priority'] ) ? $fieldset['priority'] : models\Fieldset::PRIO_DEFAULT; - add_meta_box( 'jcf_fieldset-' . $f_id, $fieldset['title'], array( $this, 'render_custom_field' ), $post_type, $pos, $prio, array( $fieldset ) ); + add_meta_box( 'jcf_fieldset-' . $f_id, $fieldset['title'], array( + $this, + 'render_custom_field', + ), $post_type, $pos, $prio, array( $fieldset ) ); } wp_add_inline_script( 'jquery-core', 'var jcf_fieldsets_visibility_rules = ' . json_encode( $visibility_rules ) . ';', 'before' ); @@ -96,17 +102,17 @@ public function action_render( $post_type = '' ) { } /** - * Prepare and print fieldset html. - * - load each field class - * - print form from each class + * Prepare and print fieldset html. + * - load each field class + * - print form from each class * * @param array $post post. * @param array $box box. */ public function render_custom_field( $post = null, $box = null ) { - $model = new models\Field(); + $model = new models\Field(); $fieldset = $box['args'][0]; - $fields = $model->find_by_post_type( $post->post_type ); + $fields = $model->find_by_post_type( $post->post_type ); $this->_render( 'shortcodes/modal' ); foreach ( $fieldset['fields'] as $field_id => $enabled ) { @@ -115,8 +121,8 @@ public function render_custom_field( $post = null, $box = null ) { } $params = array( - 'post_type' => $post->post_type, - 'field_id' => $field_id, + 'post_type' => $post->post_type, + 'field_id' => $field_id, 'fieldset_id' => $fieldset['id'], ); $model->load( $params ) && $field_obj = core\JustFieldFactory::create( $model ); @@ -148,7 +154,7 @@ public function render_custom_field( $post = null, $box = null ) { */ public function save_post_ext( $post_id = 0, $post = null ) { $fieldsets_model = new models\Fieldset(); - $field_model = new models\Field(); + $field_model = new models\Field(); $field_model->load( $_POST ); /* do not save anything on autosave */ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { @@ -159,12 +165,12 @@ public function save_post_ext( $post_id = 0, $post = null ) { * Verify this came from the our screen and with proper authorization, * because save_post can be triggered at other times */ - if ( empty( $_POST['justcustomfields_noncename'] ) || !wp_verify_nonce( $_POST['justcustomfields_noncename'], plugin_basename( __FILE__ ) ) ) { + if ( empty( $_POST['justcustomfields_noncename'] ) || ! wp_verify_nonce( $_POST['justcustomfields_noncename'], plugin_basename( __FILE__ ) ) ) { return; } /* check permissions */ - $permission = ('page' === $field_model->post_type) ? 'edit_page' : 'edit_post'; + $permission = ( 'page' === $field_model->post_type ) ? 'edit_page' : 'edit_post'; if ( ! current_user_can( $permission, $post_id ) ) { return; @@ -183,7 +189,7 @@ public function save_post_ext( $post_id = 0, $post = null ) { foreach ( $fieldset['fields'] as $field_id => $tmp ) { $field_model->field_id = $field_id; - $field_obj = core\JustFieldFactory::create( $field_model ); + $field_obj = core\JustFieldFactory::create( $field_model ); $field_obj->setPostId( $post->ID ); $field_obj->do_save(); } @@ -201,25 +207,26 @@ public function save_post_ext( $post_id = 0, $post = null ) { */ public function jcf_shortcode( $args ) { $model = new models\Shortcodes(); + return $model->get_field_value( $args ); } /** - * Add custom scripts to post edit page + * Add custom scripts to post edit page */ public function add_scripts() { wp_enqueue_script( 'jcf_edit_post' ); } /** - * Add custom styles to post edit page + * Add custom styles to post edit page */ public function add_styles() { wp_enqueue_style( 'jcf_edit_post' ); } /** - * This add js script to the Upload Media wordpress popup + * This add js script to the Upload Media wordpress popup */ public function add_media_uploader_js() { global $pagenow; @@ -230,19 +237,22 @@ public function add_media_uploader_js() { /* Gets the right label depending on the caller widget */ switch ( $_GET['type'] ) { - case 'image': $button_label = __( 'Select Picture', \JustCustomFields::TEXTDOMAIN ); + case 'image': + $button_label = __( 'Select Picture', \JustCustomFields::TEXTDOMAIN ); break; - case 'file': $button_label = __( 'Select File', \JustCustomFields::TEXTDOMAIN ); + case 'file': + $button_label = __( 'Select File', \JustCustomFields::TEXTDOMAIN ); break; - default: $button_label = __( 'Insert into Post', \JustCustomFields::TEXTDOMAIN ); + default: + $button_label = __( 'Insert into Post', \JustCustomFields::TEXTDOMAIN ); break; } /* Overrides the label when displaying the media uploader panels */ ?> - instance['description']) ) : ?> -

instance['description']); ?>

- + instance['description'] ) ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
@@ -51,60 +68,71 @@ public function field() /** * draw form for edit field */ - public function form() - { + public function form() { //Defaults - $instance = wp_parse_args((array) $this->instance, array( 'title' => '' )); + $instance = wp_parse_args( (array) $this->instance, array( 'title' => '' ) ); - $title = esc_attr($instance['title']); - $show_monthes = !empty($instance['show_monthes']) ? ' checked="checked" ' : ''; - $date_format = !empty($instance['date_format']) ? esc_attr($instance['date_format']) : 'yy-mm-dd'; + $title = esc_attr( $instance['title'] ); + $show_monthes = ! empty( $instance['show_monthes'] ) ? ' checked="checked" ' : ''; + $date_format = ! empty( $instance['date_format'] ) ? esc_attr( $instance['date_format'] ) : 'yy-mm-dd'; ?> -

-

-

-
- yy-mm-dd +

+ + +

+

+

+ +
+ yy-mm-dd +

\ No newline at end of file diff --git a/views/fields/collection.php b/views/fields/collection.php index b35a4ae..5d1c9ad 100644 --- a/views/fields/collection.php +++ b/views/fields/collection.php @@ -52,7 +52,7 @@
- + @@ -47,7 +47,7 @@ class="jcf_edit_field field_options['classname']; ?>"> - -
+
Date: Thu, 15 Jun 2017 18:51:12 +0300 Subject: [PATCH 13/16] refactor input, related content, select --- components/inputtext/JustField_InputText.php | 97 +++-- .../JustField_RelatedContent.php | 361 ++++++++++-------- components/select/JustField_Select.php | 170 +++++---- components/table/JustField_Table.php | 12 +- 4 files changed, 369 insertions(+), 271 deletions(-) diff --git a/components/inputtext/JustField_InputText.php b/components/inputtext/JustField_InputText.php index 3f60ac0..eb67401 100644 --- a/components/inputtext/JustField_InputText.php +++ b/components/inputtext/JustField_InputText.php @@ -4,34 +4,41 @@ use jcf\core; -class JustField_InputText extends core\JustField -{ +/** + * Class for InputText + * + * @package default + * @author Alexander Prokopenko + */ +class JustField_InputText extends core\JustField { - public function __construct() - { + /** + * Class constructor + **/ + public function __construct() { $field_ops = array( 'classname' => 'field_inputtext' ); - parent::__construct('inputtext', __('Input Text', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'inputtext', __( 'Input Text', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { + public function field() { ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> - -
- - instance['description'] != '' ) : ?> -

instance['description']); ?>

- + field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> + +
+ + instance['description'] ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
@@ -39,36 +46,52 @@ public function field() } /** - * draw form for + * Draw form for */ - public function form() - { - $instance = wp_parse_args((array) $this->instance, array( 'title' => '', 'description' => '' )); - $description = esc_html($instance['description']); - $title = esc_attr($instance['title']); + public function form() { + $instance = wp_parse_args( (array) $this->instance, array( 'title' => '', 'description' => '' ) ); + $description = esc_html( $instance['description'] ); + $title = esc_attr( $instance['title'] ); ?> -

-

+

+ + +

+

+ +

'field_relatedcontent' ); - parent::__construct('relatedcontent', __('Related Content', \JustCustomFields::TEXTDOMAIN), $field_ops); - add_action('wp_ajax_jcf_related_content_autocomplete', array( $this, 'ajaxAutocomplete' )); + parent::__construct( 'relatedcontent', __( 'Related Content', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + add_action( 'wp_ajax_jcf_related_content_autocomplete', array( $this, 'ajax_autocomplete' ) ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { - if ( empty($this->entry) ) + public function field() { + if ( empty( $this->entry ) ) { $this->entry = array(); - // add null element for etalon copy + } + // add null element for etalon copy. $entries = array( '00' => '' ) + (array) $this->entry; - // get posts data - $type = $this->instance['input_type']; - $post_type = $this->instance['post_type']; - $post_types = jcf_get_post_types('object'); + // get posts data. + $type = $this->instance['input_type']; + $post_type = $this->instance['post_type']; + $post_types = jcf_get_post_types( 'object' ); - if ( $type == 'select' ) { - // get posts list + if ( 'select' === $type ) { + // get posts list. global $wpdb; - if ( $post_type != 'any' ) { + if ( 'any' !== $post_type ) { $post_type_where = " post_type = '$post_type' "; - } - else { - // get all post types - $post_type_where = "( post_type = '" . implode("' OR post_type = '", array_keys($post_types)) . "' )"; + } else { + // get all post types. + $post_type_where = "( post_type = '" . implode( "' OR post_type = '", array_keys( $post_types ) ) . "' )"; } $query = "SELECT ID, post_title, post_status, post_type FROM $wpdb->posts WHERE $post_type_where AND (post_status = 'publish' OR post_status = 'draft') ORDER BY post_title"; - $posts = $wpdb->get_results($query); + $posts = $wpdb->get_results( $query ); $options = array(); foreach ( $posts as $p ) { - $draft = ( $p->post_status == 'draft' ) ? ' (DRAFT)' : ''; - $type_label = ( $post_type == 'any' ) ? ' / ' . $post_types[$p->post_type]->labels->singular_name : ''; - $options["" . $p->ID . ""] = esc_attr($p->post_title . $draft . $type_label); + $draft = ( 'draft' === $p->post_status ) ? ' (DRAFT)' : ''; + $type_label = ( 'any' === $post_type ) ? ' / ' . $post_types[ $p->post_type ]->labels->singular_name : ''; + $options[ '' . $p->ID . '' ] = esc_attr( $p->post_title . $draft . $type_label ); } - } - elseif ( $type == 'autocomplete' && !empty($this->entry[0]) ) { + } elseif ( 'autocomplete' === $type && ! empty( $this->entry[0] ) ) { global $wpdb; $query = "SELECT ID, post_title, post_status, post_type FROM $wpdb->posts - WHERE ID IN(" . implode(',', $this->entry) . ")"; - $posts = $wpdb->get_results($query); + WHERE ID IN(" . implode( ',', $this->entry ) . ")"; + $posts = $wpdb->get_results( $query ); $options = array(); foreach ( $posts as $p ) { - $draft = ( $p->post_status == 'draft' ) ? ' (DRAFT)' : ''; - $type_label = ( $post_type == 'any' ) ? ' / ' . $post_types[$p->post_type]->labels->singular_name : ''; - $options["" . $p->ID . ""] = esc_attr($p->post_title . $draft . $type_label); + $draft = ( 'draft' === $p->post_status ) ? ' (DRAFT)' : ''; + $type_label = ( 'any' === $post_type ) ? ' / ' . $post_types[ $p->post_type ]->labels->singular_name : ''; + $options[ '' . $p->ID . '' ] = esc_attr( $p->post_title . $draft . $type_label ); } } ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> + field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> -
+
$entry ) : ?> -
+

- - + - $label ) : ?> - - + $label ) : ?> + + - - - + + +

- - -
+ + +
- instance['description'] != '' ): ?> -

instance['description']); ?>

+ instance['description'] ) : ?> +

instance['description'] ); ?>

- +
field_options['after_widget']; ?> @@ -132,137 +141,178 @@ public function field() } /** - * draw form for edit field + * Draw form for edit field */ - public function form() - { - //Defaults - $instance = wp_parse_args((array) $this->instance, array( 'title' => '', 'post_type' => 'page', 'input_type' => 'autocomplete', - 'description' => __('Start typing entry Title to see the list.', \JustCustomFields::TEXTDOMAIN) )); - - $title = esc_attr($instance['title']); - $description = esc_html($instance['description']); - - $post_types = jcf_get_post_types('object'); + public function form() { + // Defaults. + $instance = wp_parse_args( (array) $this->instance, array( + 'title' => '', + 'post_type' => 'page', + 'input_type' => 'autocomplete', + 'description' => __( 'Start typing entry Title to see the list.', \JustCustomFields::TEXTDOMAIN ), + ) ); + + $title = esc_attr( $instance['title'] ); + $description = esc_html( $instance['description'] ); + + $post_types = jcf_get_post_types( 'object' ); ?> -

-

+

+ + +

-

- + $pt ) : ?> - - + +

-

- + +

-

-

+

+ +

$params ) { - if ( !is_array($params) || !empty($params['__delete__']) || empty($params['related_id']) ) { + if ( ! is_array( $params ) || ! empty( $params['__delete__'] ) || empty( $params['related_id'] ) ) { continue; } - unset($params['__delete__']); - $values[$key] = $params['related_id']; + unset( $params['__delete__'] ); + $values[ $key ] = $params['related_id']; } - $values = array_values($values); + $values = array_values( $values ); + return $values; } /** - * update instance (settings) for current field + * Update instance (settings) for current field + * + * @param array $new_instance New instance. + * @param array $old_instance Old instance. + * + * @return array */ - public function update( $new_instance, $old_instance ) - { - $instance = $old_instance; - $instance['title'] = strip_tags($new_instance['title']); - $instance['post_type'] = strip_tags($new_instance['post_type']); - $instance['input_type'] = strip_tags($new_instance['input_type']); - $instance['description'] = strip_tags($new_instance['description']); + public function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['post_type'] = strip_tags( $new_instance['post_type'] ); + $instance['input_type'] = strip_tags( $new_instance['input_type'] ); + $instance['description'] = strip_tags( $new_instance['description'] ); + return $instance; } /** - * custom get_field functions to add one more deep level + * Custom get_field functions to add one more deep level + * + * @param mixed $field Field. + * @param mixed $number Number. + * + * @return mixed */ - protected function getFieldIdL2( $field, $number ) - { - return $this->get_field_id( $number . '-' . $field); + protected function get_field_id_l2( $field, $number ) { + return $this->get_field_id( $number . '-' . $field ); } - protected function getFieldNameL2( $field, $number ) - { - return $this->get_field_name( $number . '][' . $field); + /** + * Custom get_field functions to add one more deep level + * + * @param mixed $field Field. + * @param mixed $number Number. + * + * @return mixed + */ + protected function get_field_name_l2( $field, $number ) { + return $this->get_field_name( $number . '][' . $field ); } /** - * add custom scripts + * Add custom scripts */ - public function add_js() - { + public function add_js() { wp_register_script( 'jcf_related_content', - plugins_url( '/related-content.js', __FILE__ ), - array( 'jquery', 'jquery-ui-autocomplete', 'jquery-ui-sortable', 'jcf_edit_post' ) + plugins_url( '/related-content.js', __FILE__ ), + array( 'jquery', 'jquery-ui-autocomplete', 'jquery-ui-sortable', 'jcf_edit_post' ) ); - wp_enqueue_script('jcf_related_content'); + wp_enqueue_script( 'jcf_related_content' ); - // add text domain if not registered with another component + // add text domain if not registered with another component. global $wp_scripts; - if ( empty($wp_scripts->registered['jcf_fields_group']) && empty($wp_scripts->registered['jcf_uploadmedia']) ) { - wp_localize_script('jcf_related_content', 'jcf_textdomain', jcf_get_language_strings()); + if ( empty( $wp_scripts->registered['jcf_fields_group'] ) && empty( $wp_scripts->registered['jcf_uploadmedia'] ) ) { + wp_localize_script( 'jcf_related_content', 'jcf_textdomain', jcf_get_language_strings() ); } } - public function add_css() - { - wp_register_style('ui-autocomplete', plugins_url( '/assets/jquery-ui-1.8.14.autocomplete.css', __FILE__ )); - wp_enqueue_style('ui-autocomplete'); + /** + * Add custom styles + */ + public function add_css() { + wp_register_style( 'ui-autocomplete', plugins_url( '/assets/jquery-ui-1.8.14.autocomplete.css', __FILE__ ) ); + wp_enqueue_style( 'ui-autocomplete' ); - wp_register_style('jcf_related_content', plugins_url( '/related-content.css', __FILE__ ), array( 'jcf_edit_post' ) ); - wp_enqueue_style('jcf_related_content'); + wp_register_style( 'jcf_related_content', plugins_url( '/related-content.css', __FILE__ ), array( 'jcf_edit_post' ) ); + wp_enqueue_style( 'jcf_related_content' ); } /** - * print fields values from shortcode + * Print field values inside the shortcode + * + * @param array $args shortcode args. + * + * @return mixed */ - public function shortcode_value( $args ) - { - if ( empty($this->entry) ) + public function shortcode_value( $args ) { + if ( empty( $this->entry ) ) { return; + } $html = '
    '; foreach ( $this->entry as $key => $entry ) { - $post_link = get_permalink($entry); - $post_title = get_the_title($entry); - $html .= '
  • ' . esc_html($post_title) . '
  • '; + $post_link = get_permalink( $entry ); + $post_title = get_the_title( $entry ); + $html .= '
  • ' . esc_html( $post_title ) . '
  • '; } $html .= '
'; @@ -272,45 +322,46 @@ public function shortcode_value( $args ) /** * Autocomplete ajax callback */ - public function ajaxAutocomplete() { - if ( empty($_POST['term']) ) - die(''); + public function ajax_autocomplete() { + if ( empty( $_POST['term'] ) ) { + die( '' ); + } - $post_type = $_POST['post_types']; - $post_types = jcf_get_post_types('object'); + $post_type = $_POST['post_types']; + $post_types = jcf_get_post_types( 'object' ); - if ( $post_type != 'any' ) { + if ( 'any' !== $post_type ) { $post_type_where = " post_type = '" . $_POST['post_types'] . "' "; - } - else { - // get all post types - $post_type_where = "( post_type = '" . implode("' OR post_type = '", array_keys($post_types)) . "' )"; + } else { + // get all post types. + $post_type_where = "( post_type = '" . implode( "' OR post_type = '", array_keys( $post_types ) ) . "' )"; } global $wpdb; - $query = "SELECT ID, post_title, post_status, post_type + $query = "SELECT ID, post_title, post_status, post_type FROM $wpdb->posts WHERE $post_type_where AND (post_status = 'publish' OR post_status = 'draft') AND post_title LIKE '%" . $_POST['term'] . "%' ORDER BY post_title"; - $posts = $wpdb->get_results($query); + $posts = $wpdb->get_results( $query ); $response = array(); foreach ( $posts as $p ) { - $draft = ( $p->post_status == 'draft' ) ? ' (DRAFT)' : ''; - $type_label = ( $_POST['post_types'] != 'any' ) ? '' : ' / ' . $post_types[$p->post_type]->labels->singular_name; + $draft = ( 'draft' === $p->post_status ) ? ' (DRAFT)' : ''; + $type_label = ( 'any' !== $_POST['post_types'] ) ? '' : ' / ' . $post_types[ $p->post_type ]->labels->singular_name; $response[] = array( - 'id' => $p->ID, - 'label' => $p->post_title . $draft . $type_label, - 'value' => $p->post_title . $draft . $type_label, - 'type' => $p->post_type, - 'status' => $p->post_status + 'id' => $p->ID, + 'label' => $p->post_title . $draft . $type_label, + 'value' => $p->post_title . $draft . $type_label, + 'type' => $p->post_type, + 'status' => $p->post_status, ); } - $result = json_encode($response); - header("Content-Type: application/json; charset=" . get_bloginfo('charset')); + $result = json_encode( $response ); + header( 'Content-Type: application/json; charset=' . get_bloginfo( 'charset' ) ); echo $result; exit(); } } + ?> \ No newline at end of file diff --git a/components/select/JustField_Select.php b/components/select/JustField_Select.php index dde800e..9d03882 100644 --- a/components/select/JustField_Select.php +++ b/components/select/JustField_Select.php @@ -10,38 +10,40 @@ * @package default * @author Alexander Prokopenko */ -class JustField_Select extends core\JustField -{ +class JustField_Select extends core\JustField { - public function __construct() - { + /** + * Class constructor + **/ + public function __construct() { $field_ops = array( 'classname' => 'field_select' ); - parent::__construct('select', __('Select', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'select', __( 'Select', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { - $values = $this->parsedSelectOptions($this->instance); + public function field() { + $values = $this->parsedSelectOptions( $this->instance ); ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> -
- -
- instance['description']) ) : ?> -

instance['description']); ?>

+ field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> +
+ +
+ instance['description'] ) ) : ?> +

instance['description'] ); ?>

field_options['after_widget']; ?>
@@ -51,69 +53,91 @@ public function field() /** * draw form for edit field */ - public function form() - { + public function form() { //Defaults - $instance = wp_parse_args((array) $this->instance, array( 'title' => '', 'description' => '', 'options' => '', 'empty_option' => '' )); - $title = esc_attr($instance['title']); - $options = esc_attr($instance['options']); - $description = esc_html($instance['description']); - $empty_option = esc_attr($instance['empty_option']); + $instance = wp_parse_args( (array) $this->instance, array( + 'title' => '', + 'description' => '', + 'options' => '', + 'empty_option' => '', + ) ); + $title = esc_attr( $instance['title'] ); + $options = esc_attr( $instance['options'] ); + $description = esc_html( $instance['description'] ); + $empty_option = esc_attr( $instance['empty_option'] ); ?> -

-

- -
label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN); ?>

-

-

-

+

+ + +

+

+ + +
+ label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+

+

+ +
+ +

+

+ +

parsedSelectOptions($this->instance); - $options = array_flip($options); - $value = $this->entry; - - if ( isset($options[$this->entry]) ) { - $value = $options[$this->entry]; + public function shortcode_value( $args ) { + $options = $this->parsedSelectOptions( $this->instance ); + $options = array_flip( $options ); + $value = $this->entry; + + if ( isset( $options[ $this->entry ] ) ) { + $value = $options[ $this->entry ]; } - return $args['before_value'] . esc_html($value) . $args['after_value']; + + return $args['before_value'] . esc_html( $value ) . $args['after_value']; } } diff --git a/components/table/JustField_Table.php b/components/table/JustField_Table.php index eab2ac5..7af59c3 100644 --- a/components/table/JustField_Table.php +++ b/components/table/JustField_Table.php @@ -45,8 +45,8 @@ public function field() foreach ($columns as $col_name => $col_title) { $table_headers .= '' . $col_title . ''; $clone_row .= ''; + id="' . $this->get_field_id_l2($col_name, '00') . '" + name="' . $this->get_field_name_l2($col_name, '00') . '">'; } // generate rows html @@ -63,8 +63,8 @@ public function field() foreach ($columns as $col_name => $col_title) { $rows .= ' + id="' . $this->get_field_id_l2($col_name, $key) . '" + name="' . $this->get_field_name_l2($col_name, $key) . '"> '; } @@ -166,12 +166,12 @@ public function update( $new_instance, $old_instance ) /** * custom get_field functions to add one more deep level */ - protected function getFieldIdL2( $field, $number ) + protected function get_field_id_l2( $field, $number ) { return $this->get_field_id( $number . '-' . $field); } - protected function getFieldNameL2( $field, $number ) + protected function get_field_name_l2( $field, $number ) { return $this->get_field_name( $number . '][' . $field); } From b27d1c8bec09bb918197fd62d20cbb40310c32db Mon Sep 17 00:00:00 2001 From: evkos Date: Fri, 16 Jun 2017 18:47:42 +0300 Subject: [PATCH 14/16] correct several components --- .../JustField_RelatedContent.php | 3 +- components/select/JustField_Select.php | 53 +-- .../JustField_SelectMultiple.php | 180 +++++----- .../simplemedia/JustField_SimpleMedia.php | 287 +++++++++------- components/table/JustField_Table.php | 308 ++++++++++-------- components/textarea/JustField_Textarea.php | 182 ++++++----- views/_header.php | 8 +- views/_notices.php | 18 +- 8 files changed, 608 insertions(+), 431 deletions(-) diff --git a/components/relatedcontent/JustField_RelatedContent.php b/components/relatedcontent/JustField_RelatedContent.php index 3fc1181..0201d7d 100644 --- a/components/relatedcontent/JustField_RelatedContent.php +++ b/components/relatedcontent/JustField_RelatedContent.php @@ -127,8 +127,7 @@ class="jcf_cancel"> instance['description'] ) : ?>

instance['description'] ); ?>

+ echo ' jcf-hide'; } ?>">instance['description'] ); ?>

parsedSelectOptions( $this->instance ); ?> -
+
field_options['before_widget']; ?> field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?>
+ +

- - + +
- label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+ label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>

- + placeholder="ex. Choose item from the list"" type="text" value="" />

@@ -95,7 +95,11 @@ class="widefat">

} /** - * save field on post edit form + * Save field on post edit form + * + * @param array $values Values. + * + * @return array */ public function save( $values ) { $values = $values['val']; @@ -104,7 +108,12 @@ public function save( $values ) { } /** - * update instance (settings) for current field + * Update instance (settings) for current field + * + * @param array $new_instance New instance. + * @param array $old_instance Old instance. + * + * @return array */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; @@ -117,9 +126,9 @@ public function update( $new_instance, $old_instance ) { } /** - * prepare list of options + * Prepare list of options * - * @param array $instance current instance + * @param array $instance current instance. * * @return array */ @@ -145,9 +154,11 @@ public function parsedSelectOptions( $instance ) { } /** - * print field values inside the shortcode + * Print field values inside the shortcode + * + * @param array $args shortcode args. * - * @params array $args shortcode args + * @return mixed */ public function shortcode_value( $args ) { $options = $this->parsedSelectOptions( $this->instance ); diff --git a/components/selectmultiple/JustField_SelectMultiple.php b/components/selectmultiple/JustField_SelectMultiple.php index 39e33e3..d343082 100644 --- a/components/selectmultiple/JustField_SelectMultiple.php +++ b/components/selectmultiple/JustField_SelectMultiple.php @@ -10,104 +10,133 @@ * @package default * @author Alexander Prokopenko */ -class JustField_SelectMultiple extends core\JustField -{ +class JustField_SelectMultiple extends core\JustField { - public function __construct() - { + /** + * Class constructor + **/ + public function __construct() { $field_ops = array( 'classname' => 'field_selectmultiple' ); - parent::__construct('selectmultiple', __('Select Multiple', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'selectmultiple', __( 'Select Multiple', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { - if ( !is_array($this->entry) ) + public function field() { + if ( ! is_array( $this->entry ) ) { $this->entry = array(); - // prepare options array - $values = $this->parsedSelectOptions($this->instance); + } + // prepare options array. + $values = $this->parsedSelectOptions( $this->instance ); ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> -
- $val ): ?> - + - -
- instance['description'] != '' ) : ?> -

instance['description']); ?>

- + +
+ instance['description'] ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
instance, array( 'title' => '', 'description' => '', 'settings' => '' )); - - $title = esc_attr($instance['title']); - $options = esc_attr($instance['options']); - $description = esc_html($instance['description']); + public function form() { + // Defaults. + $instance = wp_parse_args( (array) $this->instance, array( + 'title' => '', + 'description' => '', + 'settings' => '', + ) ); + + $title = esc_attr( $instance['title'] ); + $options = esc_attr( $instance['options'] ); + $description = esc_html( $instance['description'] ); ?> -

- -

- -
label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN); ?>

-

+

+ + +

+ +

+ + +
+ label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+

+

+ +

parsedSelectOptions($this->instance); - $options = array_flip($options); + public function shortcode_value( $args ) { + $options = $this->parsedSelectOptions( $this->instance ); + $options = array_flip( $options ); - if ( empty($this->entry) ) + if ( empty( $this->entry ) ) { return ''; + } $html = '
    '; foreach ( $this->entry as $value ) { - $key = preg_replace('/\s+/', '-', $value); - $key = preg_replace('/[^0-9a-z\-\_]/i', '', $key); - if ( isset($options[$value]) ) { - $value = $options[$value]; + $key = preg_replace( '/\s+/', '-', $value ); + $key = preg_replace( '/[^0-9a-z\-\_]/i', '', $key ); + if ( isset( $options[ $value ] ) ) { + $value = $options[ $value ]; } - $key = esc_attr($key); - $value = esc_html($value); - $html .= "
  • $value
  • \r\n"; + $key = esc_attr( $key ); + $value = esc_html( $value ); + $html .= "
  • $value
  • \r\n"; } $html .= '
'; @@ -143,4 +176,5 @@ public function shortcode_value( $args ) } } + ?> \ No newline at end of file diff --git a/components/simplemedia/JustField_SimpleMedia.php b/components/simplemedia/JustField_SimpleMedia.php index ab62222..e4754d7 100644 --- a/components/simplemedia/JustField_SimpleMedia.php +++ b/components/simplemedia/JustField_SimpleMedia.php @@ -5,183 +5,242 @@ use jcf\core; /** - * Simple Upload media field + * Simple Upload media field */ -class JustField_SimpleMedia extends core\JustField -{ - public static $compatibility = "4.0+"; +class JustField_SimpleMedia extends core\JustField { - public function __construct() - { + /** + * Capability + * + * @var $compatibility + */ + public static $compatibility = '4.0+'; + + /** + * Class constructor + **/ + public function __construct() { $field_ops = array( 'classname' => 'field_simplemedia' ); - parent::__construct('simplemedia', __('Simple Media', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'simplemedia', __( 'Simple Media', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { - $noimage = $image = jcf_plugin_url('components/simplemedia/assets/jcf-noimage100x77.jpg'); + public function field() { + $noimage = $image = jcf_plugin_url( 'components/simplemedia/assets/jcf-noimage100x77.jpg' ); $delete_class = ' jcf-hide'; - $upload_type = $this->instance['type']; - $upload_text = ($upload_type == 'image') ? __('Select image', \JustCustomFields::TEXTDOMAIN) : __('Select file', \JustCustomFields::TEXTDOMAIN); - $value = $link = '#'; + $upload_type = $this->instance['type']; + $upload_text = ( 'image' === $upload_type ) ? __( 'Select image', \JustCustomFields::TEXTDOMAIN ) : __( 'Select file', \JustCustomFields::TEXTDOMAIN ); + $value = $link = '#'; - if ( empty($this->entry) ) + if ( empty( $this->entry ) ) { $this->entry = 0; + } ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> -
- entry) ) { - $value = esc_attr($this->entry); - $link = wp_get_attachment_url($this->entry); - $upload_text = ($upload_type == 'image') ? __('Update image', \JustCustomFields::TEXTDOMAIN) : __('Update file', \JustCustomFields::TEXTDOMAIN); - $delete_class = ''; - } - ?> -
-
- + field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> +
+ entry ) ) { + $value = esc_attr( $this->entry ); + $link = wp_get_attachment_url( $this->entry ); + $upload_text = ( 'image' === $upload_type ) ? __( 'Update image', \JustCustomFields::TEXTDOMAIN ) : __( 'Update file', \JustCustomFields::TEXTDOMAIN ); + $delete_class = ''; + } + ?> +
+
+ -
- - -

- - - -
+ }); + +
+
- instance['description'] != '' ) : ?> -

instance['description']); ?>

- + instance['description'] ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
instance, array( 'title' => '', 'type' => 'file', 'autoresize' => '', - 'description' => '' )); - $instance['type'] = (isset($this->instance['type'])) ? $this->instance['type'] : 'file'; - $title = esc_attr($instance['title']); - $type = $instance['type']; - $description = esc_html($instance['description']); + public function form() { + // Defaults. + $instance = wp_parse_args( (array) $this->instance, array( + 'title' => '', + 'type' => 'file', + 'autoresize' => '', + 'description' => '', + ) ); + $instance['type'] = ( isset( $this->instance['type'] ) ) ? $this->instance['type'] : 'file'; + $title = esc_attr( $instance['title'] ); + $type = $instance['type']; + $description = esc_html( $instance['description'] ); ?> -

-

- - +

+

+ +

-

+

+ +

( $post_ID ? $post_ID : null ) )); - wp_enqueue_script("jcf-simpleupload-modal", jcf_plugin_url('components/simplemedia/assets/simplemedia-modal.js'), array( 'jquery', 'media-models', 'jcf_edit_post' )); - - // add text domain if not registered with another component + } + wp_enqueue_media( array( 'post' => ( $post_id ? $post_id : null ) ) ); + wp_enqueue_script( 'jcf-simpleupload-modal', jcf_plugin_url( 'components/simplemedia/assets/simplemedia-modal.js' ), array( + 'jquery', + 'media-models', + 'jcf_edit_post', + ) ); + + // add text domain if not registered with another component. global $wp_scripts; - if ( empty($wp_scripts->registered['jcf_fields_group']) && empty($wp_scripts->registered['jcf_related_content']) ) { - wp_localize_script('jcf_simplemedia', 'jcf_textdomain', jcf_get_language_strings()); + if ( empty( $wp_scripts->registered['jcf_fields_group'] ) && empty( $wp_scripts->registered['jcf_related_content'] ) ) { + wp_localize_script( 'jcf_simplemedia', 'jcf_textdomain', jcf_get_language_strings() ); } } - - public function add_css() - { - wp_register_style('jcf_simplemedia', jcf_plugin_url('components/simplemedia/assets/simplemedia.css'), array( 'thickbox', 'jcf_edit_post' )); - wp_enqueue_style('jcf_simplemedia'); + /** + * Add custom styles + */ + public function add_css() { + wp_register_style( 'jcf_simplemedia', jcf_plugin_url( 'components/simplemedia/assets/simplemedia.css' ), array( + 'thickbox', + 'jcf_edit_post', + ) ); + wp_enqueue_style( 'jcf_simplemedia' ); } /** - * print field values inside the shortcode + * Print field values inside the shortcode * - * @params array $args shortcode args + * @param array $args shortcode args. + * + * @return mixed */ - public function shortcode_value( $args ) - { - if ( empty($this->entry) ) return ''; + public function shortcode_value( $args ) { + if ( empty( $this->entry ) ) { + return ''; + } - $size = isset($args['size'])? $args['size'] : 'thumbnail'; - $value = wp_get_attachment_image($this->entry, $size); + $size = isset( $args['size'] ) ? $args['size'] : 'thumbnail'; + $value = wp_get_attachment_image( $this->entry, $size ); return $args['before_value'] . $value . $args['after_value']; } } + ?> diff --git a/components/table/JustField_Table.php b/components/table/JustField_Table.php index 7af59c3..c892c15 100644 --- a/components/table/JustField_Table.php +++ b/components/table/JustField_Table.php @@ -10,61 +10,59 @@ * @package default * @author Sergey Samoylov */ -class JustField_Table extends core\JustField -{ +class JustField_Table extends core\JustField { - public function __construct() - { + public function __construct() { $field_ops = array( 'classname' => 'field_table' ); - parent::__construct('table', __('Table', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'table', __( 'Table', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { - if ( empty($this->entry) ) + public function field() { + if ( empty( $this->entry ) ) { $this->entry = array(); + } - // add null element for etalon copy + // add null element for etalon copy. $entries = (array) $this->entry; - // get fields - $columns = $this->parseColumnsOptions(); + // get fields. + $columns = $this->parse_columns_options(); - if ( !empty($columns) ) { - // generate th headings and row to be cloned - $count_cols = count($columns); + if ( ! empty( $columns ) ) { + // generate th headings and row to be cloned. + $count_cols = count( $columns ); $table_headers = 'Options'; - $clone_row = ' + $clone_row = ' '; - foreach ($columns as $col_name => $col_title) { + foreach ( $columns as $col_name => $col_title ) { $table_headers .= '' . $col_title . ''; - $clone_row .= ''; + $clone_row .= ''; } - // generate rows html + // generate rows html. $rows = ''; - $rows .= '' - . __('No data yet.', \JustCustomFields::TEXTDOMAIN) - . ''; + $rows .= '' + . __( 'No data yet.', \JustCustomFields::TEXTDOMAIN ) + . ''; - foreach ($entries as $key => $entry) { + foreach ( $entries as $key => $entry ) { $rows .= ' '; - foreach ($columns as $col_name => $col_title) { - $rows .= ' + foreach ( $columns as $col_name => $col_title ) { + $rows .= ' '; } @@ -72,169 +70,222 @@ public function field() } } ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> - - -
- - - - - - - - - - -
-

-
- -

- - - instance['description'] != '' ): ?> -

instance['description']); ?>

- + field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> + + +
+ + + + + + + + + + +
+

+

+
+ +

+ + + instance['description'] ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
instance, array( 'title' => '', 'columns' => '', 'description' => '' )); - - $title = esc_attr($instance['title']); - $columns = esc_html($instance['columns']); - $description = esc_html($instance['description']); + public function form() { + // Defaults. + $instance = wp_parse_args( (array) $this->instance, array( + 'title' => '', + 'columns' => '', + 'description' => '', + ) ); + + $title = esc_attr( $instance['title'] ); + $columns = esc_html( $instance['columns'] ); + $description = esc_html( $instance['description'] ); ?> -

-

-

- -
Example: username|User name', \JustCustomFields::TEXTDOMAIN); ?>

-

-

+

+ + +

+

+ + +
+ Example: username|User name', \JustCustomFields::TEXTDOMAIN ); ?> +

+

+ +

$params ) { - if ( !is_array($params) || !empty($params['__delete__']) ) { + if ( ! is_array( $params ) || ! empty( $params['__delete__'] ) ) { continue; } - unset($params['__delete__']); - $values[$key] = $params; + unset( $params['__delete__'] ); + $values[ $key ] = $params; } - $values = array_values($values); + $values = array_values( $values ); + return $values; } /** - * update instance (settings) for current field + * Update instance (settings) for current field + * + * @param array $new_instance New instance. + * @param array $old_instance Old instance. + * + * @return array */ - public function update( $new_instance, $old_instance ) - { - $instance = $old_instance; - $instance['title'] = strip_tags($new_instance['title']); - $instance['columns'] = strip_tags($new_instance['columns']); - $instance['description'] = strip_tags($new_instance['description']); + public function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['columns'] = strip_tags( $new_instance['columns'] ); + $instance['description'] = strip_tags( $new_instance['description'] ); + return $instance; } /** - * custom get_field functions to add one more deep level + * Custom get_field functions to add one more deep level + * + * @param mixed $field Field. + * @param mixed $number Number. + * + * @return mixed */ - protected function get_field_id_l2( $field, $number ) - { - return $this->get_field_id( $number . '-' . $field); + protected function get_field_id_l2( $field, $number ) { + return $this->get_field_id( $number . '-' . $field ); } - protected function get_field_name_l2( $field, $number ) - { - return $this->get_field_name( $number . '][' . $field); + /** + * Custom get_field functions to add one more deep level + * + * @param mixed $field Field. + * @param mixed $number Number. + * + * @return mixed + */ + protected function get_field_name_l2( $field, $number ) { + return $this->get_field_name( $number . '][' . $field ); } - public function add_js() - { + + /** + * Add custom scripts + */ + public function add_js() { global $wp_version; - wp_register_script('jcf_table', jcf_plugin_url('components/table/table.js'), array( 'jquery', 'jquery-ui-sortable', 'jcf_edit_post' )); - wp_enqueue_script('jcf_table'); + wp_register_script( 'jcf_table', jcf_plugin_url( 'components/table/table.js' ), array( + 'jquery', + 'jquery-ui-sortable', + 'jcf_edit_post', + ) ); + wp_enqueue_script( 'jcf_table' ); - // add text domain if not registered with another component + // add text domain if not registered with another component. global $wp_scripts; - wp_localize_script('jcf_table', 'jcf_textdomain', jcf_get_language_strings()); + wp_localize_script( 'jcf_table', 'jcf_textdomain', jcf_get_language_strings() ); } - public function add_css() - { - wp_register_style('jcf_table', jcf_plugin_url('components/table/table.css'), array( 'jcf_edit_post' )); - wp_enqueue_style('jcf_table'); + /** + * Add custom styles + */ + public function add_css() { + wp_register_style( 'jcf_table', jcf_plugin_url( 'components/table/table.css' ), array( 'jcf_edit_post' ) ); + wp_enqueue_style( 'jcf_table' ); } /** - * parse columns from settings + * Parse columns from settings + * * @return array */ - protected function parseColumnsOptions() - { - $columns = array(); - $_columns = explode("\n", $this->instance['columns']); + protected function parse_columns_options() { + $columns = array(); + $_columns = explode( "\n", $this->instance['columns'] ); foreach ( $_columns as $line ) { - $line = trim($line); - if ( strpos($line, '|') !== FALSE ) { - $col_name = explode('|', $line); - $columns[$col_name[0]] = $col_name[1]; - } - elseif ( !empty($line) ) { - $columns[$line] = $line; + $line = trim( $line ); + if ( strpos( $line, '|' ) !== false ) { + $col_name = explode( '|', $line ); + $columns[ $col_name[0] ] = $col_name[1]; + } elseif ( ! empty( $line ) ) { + $columns[ $line ] = $line; } } + return $columns; } /** - * print fields values from shortcode + * Print field values inside the shortcode + * + * @param array $args shortcode args. + * + * @return mixed */ - public function shortcode_value( $args ) - { - $columns = $this->parseColumnsOptions(); - if ( empty($columns) || empty($this->entry) ) + public function shortcode_value( $args ) { + $columns = $this->parse_columns_options(); + if ( empty( $columns ) || empty( $this->entry ) ) { return ''; + } - $count_cols = count($columns); + $count_cols = count( $columns ); $thead_columns = ''; - $html = $rows = ''; + $html = $rows = ''; foreach ( $this->entry as $key => $entry ) { $rows .= ''; foreach ( $columns as $col_name => $col_title ) { if ( $key == 0 ) { - $thead_columns .= '' . esc_html($col_title) . ''; + $thead_columns .= '' . esc_html( $col_title ) . ''; } - $rows .= '' . esc_html($entry[$col_name]) . ''; + $rows .= '' . esc_html( $entry[ $col_name ] ) . ''; } $rows .= ''; } @@ -242,6 +293,7 @@ public function shortcode_value( $args ) $html .= '' . $thead_columns . ''; $html .= $rows; $html .= ''; + return $args['before_value'] . $html . $args['after_value']; } diff --git a/components/textarea/JustField_Textarea.php b/components/textarea/JustField_Textarea.php index 3b82e2d..8759483 100644 --- a/components/textarea/JustField_Textarea.php +++ b/components/textarea/JustField_Textarea.php @@ -10,119 +10,143 @@ * @package default * @author Alexander Prokopenko */ -class JustField_Textarea extends core\JustField -{ +class JustField_Textarea extends core\JustField { - public function __construct() - { + /** + * Class constructor + **/ + public function __construct() { $field_ops = array( 'classname' => 'field_textarea' ); - parent::__construct('textarea', __('Textarea', \JustCustomFields::TEXTDOMAIN), $field_ops); + parent::__construct( 'textarea', __( 'Textarea', \JustCustomFields::TEXTDOMAIN ), $field_ops ); } /** - * draw field on post edit form - * you can use $this->instance, $this->entry + * Draw field on post edit form + * you can use $this->instance, $this->entry */ - public function field() - { + public function field() { ?> -
+
field_options['before_widget']; ?> - field_options['before_title'] . esc_html($this->instance['title']) . $this->field_options['after_title']; ?> - instance['editor']) ) : // check editor - - ob_start(); - /** - * @todo have bug with switching editor/text after ajax field loading, now disabled this functionality - * @author Kirill Samojlenko - */ - wp_editor($this->entry, $this->get_field_id('val'), array( - 'textarea_name' => $this->get_field_name('val'), - 'textarea_rows' => 5, - 'media_buttons' => true, - 'wpautop' => true, - 'quicktags' => false, - 'tinymce' => array( - 'theme_advanced_buttons1' => 'bold,italic,strikethrough,|,bullist,numlist,blockquote,|,justifyleft,justifycenter,justifyright,|,link,unlink,|,spellchecker,fullscreen,wp_adv', - ), - )); - echo ob_get_clean(); - - if ( defined('DOING_AJAX') && DOING_AJAX ) : - ?> - - - - is_taxonomy_field() ) : ?> - + + + is_taxonomy_field() ) : ?> + - + }); + + - - entry); ?> - - + + entry ); ?> + + - instance['description']) ) : ?> -

instance['description']); ?>

- + instance['description'] ) ) : ?> +

instance['description'] ); ?>

+ field_options['after_widget']; ?>
instance, array( 'title' => '', 'description' => '' )); - $title = esc_attr($instance['title']); - $description = esc_html($instance['description']); - $checked = !empty($instance['editor']) ? ' checked="checked" ' : ''; + public function form() { + // Defaults. + $instance = wp_parse_args( (array) $this->instance, array( 'title' => '', 'description' => '' ) ); + $title = esc_attr( $instance['title'] ); + $description = esc_html( $instance['description'] ); + $checked = ! empty( $instance['editor'] ) ? ' checked="checked" ' : ''; ?> -

-

-

+

+ + +

+

+

+ +

instance['editor'] ) { - $values = wpautop($values); + $values = wpautop( $values ); } + return $values; } /** - * update instance (settings) for current field + * Update instance (settings) for current field + * + * @param array $new_instance New instance. + * @param array $old_instance Old instance. + * + * @return array */ - public function update( $new_instance, $old_instance ) - { - $instance = $old_instance; - $instance['title'] = strip_tags($new_instance['title']); - $instance['editor'] = (int) @$new_instance['editor']; - $instance['description'] = strip_tags($new_instance['description']); + public function update( $new_instance, $old_instance ) { + $instance = $old_instance; + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['editor'] = (int) @$new_instance['editor']; + $instance['description'] = strip_tags( $new_instance['description'] ); + return $instance; } } + ?> \ No newline at end of file diff --git a/views/_header.php b/views/_header.php index 6a12ab9..b9da60d 100644 --- a/views/_header.php +++ b/views/_header.php @@ -1,8 +1,6 @@
-

+

- - - - + + diff --git a/views/_notices.php b/views/_notices.php index 4f5e4bd..15661be 100644 --- a/views/_notices.php +++ b/views/_notices.php @@ -1,17 +1,17 @@ -_messages) ) :?> - _messages as $message ):?> -
+_messages ) ) : ?> + _messages as $message ) : ?> +

- ' . __('Dismiss this notice.', \JustCustomFields::TEXTDOMAIN) . '') ?> + ' . esc_html__( 'Dismiss this notice.', \JustCustomFields::TEXTDOMAIN ) . '' ) ?>
-_errors) ) :?> - _errors as $error ):?> -
-

- ' . __('Dismiss this notice.', \JustCustomFields::TEXTDOMAIN) . ''); ?> +_errors ) ) : ?> + _errors as $error ) : ?> +
+

+ ' . esc_html__( 'Dismiss this notice.', \JustCustomFields::TEXTDOMAIN ) . '' ); ?>
\ No newline at end of file From 1719c750c294e5439f3730eb5f589e57769a09ea Mon Sep 17 00:00:00 2001 From: evkos Date: Tue, 20 Jun 2017 09:59:46 +0300 Subject: [PATCH 15/16] correct views --- components/select/JustField_Select.php | 2 +- .../JustField_SelectMultiple.php | 2 +- views/admin/index.php | 42 ++- views/fields/collection.php | 43 +-- views/fields/form.php | 66 +++-- views/fieldsets/_taxonomy_meta_box.php | 38 ++- views/fieldsets/form.php | 79 ++++-- views/fieldsets/index.php | 256 ++++++++++-------- views/fieldsets/visibility/form.php | 118 ++++---- views/fieldsets/visibility/rules.php | 108 ++++---- .../fieldsets/visibility/taxonomies_list.php | 35 ++- views/fieldsets/visibility/templates_list.php | 26 +- views/fieldsets/visibility/terms_list.php | 66 +++-- views/import_export/_fields.php | 129 +++++---- 14 files changed, 582 insertions(+), 428 deletions(-) diff --git a/components/select/JustField_Select.php b/components/select/JustField_Select.php index d3fa4b6..65ebe3f 100644 --- a/components/select/JustField_Select.php +++ b/components/select/JustField_Select.php @@ -76,7 +76,7 @@ public function form() {
- label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+ label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>


- label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+ label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>

diff --git a/views/admin/index.php b/views/admin/index.php index 13bc280..c7ab767 100644 --- a/views/admin/index.php +++ b/views/admin/index.php @@ -1,21 +1,31 @@ - +

-
+

-

+

Post Types

-
+

Taxonomies

- + diff --git a/views/fields/collection.php b/views/fields/collection.php index 5d1c9ad..b0bd120 100644 --- a/views/fields/collection.php +++ b/views/fields/collection.php @@ -2,10 +2,10 @@   - - - - + + + + @@ -14,16 +14,16 @@
- - - + + + + value=""/>
@@ -31,40 +31,41 @@ - + $field ) : ?> - + + rel="">
- + | - +
- + + align="center"> diff --git a/views/fields/form.php b/views/fields/form.php index 8a63ddc..61a3db1 100644 --- a/views/fields/form.php +++ b/views/fields/form.php @@ -1,68 +1,78 @@ -id_base == $field->id ) ? __( 'Add', \JustCustomFields::TEXTDOMAIN ) : __( 'Edit', \JustCustomFields::TEXTDOMAIN ); ?> +id_base === $field->id ) ? __( 'Add', \JustCustomFields::TEXTDOMAIN ) : __( 'Edit', \JustCustomFields::TEXTDOMAIN ); ?>
-

title; ?>

+

title ); ?>

- - - - + + + + is_collection_field() ) : ?> - + form(); - // need to add slug field too + // need to add slug field too. $slug = esc_attr( $field->slug ); ?>

- - + + value=""/>
- +

is_new ) { $field->instance['enabled'] = 1; } ?>

-

is_collection_field() ) : ?> - id_base == 'inputtext' ) : ?> + id_base ) : ?>

-

- +

@@ -70,15 +80,15 @@ class="media-modal-icon">
- + | + class="field-control-remove submitdelete"> | + class="field-control-close">
-

diff --git a/views/fieldsets/_taxonomy_meta_box.php b/views/fieldsets/_taxonomy_meta_box.php index 023cd23..bb9b82f 100644 --- a/views/fieldsets/_taxonomy_meta_box.php +++ b/views/fieldsets/_taxonomy_meta_box.php @@ -1,17 +1,27 @@ - - - - - -
-

-
- -
+ + + + + +
+

+
+
- - - - +
+ + + + diff --git a/views/fieldsets/form.php b/views/fieldsets/form.php index d9b248c..2be1df8 100644 --- a/views/fieldsets/form.php +++ b/views/fieldsets/form.php @@ -1,10 +1,14 @@
-

- +

+
- +

- - + +

- +

-
+

-
+

- +

- - - + + +

-
- - _render('fieldsets/visibility/rules', array( - 'visibility_rules' => $fieldset['visibility_rules'], - 'post_type' => $post_type - )); ?> - +
+ + _render( 'fieldsets/visibility/rules', array( + 'visibility_rules' => $fieldset['visibility_rules'], + 'post_type' => $post_type, + ) ); ?> + ajax_get_visibility_form(); ?>
@@ -67,11 +86,15 @@
- | - + + | +
- +

diff --git a/views/fieldsets/index.php b/views/fieldsets/index.php index 3f8718b..1b86fa7 100644 --- a/views/fieldsets/index.php +++ b/views/fieldsets/index.php @@ -1,5 +1,7 @@ - + -

» - label; ?> » +

+ » + label ); ?> » +

- - + +
- - - -
-
-

+ + + +
+
+

- + + - - + + -

-
- - - - - - - - - - - - - - - - - - $enabled) : - if ( empty($field_settings[$field_id]) ) continue; - ?> - - - - - - - - - - + +
+
 
 
- - - -
- | - -
- -
    -
  • :
  • -
  • :
  • -
  • :
  • -
- -
- _render( 'fields/collection', array( - 'collection' => isset($collections[$field_id])? $collections[$field_id] : array(), - 'collection_id' => $field_id, - 'fieldset_id' => $fieldset['id'], - 'registered_fields' => $collections['registered_fields'], - 'post_type_kind' => $post_type_kind, - )); ?>
+ + + + + + + + + + + + + + + + - - - + + + + $enabled ) : + if ( empty( $field_settings[ $field_id ] ) ) { + continue; + } + ?> + + + + + + + + + + + + + + + + + + +
 
 
+ + + +
+ + | + +
+ +
    +
  • + : +
  • +
  • + : +
  • +
  • + :
  • +
+ +
+ _render( 'fields/collection', array( + 'collection' => isset( $collections[ $field_id ] ) ? $collections[ $field_id ] : array(), + 'collection_id' => $field_id, + 'fieldset_id' => $fieldset['id'], + 'registered_fields' => $collections['registered_fields'], + 'post_type_kind' => $post_type_kind, + ) ); ?>
+
+ +
+ +
+ + + + + +
+ +
- - -
- -
-
-
- - - - - -
-
-
- -
-
-

- - +
+
+
+ +
- - + +
-

+

- - - + + +
@@ -139,11 +179,11 @@
- - + +
- - \ No newline at end of file + + diff --git a/views/fieldsets/visibility/form.php b/views/fieldsets/visibility/form.php index b23657e..98dc883 100644 --- a/views/fieldsets/visibility/form.php +++ b/views/fieldsets/visibility/form.php @@ -1,14 +1,18 @@ '', + 'rule_id' => '', 'visibility_option' => FieldsetVisibility::VISIBILITY_HIDE, - 'join_condition' => FieldsetVisibility::JOIN_AND, - 'based_on' => '', + 'join_condition' => FieldsetVisibility::JOIN_AND, + 'based_on' => '', ); } @@ -17,55 +21,57 @@
- +
-

- /> - +

+ /> +
- /> - +
- -
+ +

- -
+ +

-
+
@@ -73,38 +79,40 @@

- + _render('fieldsets/visibility/terms_list', array( - 'taxonomies' => $taxonomies, - 'current_tax' => $visibility_rule['rule_taxonomy'], - 'terms' => $terms, - 'current_term' => $visibility_rule['rule_taxonomy_terms'] - )); + $this->_render( 'fieldsets/visibility/terms_list', array( + 'taxonomies' => $taxonomies, + 'current_tax' => $visibility_rule['rule_taxonomy'], + 'terms' => $terms, + 'current_term' => $visibility_rule['rule_taxonomy_terms'], + ) ); ?> - + _render('fieldsets/visibility/templates_list', array( - 'templates' => $templates, - 'current' => $visibility_rule['rule_templates'] - )); + $this->_render( 'fieldsets/visibility/templates_list', array( + 'templates' => $templates, + 'current' => $visibility_rule['rule_templates'], + ) ); ?> - +
- - + + - - - - - + + + + + - - - + + +
diff --git a/views/fieldsets/visibility/rules.php b/views/fieldsets/visibility/rules.php index 486a493..16d62c2 100644 --- a/views/fieldsets/visibility/rules.php +++ b/views/fieldsets/visibility/rules.php @@ -1,74 +1,82 @@ {based_on} in {terms}'; -$row_index = 1; +$row_index = 1; ?>
- - - - - + + + + + - $rule ) : + $rule ) : - if ( $rule['based_on'] == 'taxonomy' ) { - $tax = get_taxonomy($rule['rule_taxonomy']); - $based_on = $tax->labels->singular_name; + if ( 'taxonomy' === $rule['based_on'] ) { + $tax = get_taxonomy( $rule['rule_taxonomy'] ); + $based_on = $tax->labels->singular_name; - $terms_list = array(); - if ( !empty($rule['rule_taxonomy_terms']) ) { - foreach ( $rule['rule_taxonomy_terms'] as $term_id ) { - $term_obj = get_term_by('id', $term_id, $rule['rule_taxonomy']); - $terms_list[] = $term_obj->name; - } + $terms_list = array(); + if ( ! empty( $rule['rule_taxonomy_terms'] ) ) { + foreach ( $rule['rule_taxonomy_terms'] as $term_id ) { + $term_obj = get_term_by( 'id', $term_id, $rule['rule_taxonomy'] ); + $terms_list[] = $term_obj->name; } - $terms = implode(', ', $terms_list); } - else { - $based_on = 'Page Template'; - - $tpl_selected = array(); - foreach ( $rule['rule_templates'] as $tpl ) { - if ( !isset($templates[$tpl]) ) continue; + $terms = implode( ', ', $terms_list ); + } else { + $based_on = 'Page Template'; - $tpl_selected[] = $templates[$tpl]; + $tpl_selected = array(); + foreach ( $rule['rule_templates'] as $tpl ) { + if ( ! isset( $templates[ $tpl ] ) ) { + continue; } - $terms = implode(', ', $tpl_selected); + + $tpl_selected[] = $templates[ $tpl ]; } + $terms = implode( ', ', $tpl_selected ); + } - // generate name based on patter - $rule_text = strtr($rule_text_pattern, array( - '{show_hide}' => ucfirst($rule['visibility_option']), - '{based_on}' => $based_on, - '{terms}' => $terms, - )); - ?> - - - - - - + // generate name based on patter. + $rule_text = strtr( $rule_text_pattern, array( + '{show_hide}' => ucfirst( $rule['visibility_option'] ), + '{based_on}' => $based_on, + '{terms}' => $terms, + ) ); + ?> + + + + + +
#
#
- 2 ) : ?> -
- - -
- - -
+ 2 ) : ?> +
+ + +
+ + +
-

+

diff --git a/views/fieldsets/visibility/taxonomies_list.php b/views/fieldsets/visibility/taxonomies_list.php index 94e1e04..6c6688c 100644 --- a/views/fieldsets/visibility/taxonomies_list.php +++ b/views/fieldsets/visibility/taxonomies_list.php @@ -1,29 +1,36 @@ - +

- +

- + _render('fieldsets/visibility/terms_list', array( - 'terms' => $terms, - 'current_term' => $current_term - )); + $this->_render( 'fieldsets/visibility/terms_list', array( + 'terms' => $terms, + 'current_term' => $current_term, + ) ); ?>
- -

+ +

- diff --git a/views/fieldsets/visibility/templates_list.php b/views/fieldsets/visibility/templates_list.php index fabc92e..5c0be2c 100644 --- a/views/fieldsets/visibility/templates_list.php +++ b/views/fieldsets/visibility/templates_list.php @@ -1,19 +1,27 @@ - +
-

+

    $name ): ?> + foreach ( $templates as $path => $name ) : ?>
  • - /> - + /> +

- -

+ +

diff --git a/views/fieldsets/visibility/terms_list.php b/views/fieldsets/visibility/terms_list.php index 6b484ae..8f6f382 100644 --- a/views/fieldsets/visibility/terms_list.php +++ b/views/fieldsets/visibility/terms_list.php @@ -1,42 +1,52 @@ -taxonomy); ?> - -

labels->name . ':', \JustCustomFields::TEXTDOMAIN); ?>

- +taxonomy ); + +?> + +

labels->name . ':', \JustCustomFields::TEXTDOMAIN ); ?>

+
    + foreach ( $terms as $term ) : ?>
  • - term_id, $current_term), true); ?> - id="rule_taxonomy_term_term_id; ?>" /> - + term_id, $current_term ), true ); ?> + id="rule_taxonomy_term_term_id ); ?>"/> +
  • - +
- +
- +
    - - - term_id, $current_term) ) : ?> + + + term_id, $current_term ) ) : ?>
  • - - id="rule_taxonomy_term_term_id; ?>" /> - + + id="rule_taxonomy_term_term_id ); ?>"/> +
  • - - - + + +

- -

- \ No newline at end of file + +

+ diff --git a/views/import_export/_fields.php b/views/import_export/_fields.php index c1c33c0..9d92384 100644 --- a/views/import_export/_fields.php +++ b/views/import_export/_fields.php @@ -4,92 +4,109 @@ /* @var $field_settings array */ ?> $fieldset ) : ?> -
"> +
">

- "selected_data[{$pt_key}][{$fieldset_id}][id]", - 'value' => $fieldset_id, - 'class' => "jcf_fieldset_select_all", + "selected_data[{$pt_key}][{$fieldset_id}][id]", + 'value' => $fieldset_id, + 'class' => 'jcf_fieldset_select_all', 'data-fields_container' => "#jcf_fieldset_fields_{$pt_key}_{$fieldset_id}", - )); ?> + ) ); ?> - + +

-
"> +
"> - + + - - - - - + + + + + + - + $field ) : ?> "> - - - - - + + + + + - From b2dcaecbeb479bd1262bcf50670b85ed260eb16c Mon Sep 17 00:00:00 2001 From: evkos Date: Tue, 20 Jun 2017 18:51:30 +0300 Subject: [PATCH 16/16] finally check all plugin's files --- components/checkbox/JustField_Checkbox.php | 14 ++-- .../collection/JustField_Collection.php | 12 ++-- .../datepicker/JustField_DatePicker.php | 15 ++-- .../googlemaps/JustField_GoogleMaps.php | 16 +++-- components/inputtext/JustField_InputText.php | 6 +- .../JustField_RelatedContent.php | 38 +++++----- components/select/JustField_Select.php | 34 ++++----- .../JustField_SelectMultiple.php | 12 ++-- components/selectmultiple/views/form.tpl.php | 8 +-- .../simplemedia/JustField_SimpleMedia.php | 18 ++--- components/table/JustField_Table.php | 29 ++++---- components/textarea/JustField_Textarea.php | 10 +-- controllers/FieldsetController.php | 2 +- controllers/ImportExportController.php | 2 +- controllers/PostTypeController.php | 8 +-- controllers/SettingsController.php | 2 +- controllers/TaxonomyController.php | 8 +-- core/JustField.php | 6 +- core/JustFieldFactory.php | 2 +- core/PluginLoader.php | 2 +- functions/helpers.php | 34 ++++----- just-custom-fields.php | 17 +++-- models/Field.php | 4 +- models/Fieldset.php | 14 ++-- models/FieldsetVisibility.php | 10 +-- models/ImportExport.php | 14 ++-- models/Migrate.php | 4 +- models/Settings.php | 12 ++-- models/Shortcodes.php | 2 +- views/_footer.php | 3 +- views/_header.php | 2 +- views/_notices.php | 15 ++-- views/_tabs.php | 15 +++- views/admin/index.php | 10 +-- views/fields/collection.php | 22 +++--- views/fields/form.php | 20 +++--- views/fieldsets/form.php | 16 ++--- views/fieldsets/index.php | 56 +++++++-------- views/fieldsets/visibility/form.php | 30 ++++---- views/fieldsets/visibility/rules.php | 6 +- .../fieldsets/visibility/taxonomies_list.php | 6 +- views/fieldsets/visibility/templates_list.php | 4 +- views/fieldsets/visibility/terms_list.php | 4 +- views/import_export/_fields.php | 61 ++++++++-------- views/import_export/export.php | 44 +++++++----- views/import_export/import.php | 52 +++++++------- views/import_export/index.php | 38 +++++----- views/migrate/index.php | 44 ++++++------ views/migrate/upgraded.php | 8 +-- views/settings/index.php | 69 +++++++++++-------- views/shortcodes/modal.php | 34 ++++++--- 51 files changed, 495 insertions(+), 419 deletions(-) diff --git a/components/checkbox/JustField_Checkbox.php b/components/checkbox/JustField_Checkbox.php index 1d8786c..7043d6b 100644 --- a/components/checkbox/JustField_Checkbox.php +++ b/components/checkbox/JustField_Checkbox.php @@ -17,7 +17,7 @@ class JustField_Checkbox extends core\JustField { **/ public function __construct() { $field_ops = array( 'classname' => 'field_checkbox' ); - parent::__construct( 'checkbox', __( 'Checkbox', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'checkbox', __( 'Checkbox', 'jcf' ), $field_ops ); } /** @@ -29,7 +29,7 @@ public function field() { $values = $this->parsed_select_options( $this->instance ); if ( empty( $values ) ) { - echo '

' . __( 'Please check settings. Values are empty', \JustCustomFields::TEXTDOMAIN ) . '

'; + echo '

' . esc_html__( 'Please check settings. Values are empty', 'jcf' ) . '

'; return false; } @@ -46,7 +46,7 @@ class="jcf_edit_field field_options['classname'] ); $val ) : ?> entry ) ? true : false; + $checked = ( $val === $this->entry ) ? true : false; } else { $checked = in_array( $val, (array) $this->entry ); } @@ -80,20 +80,20 @@ public function form() { ) ); ?>

- +

- +
- label1|id1
label2|id2
label3', \JustCustomFields::TEXTDOMAIN ); ?>
+ label1|id1
label2|id2
label3', 'jcf' ); ?>

- + diff --git a/components/collection/JustField_Collection.php b/components/collection/JustField_Collection.php index 849f810..8e9f102 100644 --- a/components/collection/JustField_Collection.php +++ b/components/collection/JustField_Collection.php @@ -45,7 +45,7 @@ class JustField_Collection extends core\JustField { **/ public function __construct() { $field_ops = array( 'classname' => 'field_collection' ); - parent::__construct( 'collection', __( 'Collection', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'collection', __( 'Collection', 'jcf' ), $field_ops ); add_action( 'wp_ajax_jcf_collection_add_new_field_group', array( $this, 'ajax_return_collection_field_group', @@ -77,7 +77,7 @@ public function field() { $entries = (array) $this->entry; ?> -

field_options['before_widget']; ?> field_options['before_title'] . esc_html( $this->instance['title'] ) . $this->field_options['after_title']; ?> @@ -109,7 +109,7 @@ class="jcf_edit_field field_options['classname'] ); ?> + class="collection_undo_remove_group">
@@ -144,7 +144,7 @@ class="collection_undo_remove_group">

- + @@ -389,7 +389,7 @@ public function ajax_return_collection_field_group() { instance['title'] . ' Item' ); ?> + class="collection_undo_remove_group">

diff --git a/components/datepicker/JustField_DatePicker.php b/components/datepicker/JustField_DatePicker.php index fc92f78..81ab9f3 100644 --- a/components/datepicker/JustField_DatePicker.php +++ b/components/datepicker/JustField_DatePicker.php @@ -24,7 +24,7 @@ class JustField_DatePicker extends core\JustField { **/ public function __construct() { $field_ops = array( 'classname' => 'field_datepicker' ); - parent::__construct( 'datepicker', __( 'Date Picker', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'datepicker', __( 'Date Picker', 'jcf' ), $field_ops ); } /** @@ -50,8 +50,7 @@ class="jcf_edit_field field_options['classname'] ); jQuery("#get_field_id( 'val' ) ); ?>").datepicker({ dateFormat: "instance['date_format'] ) ? esc_attr( $this->instance['date_format'] ) : 'yy-mm-dd'; ?>" instance['show_monthes'] ) ) { - echo ', changeMonth: true, changeYear: true'; - } ?> + echo ', changeMonth: true, changeYear: true'; } ?> }); }); --> @@ -77,7 +76,7 @@ public function form() { $date_format = ! empty( $instance['date_format'] ) ? esc_attr( $instance['date_format'] ) : 'yy-mm-dd'; ?>

- + @@ -87,16 +86,16 @@ public function form() { id="get_field_id( 'show_monthes' ) ); ?>" name="get_field_name( 'show_monthes' ); ?>" type="checkbox" - value="1" /> + value="1" />

- +
- yy-mm-dd yy-mm-dd + target="_blank">

'field_googlemaps' ); - parent::__construct( 'googlemaps', __( 'Google Maps', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'googlemaps', __( 'Google Maps', 'jcf' ), $field_ops ); } /** @@ -153,19 +153,20 @@ public function form() { $api_key = Settings::get_google_maps_api_key(); ?> -
+

- + + name="get_field_name( 'title' ); ?>" type="text" + value=""/>

- +

+ class="widefat">

-
+
+ data-field_id="get_field_id( 'uploaded_file' ) ); ?>">
@@ -126,21 +126,21 @@ public function form() { $description = esc_html( $instance['description'] ); ?>

- +

- +

- +

diff --git a/components/table/JustField_Table.php b/components/table/JustField_Table.php index c892c15..beb225c 100644 --- a/components/table/JustField_Table.php +++ b/components/table/JustField_Table.php @@ -12,9 +12,12 @@ */ class JustField_Table extends core\JustField { + /** + * JustField_Table constructor. + */ public function __construct() { $field_ops = array( 'classname' => 'field_table' ); - parent::__construct( 'table', __( 'Table', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'table', __( 'Table', 'jcf' ), $field_ops ); } /** @@ -50,7 +53,7 @@ public function field() { // generate rows html. $rows = ''; $rows .= '
'; foreach ( $entries as $key => $entry ) { @@ -80,20 +83,20 @@ class="jcf_edit_field field_options['classname'] );
 
"jcf_field_select", - 'name' => "selected_data[{$pt_key}][{$fieldset_id}][fields][{$field_id}][id]", - 'value' => $field_id, - 'data-is_collection' => (int) preg_match('/^collection\-/', $field_id), + echo jcf_html_checkbox( array( + 'class' => "jcf_field_select", + 'name' => "selected_data[{$pt_key}][{$fieldset_id}][fields][{$field_id}][id]", + 'value' => $field_id, + 'data-is_collection' => (int) preg_match( '/^collection\-/', $field_id ), 'data-collection_container' => "#jcf_collection_fields_{$pt_key}_{$fieldset_id}_{$field_id}", - )); + ) ); ?>
    -
  • -
  • :
  • -
  • :
  • -
  • :
  • +
  • +
  • : +
  • +
  • : +
  • +
  • : +
"> + "> - - - - + + + + - $collection_field ): ?> - - - - - - - - + + + + + + + +
 
- "selected_data[{$pt_key}][{$fieldset_id}][fields][{$field_id}][collection_fields][{$collection_field_id}]", - 'value' => 1, - 'class' => "jcf-collection_field_select", - )); ?> - -
+ "selected_data[{$pt_key}][{$fieldset_id}][fields][{$field_id}][collection_fields][{$collection_field_id}]", + 'value' => 1, + 'class' => "jcf-collection_field_select", + ) ); ?> + +
' - . __( 'No data yet.', \JustCustomFields::TEXTDOMAIN ) + . __( 'No data yet.', 'jcf' ) . '
- + - + - +

+ class="button button-small jcf_add_row jcf_add_table_row">

-

+

instance['description'] ) : ?> @@ -116,25 +119,25 @@ public function form() { ) ); $title = esc_attr( $instance['title'] ); - $columns = esc_html( $instance['columns'] ); + $columns = $instance['columns']; $description = esc_html( $instance['description'] ); ?>

- +

- +
- Example: username|User name', \JustCustomFields::TEXTDOMAIN ); ?> + Example: username|User name', 'jcf' ); ?>

- +

@@ -282,7 +285,7 @@ public function shortcode_value( $args ) { $rows .= ''; foreach ( $columns as $col_name => $col_title ) { - if ( $key == 0 ) { + if ( 0 === $key ) { $thead_columns .= '' . esc_html( $col_title ) . ''; } $rows .= '' . esc_html( $entry[ $col_name ] ) . ''; diff --git a/components/textarea/JustField_Textarea.php b/components/textarea/JustField_Textarea.php index 8759483..b8b9f38 100644 --- a/components/textarea/JustField_Textarea.php +++ b/components/textarea/JustField_Textarea.php @@ -17,7 +17,7 @@ class JustField_Textarea extends core\JustField { **/ public function __construct() { $field_ops = array( 'classname' => 'field_textarea' ); - parent::__construct( 'textarea', __( 'Textarea', \JustCustomFields::TEXTDOMAIN ), $field_ops ); + parent::__construct( 'textarea', __( 'Textarea', 'jcf' ), $field_ops ); } /** @@ -47,7 +47,7 @@ class="jcf_edit_field field_options['classname'] ); ) ); echo ob_get_clean(); - if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) : + if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) : ?>
- -
+ +

We will launch several upgrade scripts:

    - $m) : ?> -
  • v upgrade
  • - + $m ) : ?> +
  • v upgrade
  • +
-
+ - /> + + />
- - + diff --git a/views/migrate/upgraded.php b/views/migrate/upgraded.php index 4b9476e..0a47c1f 100644 --- a/views/migrate/upgraded.php +++ b/views/migrate/upgraded.php @@ -4,13 +4,13 @@ /* @var $errors array */ ?>
-

+

Upgrade settings

-

All data upgraded. View settings

+

All data upgraded. View + settings

- - + diff --git a/views/settings/index.php b/views/settings/index.php index ca86c91..534616a 100644 --- a/views/settings/index.php +++ b/views/settings/index.php @@ -4,66 +4,77 @@ /* @var $googlemaps_api_key string */ use jcf\models\Settings; + ?> - +
-
-
+
+
-

+

/> -
+ value="" + id="jcf_read_db" /> +
- /> + />
+ File system: Current theme folder. Fields configuration is saved to the current theme folder in json format and can be copied to another site easily.', 'jcf' ); ?> +
/> + value="" + id="jcf_read_file_global" />
+ File system: Global (/wp-content/jcf/*). Fields configuration is saved to the wp-content folder in json format and can be copied to another site easily.', 'jcf' ); ?> +
- +
-

+

/> -
+ value="" /> +
/> -

+ value="" /> +

-

+

- +
+ value=""/>
-

Click here to generate your API Key.

-

Usually API key is domain related, so if you moved your site to a new domain - please update the API key.

-
+

Click here to generate your API Key.

+

+ Usually API key is domain related, so if you moved your site to a new domain - please update + the API key. + +

+
-

- - +

+ +
- + diff --git a/views/shortcodes/modal.php b/views/shortcodes/modal.php index 3607109..163f864 100644 --- a/views/shortcodes/modal.php +++ b/views/shortcodes/modal.php @@ -1,23 +1,37 @@ + +
-

- +

+

- - + + -
-

+
+ +

- - + + -
-

+
+ +