From e8023f13b0dce5b51cbc6e3851121e5f7335792a Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Fri, 1 Mar 2019 22:12:00 -0800 Subject: [PATCH 01/67] Add development tools --- .coveralls.yml | 3 + .dev-lib | 3 + .editorconfig | 18 +++++ .eslintignore | 3 + .eslintrc | 156 +++++++++++++++++++++++++++++++++++++++++++ .gitignore | 9 +++ .jscsrc | 9 +++ .jshintignore | 3 + .jshintrc | 24 +++++++ .phpcs.ruleset.xml | 48 +++++++++++++ .travis.yml | 35 ++++++++++ bin/install-tests.sh | 36 ++++++++++ bin/phpunit.sh | 19 ++++++ composer.json | 49 +++++++++++++- phpunit.xml.dist | 29 ++++++++ tests/autoload.php | 29 ++++++++ tests/bootstrap.php | 106 +++++++++++++++++++++++++++++ 17 files changed, 576 insertions(+), 3 deletions(-) create mode 100644 .coveralls.yml create mode 100644 .dev-lib create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 .gitignore create mode 100644 .jscsrc create mode 100644 .jshintignore create mode 100644 .jshintrc create mode 100644 .phpcs.ruleset.xml create mode 100644 .travis.yml create mode 100755 bin/install-tests.sh create mode 100755 bin/phpunit.sh create mode 100644 phpunit.xml.dist create mode 100644 tests/autoload.php create mode 100644 tests/bootstrap.php diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..3b85ca4 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci +coverage_clover: build/logs/clover.xml +json_path: build/logs/coveralls-upload.json diff --git a/.dev-lib b/.dev-lib new file mode 100644 index 0000000..b2e0c15 --- /dev/null +++ b/.dev-lib @@ -0,0 +1,3 @@ +DEFAULT_BASE_BRANCH=develop +PHPCS_IGNORE='vendor/*,tests/wp-tests/*' +CHECK_SCOPE=patches diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..21f03ed --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# WordPress Coding Standards +# https://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[{package.json,*.yml}] +indent_style = space +indent_size = 2 + +[{*.txt,wp-config-sample.php}] +end_of_line = crlf diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4cd1606 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +**/*.min.js +**/node_modules/** +**/vendor/** diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..6d40c00 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,156 @@ +{ + "env": { + "browser": true + }, + "globals": { + "_": false, + "Backbone": false, + "jQuery": false, + "wp": false + }, + "rules": { + "accessor-pairs": [2], + "block-scoped-var": [2], + "callback-return": [2], + "complexity": [2, 8], + "consistent-return": [2], + "consistent-this": [2, "self"], + "constructor-super": [2], + "default-case": [2], + "eqeqeq": [2], + "func-style": [0], + "global-require": [2], + "guard-for-in": [0], + "handle-callback-err": [2, "^err(or)?$"], + "id-length": [0], + "id-match": [0], + "indent": ["error", "tab"], + "init-declarations": [0], + "max-depth": [2, 3], + "max-nested-callbacks": [2, 3], + "max-params": [2, 4], + "max-statements": [0], + "new-parens": [0], + "no-alert": [0], + "no-array-constructor": [0], + "no-bitwise": [0], + "no-caller": [2], + "no-case-declarations": [2], + "no-catch-shadow": [2], + "no-class-assign": [2], + "no-cond-assign": [2], + "no-console": [0], + "no-const-assign": [2], + "no-constant-condition": [0], + "no-continue": [0], + "no-control-regex": [2], + "no-debugger": [2], + "no-delete-var": [2], + "no-div-regex": [0], + "no-dupe-args": [2], + "no-dupe-class-members": [2], + "no-dupe-keys": [2], + "no-duplicate-case": [2], + "no-else-return": [0], + "no-empty-character-class": [2], + "no-empty-pattern": [2], + "no-empty": [2], + "no-eq-null": [2], + "no-eval": [2], + "no-ex-assign": [2], + "no-extend-native": [0], + "no-extra-bind": [2], + "no-extra-boolean-cast": [2], + "no-extra-parens": [2], + "no-extra-semi": [2], + "no-fallthrough": [2], + "no-floating-decimal": [2], + "no-func-assign": [2], + "no-implicit-coercion": [2], + "no-implicit-globals": [0], + "no-implied-eval": [2], + "no-inline-comments": [0], + "no-inner-declarations": [2], + "no-invalid-regexp": [2], + "no-invalid-this": [0], + "no-irregular-whitespace": [2], + "no-iterator": [2], + "no-label-var": [2], + "no-labels": [0], + "no-lone-blocks": [2], + "no-lonely-if": [2], + "no-loop-func": [2], + "no-magic-numbers": [2, { "ignoreArrayIndexes": true, "ignore": [ -1, 0 ] }], + "no-mixed-requires": [0], + "no-multi-str": [2], + "no-native-reassign": [2], + "no-negated-condition": [0], + "no-negated-in-lhs": [2], + "no-nested-ternary": [0], + "no-new-func": [0], + "no-new-object": [2], + "no-new-require": [0], + "no-new-wrappers": [2], + "no-new": [2], + "no-obj-calls": [2], + "no-octal-escape": [2], + "no-octal": [2], + "no-param-reassign": [2], + "no-path-concat": [2], + "no-plusplus": [0], + "no-process-env": [2], + "no-process-exit": [0], + "no-proto": [2], + "no-redeclare": [2], + "no-regex-spaces": [0], + "no-restricted-imports": [0], + "no-restricted-syntax": [0], + "no-return-assign": [2], + "no-script-url": [0], + "no-self-compare": [2], + "no-sequences": [2], + "no-shadow-restricted-names": [2], + "no-shadow": [2], + "no-sparse-arrays": [2], + "no-sync": [0], + "no-ternary": [0], + "no-trailing-spaces": [2], + "no-this-before-super": [2], + "no-throw-literal": [2], + "no-undef-init": [0], + "no-undef": [2], + "no-undefined": [0], + "no-unneeded-ternary": [2], + "no-unreachable": [2], + "no-unused-expressions": [2], + "no-unused-vars": [2], + "no-use-before-define": [0], + "no-useless-call": [2], + "no-useless-concat": [2], + "no-var": [0], + "no-void": [0], + "no-with": [2], + "object-shorthand": [0], + "one-var": [ 2, "always" ], + "operator-assignment": [2, "always"], + "prefer-arrow-callback": [0], + "prefer-const": [0], + "prefer-reflect": [0], + "prefer-rest-params": [0], + "prefer-spread": [0], + "prefer-template": [0], + "quotes": [0], + "radix": [2, "always"], + "require-yield": [0], + "sort-imports": [0], + "sort-vars": [0], + "strict": [2, "function"], + "use-isnan": [2], + "valid-typeof": [2], + "valid-jsdoc": [2], + "vars-on-top": [0], + "wrap-iife": [2, "inside"], + "wrap-regex": [0], + "yoda": [0] + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2c309f --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +.DS_Store + +# PHPUnit +/coverage +/tests/wp-tests + +# Composer +/vendor +composer.lock diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..12757e3 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,9 @@ +{ + "preset": "wordpress", + "excludeFiles": [ + "**/*.min.js", + "**/*.jsx", + "**/node_modules/**", + "**/vendor/**" + ] +} diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 0000000..4cd1606 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,3 @@ +**/*.min.js +**/node_modules/** +**/vendor/** diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..cdc6e31 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,24 @@ +{ + "boss": true, + "curly": true, + "eqeqeq": true, + "eqnull": true, + "es3": true, + "expr": true, + "immed": true, + "noarg": true, + "nonbsp": true, + "onevar": true, + "quotmark": "single", + "trailing": true, + "undef": true, + "unused": true, + "browser": true, + "globals": { + "_": false, + "Backbone": false, + "jQuery": false, + "JSON": false, + "wp": false + } +} diff --git a/.phpcs.ruleset.xml b/.phpcs.ruleset.xml new file mode 100644 index 0000000..350f456 --- /dev/null +++ b/.phpcs.ruleset.xml @@ -0,0 +1,48 @@ + + + Custom ruleset for the Option Tree plugin. + + + + + + . + + /vendor/* + /tests/wp-tests/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..8c5d8e2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: php + +sudo: false + +dist: precise + +notifications: + email: + on_success: never + on_failure: change + +cache: + directories: + - vendor + - $HOME/phpunit-bin + +php: + - 5.3 + - 5.6 + - 7.3 + +env: + - WP_VERSION=latest WP_MULTISITE=0 + - WP_VERSION=latest WP_MULTISITE=1 + +install: + - composer install + - export DEV_LIB_PATH=vendor/xwp/wp-dev-lib/scripts + - source "$DEV_LIB_PATH/travis.install.sh" + +script: + - source "$DEV_LIB_PATH/travis.script.sh" + +after_script: + - source "$DEV_LIB_PATH/travis.after_script.sh" diff --git a/bin/install-tests.sh b/bin/install-tests.sh new file mode 100755 index 0000000..6660669 --- /dev/null +++ b/bin/install-tests.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +WP_VERSION=`grep "wp_version =" ../../../wp-includes/version.php | awk '{print $3}' | sed "s/'//g" | sed "s/;//g"` +WP_TESTS_DIR=tests/wp-tests + +function download { + if command -v curl >/dev/null 2>&1; then + curl -L -s "$1" > "$2" + elif command -v wget >/dev/null 2>&1; then + wget -n -O "$2" "$1" + else + echo '' + return 1 + fi +} + +if [[ ${WP_VERSION} =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then + WP_TESTS_TAG="tags/${WP_VERSION}" +elif [[ ${WP_VERSION} == 'nightly' || ${WP_VERSION} == 'trunk' ]]; then + WP_TESTS_TAG="trunk" +else + # http serves a single offer, whereas https serves multiple. we only want one + download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json + grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json + LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') + if [[ -z "$LATEST_VERSION" ]]; then + echo "Latest WordPress version could not be found." + exit 1 + fi + WP_TESTS_TAG="tags/$LATEST_VERSION" +fi + +echo "Installing WordPress PHPUnit Test Suite into '${WP_TESTS_DIR}' ..." + +rm -rf ${WP_TESTS_DIR} +svn co -q https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/ ${WP_TESTS_DIR} diff --git a/bin/phpunit.sh b/bin/phpunit.sh new file mode 100755 index 0000000..be62208 --- /dev/null +++ b/bin/phpunit.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Usage: ./tests/bin.sh xdebug_on +# Runs the PHPUnit tests with html coverage output in the VVV wordpress-default site. +# Setting xdebug_off or leaving it unset will run PHPUnit without creating a coverage report. + +set -e + +path=`pwd | sed 's/.*\(\/www\)/\1/g'` + +xdebug=$1 +if [ -z "$xdebug" ]; then + xdebug="xdebug_off" +fi + +if [ $xdebug = "xdebug_on" ]; then + COVERAGE="--coverage-html /srv/$path/coverage"; +fi + +vagrant ssh -c "$xdebug && cd "/srv/$path" && phpunit $COVERAGE" diff --git a/composer.json b/composer.json index 1c0825d..3832d21 100644 --- a/composer.json +++ b/composer.json @@ -11,9 +11,52 @@ "role": "Developer" } ], + "prefer-stable" : true, "require": { + "php": ">=5.3" }, - "autoload": { - "files": ["ot-loader.php"] + "require-dev": { + "brainmaestro/composer-git-hooks": "^2.6.0", + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/phpcompatibility-wp": "*", + "php-coveralls/php-coveralls": "^2.1", + "slowprog/composer-copy-file": "0.2.1", + "wp-coding-standards/wpcs": "*", + "xwp/wp-dev-lib": "^1.0.0" + }, + "scripts": { + "phpcs": [ + "./vendor/bin/phpcs ${1:.} --standard=.phpcs.ruleset.xml" + ], + "phpcbf": [ + "./vendor/bin/phpcbf ${1:.} --standard=.phpcs.ruleset.xml" + ], + "phpunit": [ + "./bin/phpunit.sh xdebug_off" + ], + "phpunit-coverage": [ + "./bin/phpunit.sh xdebug_on" + ], + "post-install-cmd": [ + "./bin/install-tests.sh", + "./vendor/bin/cghooks add --no-lock", + "SlowProg\\CopyFile\\ScriptHandler::copy" + ], + "post-update-cmd": [ + "./bin/install-tests.sh", + "./vendor/bin/cghooks update", + "SlowProg\\CopyFile\\ScriptHandler::copy" + ], + "readme": [ + "./vendor/xwp/wp-dev-lib/scripts/generate-markdown-readme" + ] + }, + "extra": { + "copy-file": { + "tests/autoload.php": "tests/wp-tests/phpunit/wp-tests-config.php" + }, + "hooks": { + "pre-commit": "./vendor/xwp/wp-dev-lib/scripts/pre-commit" + } } -} \ No newline at end of file +} diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..538cdea --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,29 @@ + + + + + + + ./tests/ + ./tests/ + + + + + + ./ + + ./coverage + ./tests + ./vendor + + + + diff --git a/tests/autoload.php b/tests/autoload.php new file mode 100644 index 0000000..8d633e8 --- /dev/null +++ b/tests/autoload.php @@ -0,0 +1,29 @@ + Date: Fri, 1 Mar 2019 23:08:23 -0800 Subject: [PATCH 02/67] Fix typo --- tests/bootstrap.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 162a358..5526bf5 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -92,7 +92,7 @@ function _phpunit_filter_active_plugins( $active_plugins ) { tests_add_filter( 'option_active_plugins', '_phpunit_filter_active_plugins' ); /** - * Load the plugins. + * Load the plugin. */ function _phpunit_load_plugin_file() { global $_plugin_file; From 23665cdf8986a02ec2b54bf7c5f40bea40e64178 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 01:26:51 -0800 Subject: [PATCH 03/67] Fix non critical phpcs issues --- .phpcs.ruleset.xml | 5 + ot-loader.php | 1511 +++++++++++++++++++++----------------------- 2 files changed, 727 insertions(+), 789 deletions(-) diff --git a/.phpcs.ruleset.xml b/.phpcs.ruleset.xml index 350f456..1289380 100644 --- a/.phpcs.ruleset.xml +++ b/.phpcs.ruleset.xml @@ -45,4 +45,9 @@ + + + + + diff --git a/ot-loader.php b/ot-loader.php index 949fe83..02d9b3f 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -3,804 +3,737 @@ * Plugin Name: OptionTree * Plugin URI: https://github.com/valendesigns/option-tree/ * Description: Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. - * Version: 2.6.0 + * Version: 2.7.0 * Author: Derek Herman * Author URI: http://valendesigns.com * License: GPLv3 * Text Domain: option-tree + * + * @package OptionTree */ -/** - * Forces Plugin Mode when OptionTree is already loaded and displays an admin notice. - */ -if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && OT_PLUGIN_MODE == true ) { - - add_filter( 'ot_theme_mode', '__return_false', 999 ); - - function ot_conflict_notice() { - - echo '

' . __( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '

'; - - } - - add_action( 'admin_notices', 'ot_conflict_notice' ); - +if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && true === OT_PLUGIN_MODE ) { + + add_filter( 'ot_theme_mode', '__return_false', 999 ); + + /** + * Forces Plugin Mode when OptionTree is already loaded and displays an admin notice. + */ + function ot_conflict_notice() { + + echo '

' . esc_html__( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '

'; + + } + + add_action( 'admin_notices', 'ot_conflict_notice' ); + } -/** - * This is the OptionTree loader class. - * - * @package OptionTree - * @author Derek Herman - * @copyright Copyright (c) 2013, Derek Herman - */ if ( ! class_exists( 'OT_Loader' ) ) { - class OT_Loader { - - /** - * PHP5 constructor method. - * - * This method loads other methods of the class. - * - * @return void - * - * @access public - * @since 2.0 - */ - public function __construct() { - - /* load languages */ - $this->load_languages(); - - /* load OptionTree */ - add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 ); - - } - - /** - * Load the languages before everything else. - * - * @return void - * - * @access private - * @since 2.1.3 - */ - private function load_languages() { - - /** - * A quick check to see if we're in plugin mode. - * - * @since 2.1.3 - */ - define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false ); - - /** - * Path to the languages directory. - * - * This path will be relative in plugin mode and absolute in theme mode. - * - * @since 2.0.10 - * @updated 2.4.1 - */ - if ( OT_PLUGIN_MODE ) { - - define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) ); - - } else { - - if ( apply_filters( 'ot_child_theme_mode', false ) == true ) { - - $path = @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); - $path = ltrim( end( $path ), '/' ); - define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); - - } else { - - $path = @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); - $path = ltrim( end( $path ), '/' ); - define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); - - } - - } - - /* load the text domain */ - if ( OT_PLUGIN_MODE ) { - - add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); - - } else { - - add_action( 'after_setup_theme', array( $this, 'load_textdomain' ) ); - - } - - } - - /** - * Load the text domain. - * - * @return void - * - * @access private - * @since 2.0 - */ - public function load_textdomain() { - - if ( OT_PLUGIN_MODE ) { - - load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR ); - - } else { - - load_theme_textdomain( 'option-tree', OT_LANG_DIR ); - - } - - } - - /** - * Load OptionTree on the 'after_setup_theme' action. Then filters will - * be availble to the theme, and not only when in Theme Mode. - * - * @return void - * - * @access public - * @since 2.1.2 - */ - public function load_option_tree() { - - /* setup the constants */ - $this->constants(); - - /* include the required admin files */ - $this->admin_includes(); - - /* include the required files */ - $this->includes(); - - /* hook into WordPress */ - $this->hooks(); - - } - - /** - * Constants - * - * Defines the constants for use within OptionTree. Constants - * are prefixed with 'OT_' to avoid any naming collisions. - * - * @return void - * - * @access private - * @since 2.0 - */ - private function constants() { - - /** - * Current Version number. - */ - define( 'OT_VERSION', '2.6.0' ); - - /** - * For developers: Theme mode. - * - * Run a filter and set to true to enable OptionTree theme mode. - * You must have this files parent directory inside of - * your themes root directory. As well, you must include - * a reference to this file in your themes functions.php. - * - * @since 2.0 - */ - define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) ); - - /** - * For developers: Child Theme mode. TODO document - * - * Run a filter and set to true to enable OptionTree child theme mode. - * You must have this files parent directory inside of - * your themes root directory. As well, you must include - * a reference to this file in your themes functions.php. - * - * @since 2.0.15 - */ - define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) ); - - /** - * For developers: Show Pages. - * - * Run a filter and set to false if you don't want to load the - * settings & documentation pages in the admin area of WordPress. - * - * @since 2.0 - */ - define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) ); - - /** - * For developers: Show Theme Options UI Builder - * - * Run a filter and set to false if you want to hide the - * Theme Options UI page in the admin area of WordPress. - * - * @since 2.1 - */ - define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) ); - - /** - * For developers: Show Settings Import - * - * Run a filter and set to false if you want to hide the - * Settings Import options on the Import page. - * - * @since 2.1 - */ - define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) ); - - /** - * For developers: Show Settings Export - * - * Run a filter and set to false if you want to hide the - * Settings Import options on the Import page. - * - * @since 2.1 - */ - define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) ); - - /** - * For developers: Show New Layout. - * - * Run a filter and set to false if you don't want to show the - * "New Layout" section at the top of the theme options page. - * - * @since 2.0.10 - */ - define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) ); - - /** - * For developers: Show Documentation - * - * Run a filter and set to false if you want to hide the Documentation. - * - * @since 2.1 - */ - define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) ); - - /** - * For developers: Custom Theme Option page - * - * Run a filter and set to false if you want to hide the OptionTree - * Theme Option page and build your own. - * - * @since 2.1 - */ - define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) ); - - /** - * For developers: Meta Boxes. - * - * Run a filter and set to false to keep OptionTree from - * loading the meta box resources. - * - * @since 2.0 - */ - define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) ); - - /** - * For developers: Allow Unfiltered HTML in all the textareas. - * - * Run a filter and set to true if you want all the - * users to be able to post anything in the textareas. - * WARNING: This opens a security hole for low level users - * to be able to post malicious scripts, you've been warned. - * - * @since 2.0 - */ - define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) ); - - /** - * For developers: Post Formats. - * - * Run a filter and set to true if you want OptionTree - * to load meta boxes for post formats. - * - * @since 2.4.0 - */ - define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) ); - - /** - * Check if in theme mode. - * - * If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the - * directory path & URL like any other plugin. Otherwise, use - * the parent or child themes root directory. - * - * @since 2.0 - */ - if ( false == OT_THEME_MODE && false == OT_CHILD_THEME_MODE ) { - define( 'OT_DIR', plugin_dir_path( __FILE__ ) ); - define( 'OT_URL', plugin_dir_url( __FILE__ ) ); - } else { - if ( true == OT_CHILD_THEME_MODE ) { - $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); - define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) ); - define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) ); - } else { - $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); - define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) ); - define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) ); - } - } - - /** - * Template directory URI for the current theme. - * - * @since 2.1 - */ - if ( true == OT_CHILD_THEME_MODE ) { - define( 'OT_THEME_URL', get_stylesheet_directory_uri() ); - } else { - define( 'OT_THEME_URL', get_template_directory_uri() ); - } - - } - - /** - * Include admin files - * - * These functions are included on admin pages only. - * - * @return void - * - * @access private - * @since 2.0 - */ - private function admin_includes() { - - /* exit early if we're not on an admin page */ - if ( ! is_admin() ) - return false; - - /* global include files */ - $files = array( - 'ot-functions-admin', - 'ot-functions-option-types', - 'ot-functions-compat', - 'ot-settings-api' - ); - - /* include the meta box api */ - if ( OT_META_BOXES == true ) { - $files[] = 'ot-meta-box-api'; - } - - /* include the post formats api */ - if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) { - $files[] = 'ot-post-formats-api'; - } - - /* include the settings & docs pages */ - if ( OT_SHOW_PAGES == true ) { - $files[] = 'ot-functions-settings-page'; - $files[] = 'ot-functions-docs-page'; - } - - /* include the cleanup api */ - $files[] = 'ot-cleanup-api'; - - /* require the files */ - foreach ( $files as $file ) { - $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" ); - } - - /* Registers the Theme Option page */ - add_action( 'init', 'ot_register_theme_options_page' ); - - /* Registers the Settings page */ - if ( OT_SHOW_PAGES == true ) { - add_action( 'init', 'ot_register_settings_page' ); - - /* global CSS */ - add_action( 'admin_head', array( $this, 'global_admin_css' ) ); - } - - } - - /** - * Include front-end files - * - * These functions are included on every page load - * incase other plugins need to access them. - * - * @return void - * - * @access private - * @since 2.0 - */ - private function includes() { - - $files = array( - 'ot-functions', - 'ot-functions-deprecated' - ); - - /* require the files */ - foreach ( $files as $file ) { - $this->load_file( OT_DIR . "includes" . DIRECTORY_SEPARATOR . "{$file}.php" ); - } - - } - - /** - * Execute the WordPress Hooks - * - * @return void - * - * @access public - * @since 2.0 - */ - private function hooks() { - - // Attempt to migrate the settings - if ( function_exists( 'ot_maybe_migrate_settings' ) ) - add_action( 'init', 'ot_maybe_migrate_settings', 1 ); - - // Attempt to migrate the Options - if ( function_exists( 'ot_maybe_migrate_options' ) ) - add_action( 'init', 'ot_maybe_migrate_options', 1 ); - - // Attempt to migrate the Layouts - if ( function_exists( 'ot_maybe_migrate_layouts' ) ) - add_action( 'init', 'ot_maybe_migrate_layouts', 1 ); - - /* load the Meta Box assets */ - if ( OT_META_BOXES == true ) { - - /* add scripts for metaboxes to post-new.php & post.php */ - add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 ); - add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 ); - - /* add styles for metaboxes to post-new.php & post.php */ - add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 ); - add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 ); - - } - - /* Adds the Theme Option page to the admin bar */ - add_action( 'admin_bar_menu', 'ot_register_theme_options_admin_bar_menu', 999 ); - - /* prepares the after save do_action */ - add_action( 'admin_init', 'ot_after_theme_options_save', 1 ); - - /* default settings */ - add_action( 'admin_init', 'ot_default_settings', 2 ); - - /* add xml to upload filetypes array */ - add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 ); - - /* import */ - add_action( 'admin_init', 'ot_import', 4 ); - - /* export */ - add_action( 'admin_init', 'ot_export', 5 ); - - /* save settings */ - add_action( 'admin_init', 'ot_save_settings', 6 ); - - /* save layouts */ - add_action( 'admin_init', 'ot_modify_layouts', 7 ); - - /* create media post */ - add_action( 'admin_init', 'ot_create_media_post', 8 ); - - /* Google Fonts front-end CSS */ - add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 ); - - /* dynamic front-end CSS */ - add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 ); - - /* insert theme CSS dynamically */ - add_action( 'ot_after_theme_options_save', 'ot_save_css' ); - - /* AJAX call to create a new section */ - add_action( 'wp_ajax_add_section', array( $this, 'add_section' ) ); - - /* AJAX call to create a new setting */ - add_action( 'wp_ajax_add_setting', array( $this, 'add_setting' ) ); - - /* AJAX call to create a new contextual help */ - add_action( 'wp_ajax_add_the_contextual_help', array( $this, 'add_the_contextual_help' ) ); - - /* AJAX call to create a new choice */ - add_action( 'wp_ajax_add_choice', array( $this, 'add_choice' ) ); - - /* AJAX call to create a new list item setting */ - add_action( 'wp_ajax_add_list_item_setting', array( $this, 'add_list_item_setting' ) ); - - /* AJAX call to create a new layout */ - add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) ); - - /* AJAX call to create a new list item */ - add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) ); - - /* AJAX call to create a new social link */ - add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) ); - - /* AJAX call to retrieve Google Font data */ - add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) ); - - // Adds the temporary hacktastic shortcode - add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 ); - - // AJAX update - add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) ); - - /* Modify the media uploader button */ - add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 ); - - } - - /** - * Load a file - * - * @return void - * - * @access private - * @since 2.0.15 - */ - private function load_file( $file ){ - - include_once( $file ); - - } - - /** - * Adds the global CSS to fix the menu icon. - */ - public function global_admin_css() { - global $wp_version; - - $wp_38plus = version_compare( $wp_version, '3.8', '>=' ) ? true : false; - $fontsize = $wp_38plus ? '20px' : '16px'; - $wp_38minus = ''; - - if ( ! $wp_38plus ) { - $wp_38minus = ' - #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image { - background: none; - } - #adminmenu #toplevel_page_ot-settings .menu-icon-generic div.wp-menu-image:before { - padding-left: 6px; - }'; - } - - echo ' - - '; - } - - /** - * AJAX utility function for adding a new section. - */ - public function add_section() { - echo ot_sections_view( ot_settings_id() . '[sections]', $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding a new setting. - */ - public function add_setting() { - echo ot_settings_view( $_REQUEST['name'], $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding a new list item setting. - */ - public function add_list_item_setting() { - echo ot_settings_view( $_REQUEST['name'] . '[settings]', $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding new contextual help content. - */ - public function add_the_contextual_help() { - echo ot_contextual_help_view( $_REQUEST['name'], $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding a new choice. - */ - public function add_choice() { - echo ot_choices_view( $_REQUEST['name'], $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding a new layout. - */ - public function add_layout() { - echo ot_layout_view( $_REQUEST['count'] ); - die(); - } - - /** - * AJAX utility function for adding a new list item. - */ - public function add_list_item() { - check_ajax_referer( 'option_tree', 'nonce' ); - ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] ); - die(); - } - - /** - * AJAX utility function for adding a new social link. - */ - public function add_social_links() { - check_ajax_referer( 'option_tree', 'nonce' ); - ot_social_links_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] ); - die(); - } - - /** - * Fake the gallery shortcode - * - * The JS takes over and creates the actual shortcode with - * the real attachment IDs on the fly. Here we just need to - * pass in the post ID to get the ball rolling. - * - * @param array The current settings - * @param object The post object - * @return array - * - * @access public - * @since 2.2.0 - */ - public function shortcode( $settings, $post ) { - global $pagenow; - - if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ) ) ) { - return $settings; - } - - // Set the OptionTree post ID - if ( ! is_object( $post ) ) { - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_GET['post_ID'] ) ? $_GET['post_ID'] : 0 ); - if ( $post_id == 0 && function_exists( 'ot_get_media_post_ID' ) ) { - $post_id = ot_get_media_post_ID(); - } - $settings['post']['id'] = $post_id; - } - - // No ID return settings - if ( $settings['post']['id'] == 0 ) - return $settings; - - // Set the fake shortcode - $settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" ); - - // Return settings - return $settings; - - } - - /** - * Returns the AJAX images - * - * @return string - * - * @access public - * @since 2.2.0 - */ - public function ajax_gallery_update() { - - if ( ! empty( $_POST['ids'] ) ) { - - $return = ''; - - foreach( $_POST['ids'] as $id ) { - - $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); - - $return .= '
  • '; - - } - - echo $return; - exit(); - - } - - } - - /** - * Returns a JSON encoded Google fonts array. - * - * @return array - * - * @access public - * @since 2.5.0 - */ - public function retrieve_google_font() { - - if ( isset( $_POST['field_id'], $_POST['family'] ) ) { - - ot_fetch_google_fonts(); - - echo json_encode( array( - 'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ), - 'subsets' => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] ) - ) ); - exit(); - - } - - } - - /** - * Filters the media uploader button. - * - * @return string - * - * @access public - * @since 2.1 - */ - public function change_image_button( $translation, $text, $domain ) { - global $pagenow; - - if ( $pagenow == apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) && 'default' == $domain && 'Insert into post' == $text ) { - - // Once is enough. - remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) ); - return apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ); - - } - - return $translation; - - } - - - } - - /** - * Instantiate the OptionTree loader class. - * - * @since 2.0 - */ - $ot_loader = new OT_Loader(); + /** + * OptionTree loader class. + */ + class OT_Loader { -} + /** + * Constructor. + * + * This method loads other methods of the class. + * + * @access public + * @since 2.0 + */ + public function __construct() { + + // Load languages. + $this->load_languages(); + + // Load OptionTree. + add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 ); + } + + /** + * Load the languages before everything else. + * + * @access private + * @since 2.1.3 + */ + private function load_languages() { + + /** + * A quick check to see if we're in plugin mode. + * + * @since 2.1.3 + */ + define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false ); + + /** + * Path to the languages directory. + * + * This path will be relative in plugin mode and absolute in theme mode. + * + * @since 2.0.10 + * @updated 2.4.1 + */ + if ( OT_PLUGIN_MODE ) { + define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) ); + } else { + if ( true === apply_filters( 'ot_child_theme_mode', false ) ) { + $path = @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); + $path = ltrim( end( $path ), '/' ); + define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); + } else { + $path = @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); + $path = ltrim( end( $path ), '/' ); + define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); + } + } + + // Load the text domain. + if ( OT_PLUGIN_MODE ) { + add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); + } else { + add_action( 'after_setup_theme', array( $this, 'load_textdomain' ) ); + } + } + + /** + * Load the text domain. + * + * @access private + * @since 2.0 + */ + public function load_textdomain() { + + if ( OT_PLUGIN_MODE ) { + load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR ); + } else { + load_theme_textdomain( 'option-tree', OT_LANG_DIR ); + } + } + + /** + * Load OptionTree on the 'after_setup_theme' action. Then filters will + * be available to the theme, and not only when in Theme Mode. + * + * @access public + * @since 2.1.2 + */ + public function load_option_tree() { + + // Setup the constants. + $this->constants(); + + // Include the required admin files. + $this->admin_includes(); + + // Include the required files. + $this->includes(); + + // Hook into WordPress. + $this->hooks(); + } + + /** + * Constants. + * + * Defines the constants for use within OptionTree. Constants + * are prefixed with 'OT_' to avoid any naming collisions. + * + * @access private + * @since 2.0 + */ + private function constants() { + + /** + * Current Version number. + */ + define( 'OT_VERSION', '2.7.0' ); + + /** + * For developers: Theme mode. + * + * Run a filter and set to true to enable OptionTree theme mode. + * You must have this files parent directory inside of + * your themes root directory. As well, you must include + * a reference to this file in your themes functions.php. + * + * @since 2.0 + */ + define( 'OT_THEME_MODE', apply_filters( 'ot_theme_mode', false ) ); + + /** + * For developers: Child Theme mode. TODO document + * + * Run a filter and set to true to enable OptionTree child theme mode. + * You must have this files parent directory inside of + * your themes root directory. As well, you must include + * a reference to this file in your themes functions.php. + * + * @since 2.0.15 + */ + define( 'OT_CHILD_THEME_MODE', apply_filters( 'ot_child_theme_mode', false ) ); + + /** + * For developers: Show Pages. + * + * Run a filter and set to false if you don't want to load the + * settings & documentation pages in the admin area of WordPress. + * + * @since 2.0 + */ + define( 'OT_SHOW_PAGES', apply_filters( 'ot_show_pages', true ) ); + + /** + * For developers: Show Theme Options UI Builder + * + * Run a filter and set to false if you want to hide the + * Theme Options UI page in the admin area of WordPress. + * + * @since 2.1 + */ + define( 'OT_SHOW_OPTIONS_UI', apply_filters( 'ot_show_options_ui', true ) ); + + /** + * For developers: Show Settings Import + * + * Run a filter and set to false if you want to hide the + * Settings Import options on the Import page. + * + * @since 2.1 + */ + define( 'OT_SHOW_SETTINGS_IMPORT', apply_filters( 'ot_show_settings_import', true ) ); + + /** + * For developers: Show Settings Export + * + * Run a filter and set to false if you want to hide the + * Settings Import options on the Import page. + * + * @since 2.1 + */ + define( 'OT_SHOW_SETTINGS_EXPORT', apply_filters( 'ot_show_settings_export', true ) ); + + /** + * For developers: Show New Layout. + * + * Run a filter and set to false if you don't want to show the + * "New Layout" section at the top of the theme options page. + * + * @since 2.0.10 + */ + define( 'OT_SHOW_NEW_LAYOUT', apply_filters( 'ot_show_new_layout', true ) ); + + /** + * For developers: Show Documentation + * + * Run a filter and set to false if you want to hide the Documentation. + * + * @since 2.1 + */ + define( 'OT_SHOW_DOCS', apply_filters( 'ot_show_docs', true ) ); + + /** + * For developers: Custom Theme Option page + * + * Run a filter and set to false if you want to hide the OptionTree + * Theme Option page and build your own. + * + * @since 2.1 + */ + define( 'OT_USE_THEME_OPTIONS', apply_filters( 'ot_use_theme_options', true ) ); + + /** + * For developers: Meta Boxes. + * + * Run a filter and set to false to keep OptionTree from + * loading the meta box resources. + * + * @since 2.0 + */ + define( 'OT_META_BOXES', apply_filters( 'ot_meta_boxes', true ) ); + + /** + * For developers: Allow Unfiltered HTML in all the textareas. + * + * Run a filter and set to true if you want all the + * users to be able to post anything in the textareas. + * WARNING: This opens a security hole for low level users + * to be able to post malicious scripts, you've been warned. + * + * @since 2.0 + */ + define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) ); + + /** + * For developers: Post Formats. + * + * Run a filter and set to true if you want OptionTree + * to load meta boxes for post formats. + * + * @since 2.4.0 + */ + define( 'OT_POST_FORMATS', apply_filters( 'ot_post_formats', false ) ); + + /** + * Check if in theme mode. + * + * If OT_THEME_MODE and OT_CHILD_THEME_MODE is false, set the + * directory path & URL like any other plugin. Otherwise, use + * the parent or child themes root directory. + * + * @since 2.0 + */ + if ( false === OT_THEME_MODE && false === OT_CHILD_THEME_MODE ) { + define( 'OT_DIR', plugin_dir_path( __FILE__ ) ); + define( 'OT_URL', plugin_dir_url( __FILE__ ) ); + } else { + if ( true === OT_CHILD_THEME_MODE ) { + $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) ); + define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) ); + } else { + $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) ); + define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) ); + } + } + + /** + * Template directory URI for the current theme. + * + * @since 2.1 + */ + if ( true === OT_CHILD_THEME_MODE ) { + define( 'OT_THEME_URL', get_stylesheet_directory_uri() ); + } else { + define( 'OT_THEME_URL', get_template_directory_uri() ); + } + } + + /** + * Include admin files. + * + * These functions are included on admin pages only. + * + * @access private + * @since 2.0 + */ + private function admin_includes() { + + // Exit early if we're not on an admin page. + if ( ! is_admin() ) { + return false; + } + + // Global include files. + $files = array( + 'ot-functions-admin', + 'ot-functions-option-types', + 'ot-functions-compat', + 'ot-settings-api', + ); + + // Include the meta box api. + if ( true === OT_META_BOXES ) { + $files[] = 'ot-meta-box-api'; + } + + // Include the post formats api. + if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) { + $files[] = 'ot-post-formats-api'; + } + + // Include the settings & docs pages. + if ( true === OT_SHOW_PAGES ) { + $files[] = 'ot-functions-settings-page'; + $files[] = 'ot-functions-docs-page'; + } + + // Include the cleanup api. + $files[] = 'ot-cleanup-api'; + + // Require the files. + foreach ( $files as $file ) { + $this->load_file( OT_DIR . 'includes' . DIRECTORY_SEPARATOR . "{$file}.php" ); + } + + // Registers the Theme Option page. + add_action( 'init', 'ot_register_theme_options_page' ); + + // Registers the Settings page. + if ( true === OT_SHOW_PAGES ) { + add_action( 'init', 'ot_register_settings_page' ); + + // Global CSS. + add_action( 'admin_head', array( $this, 'global_admin_css' ) ); + } + } + + /** + * Include front-end files. + * + * These functions are included on every page load + * incase other plugins need to access them. + * + * @access private + * @since 2.0 + */ + private function includes() { + + $files = array( + 'ot-functions', + 'ot-functions-deprecated', + ); + + // Require the files. + foreach ( $files as $file ) { + $this->load_file( OT_DIR . 'includes' . DIRECTORY_SEPARATOR . "{$file}.php" ); + } + } + + /** + * Execute the WordPress Hooks. + * + * @access public + * @since 2.0 + */ + private function hooks() { + + // Attempt to migrate the settings. + if ( function_exists( 'ot_maybe_migrate_settings' ) ) { + add_action( 'init', 'ot_maybe_migrate_settings', 1 ); + } + + // Attempt to migrate the Options. + if ( function_exists( 'ot_maybe_migrate_options' ) ) { + add_action( 'init', 'ot_maybe_migrate_options', 1 ); + } + + // Attempt to migrate the Layouts. + if ( function_exists( 'ot_maybe_migrate_layouts' ) ) { + add_action( 'init', 'ot_maybe_migrate_layouts', 1 ); + } + + // Load the Meta Box assets. + if ( true === OT_META_BOXES ) { -/* End of file ot-loader.php */ -/* Location: ./ot-loader.php */ + // Add scripts for metaboxes to post-new.php & post.php. + add_action( 'admin_print_scripts-post-new.php', 'ot_admin_scripts', 11 ); + add_action( 'admin_print_scripts-post.php', 'ot_admin_scripts', 11 ); + + // Add styles for metaboxes to post-new.php & post.php. + add_action( 'admin_print_styles-post-new.php', 'ot_admin_styles', 11 ); + add_action( 'admin_print_styles-post.php', 'ot_admin_styles', 11 ); + + } + + // Adds the Theme Option page to the admin bar. + add_action( 'admin_bar_menu', 'ot_register_theme_options_admin_bar_menu', 999 ); + + // prepares the after save do_action. + add_action( 'admin_init', 'ot_after_theme_options_save', 1 ); + + // default settings. + add_action( 'admin_init', 'ot_default_settings', 2 ); + + // add xml to upload filetypes array. + add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 ); + + // import. + add_action( 'admin_init', 'ot_import', 4 ); + + // export. + add_action( 'admin_init', 'ot_export', 5 ); + + // save settings. + add_action( 'admin_init', 'ot_save_settings', 6 ); + + // save layouts. + add_action( 'admin_init', 'ot_modify_layouts', 7 ); + + // create media post. + add_action( 'admin_init', 'ot_create_media_post', 8 ); + + // Google Fonts front-end CSS. + add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 ); + + // dynamic front-end CSS. + add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 ); + + // insert theme CSS dynamically. + add_action( 'ot_after_theme_options_save', 'ot_save_css' ); + + // AJAX call to create a new section. + add_action( 'wp_ajax_add_section', array( $this, 'add_section' ) ); + + // AJAX call to create a new setting. + add_action( 'wp_ajax_add_setting', array( $this, 'add_setting' ) ); + + // AJAX call to create a new contextual help. + add_action( 'wp_ajax_add_the_contextual_help', array( $this, 'add_the_contextual_help' ) ); + + // AJAX call to create a new choice. + add_action( 'wp_ajax_add_choice', array( $this, 'add_choice' ) ); + + // AJAX call to create a new list item setting. + add_action( 'wp_ajax_add_list_item_setting', array( $this, 'add_list_item_setting' ) ); + + // AJAX call to create a new layout. + add_action( 'wp_ajax_add_layout', array( $this, 'add_layout' ) ); + + // AJAX call to create a new list item. + add_action( 'wp_ajax_add_list_item', array( $this, 'add_list_item' ) ); + + // AJAX call to create a new social link. + add_action( 'wp_ajax_add_social_links', array( $this, 'add_social_links' ) ); + + // AJAX call to retrieve Google Font data. + add_action( 'wp_ajax_ot_google_font', array( $this, 'retrieve_google_font' ) ); + + // Adds the temporary hacktastic shortcode. + add_filter( 'media_view_settings', array( $this, 'shortcode' ), 10, 2 ); + + // AJAX update. + add_action( 'wp_ajax_gallery_update', array( $this, 'ajax_gallery_update' ) ); + + // Modify the media uploader button. + add_filter( 'gettext', array( $this, 'change_image_button' ), 10, 3 ); + } + + /** + * Load a file. + * + * @access private + * @since 2.0.15 + * + * @param string $file Path to the file being included. + */ + private function load_file( $file ) { + include_once $file; + } + + /** + * Adds CSS for the menu icon. + */ + public function global_admin_css() { + echo ' +'; + } + + /** + * AJAX utility function for adding a new section. + */ + public function add_section() { + echo ot_sections_view( ot_settings_id() . '[sections]', $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding a new setting. + */ + public function add_setting() { + echo ot_settings_view( $_REQUEST['name'], $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding a new list item setting. + */ + public function add_list_item_setting() { + echo ot_settings_view( $_REQUEST['name'] . '[settings]', $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding new contextual help content. + */ + public function add_the_contextual_help() { + echo ot_contextual_help_view( $_REQUEST['name'], $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding a new choice. + */ + public function add_choice() { + echo ot_choices_view( $_REQUEST['name'], $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding a new layout. + */ + public function add_layout() { + echo ot_layout_view( $_REQUEST['count'] ); + die(); + } + + /** + * AJAX utility function for adding a new list item. + */ + public function add_list_item() { + check_ajax_referer( 'option_tree', 'nonce' ); + ot_list_item_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] ); + die(); + } + + /** + * AJAX utility function for adding a new social link. + */ + public function add_social_links() { + check_ajax_referer( 'option_tree', 'nonce' ); + ot_social_links_view( $_REQUEST['name'], $_REQUEST['count'], array(), $_REQUEST['post_id'], $_REQUEST['get_option'], unserialize( ot_decode( $_REQUEST['settings'] ) ), $_REQUEST['type'] ); + die(); + } + + /** + * Fake the gallery shortcode. + * + * The JS takes over and creates the actual shortcode with + * the real attachment IDs on the fly. Here we just need to + * pass in the post ID to get the ball rolling. + * + * @access public + * @since 2.2.0 + * + * @param array $settings The current settings. + * @param object $post The post object. + * @return array + */ + public function shortcode( $settings, $post ) { + global $pagenow; + + if ( in_array( $pagenow, array( 'upload.php', 'customize.php' ), true ) ) { + return $settings; + } + + // Set the OptionTree post ID. + if ( ! is_object( $post ) ) { + $post_id = isset( $_GET['post'] ) ? $_GET['post'] : ( isset( $_GET['post_ID'] ) ? $_GET['post_ID'] : 0 ); + if ( 0 >= $post_id && function_exists( 'ot_get_media_post_ID' ) ) { + $post_id = ot_get_media_post_ID(); + } + $settings['post']['id'] = $post_id; + } + + // No ID return settings. + if ( 0 >= $settings['post']['id'] ) { + return $settings; + } + + // Set the fake shortcode. + $settings['ot_gallery'] = array( 'shortcode' => "[gallery id='{$settings['post']['id']}']" ); + + // Return settings. + return $settings; + } + + /** + * AJAX to generate HTML for a list of gallery images. + * + * @access public + * @since 2.2.0 + */ + public function ajax_gallery_update() { + + if ( ! empty( $_POST['ids'] ) ) { + + $html = ''; + + foreach ( $_POST['ids'] as $id ) { + + $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); + + $html .= '
  • '; + } + + echo $html; // phpcs:ignore + exit(); + } + } + + /** + * The JSON encoded Google fonts data, or false if it cannot be encoded. + * + * @access public + * @since 2.5.0 + */ + public function retrieve_google_font() { + + if ( isset( $_POST['field_id'], $_POST['family'] ) ) { + + ot_fetch_google_fonts(); + + echo wp_json_encode( + array( + 'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ), + 'subsets' => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] ), + ) + ); + exit(); + } + } + + /** + * Filters the media uploader button. + * + * @access public + * @since 2.1 + * + * @param string $translation Translated text. + * @param string $text Text to translate. + * @param string $domain Text domain. Unique identifier for retrieving translated strings. + * + * @return string + */ + public function change_image_button( $translation, $text, $domain ) { + global $pagenow; + + if ( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) === $pagenow && 'default' === $domain && 'Insert into post' === $text ) { + + // Once is enough. + remove_filter( 'gettext', array( $this, 'ot_change_image_button' ) ); + return apply_filters( 'ot_upload_text', esc_html__( 'Send to OptionTree', 'option-tree' ) ); + + } + + return $translation; + } + } + + /** + * Instantiate the OptionTree loader class. + * + * @since 2.0 + */ + $ot_loader = new OT_Loader(); +} From 801cd93ae3863303d117e0c786461eb58afdbac7 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 04:52:09 -0800 Subject: [PATCH 04/67] Remove languages, API key, and fix phpcs issues --- .jscsrc | 3 +- assets/js/ot-admin.js | 178 +- includes/ot-functions-admin.php | 26 +- languages/option-tree-et.mo | Bin 82270 -> 0 bytes languages/option-tree-et.po | 3021 ------------------------------- languages/option-tree.po | 2461 ------------------------- ot-loader.php | 192 +- 7 files changed, 203 insertions(+), 5678 deletions(-) delete mode 100644 languages/option-tree-et.mo delete mode 100644 languages/option-tree-et.po delete mode 100644 languages/option-tree.po diff --git a/.jscsrc b/.jscsrc index 12757e3..d583b26 100644 --- a/.jscsrc +++ b/.jscsrc @@ -5,5 +5,6 @@ "**/*.jsx", "**/node_modules/**", "**/vendor/**" - ] + ], + "requireCamelCaseOrUpperCaseIdentifiers": true } diff --git a/assets/js/ot-admin.js b/assets/js/ot-admin.js index d15bc73..6458af7 100755 --- a/assets/js/ot-admin.js +++ b/assets/js/ot-admin.js @@ -1,6 +1,6 @@ /** * Option Tree UI - * + * * Dependencies: jQuery, jQuery UI, ColorPicker * * @author Derek Herman (derek@valendesigns.com) @@ -318,8 +318,8 @@ while( match = regex.exec( condition ) ) { conditions.push({ - 'check': match[1], - 'rule': match[2], + 'check': match[1], + 'rule': match[2], 'value': match[3] || '' }); } @@ -361,7 +361,7 @@ break; case 'contains': result = ( v1.indexOf(v2) !== -1 ? true : false ); - break; + break; case 'is': result = ( v1 == v2 ); break; @@ -383,7 +383,7 @@ passed = ( passed && result ); break; } - + }); if ( passed ) { @@ -391,7 +391,7 @@ } else { $(this).animate({opacity: 'hide' , height: 'hide'}, 200); } - + delete passed; }); @@ -618,8 +618,9 @@ dataType: 'json', data: { action: 'ot_google_font', - family: input.val(), - field_id: input.attr('id') + family: input.val(), + field_id: input.attr( 'id' ), + nonce: option_tree.nonce } }).done(function(response) { if ( response.hasOwnProperty('variants') ) { @@ -728,7 +729,7 @@ editor.setTheme("ace/theme/chrome"); editor.getSession().setMode("ace/mode/css"); editor.setShowPrintMargin( false ); - + editor.getSession().setValue(this_textarea.val()); editor.getSession().on('change', function(){ this_textarea.val(editor.getSession().getValue()); @@ -818,8 +819,9 @@ url: ajaxurl, dataType: 'html', data: { - action: 'gallery_update' - , ids: ids + action: 'gallery_update', + ids: ids, + nonce: option_tree.nonce }, success: function(res) { parent.children('.ot-gallery-list').html(res); @@ -860,50 +862,50 @@ if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids ) shortcode.set( 'ids', ids ) - + if ( _.isUndefined( shortcode.get('ids') ) ) shortcode.set( 'ids', '0' ) - + attachments = wp.media.gallery.attachments( shortcode ) selection = new wp.media.model.Selection( attachments.models, { props: attachments.props.toJSON() , multiple: true }) - + selection.gallery = attachments.gallery - + // Fetch the query's attachments, and then break ties from the query to allow for sorting. selection.more().done( function () { selection.props.set({ query: false }) selection.unmirror() selection.props.unset('orderby') }) - + return selection - + } - + , open: function (elm) { - + ot_gallery.frame(elm).open() - + } - + , remove: function (elm) { - + if ( confirm( option_tree.confirm ) ) { - + $(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value', ''); $(elm).parents('.format-setting-inner').children('.ot-gallery-list').remove(); $(elm).next('.ot-gallery-edit').text( option_tree.create ); $(elm).remove(); OT_UI.parse_condition(); - + } } - + } // Gallery delete @@ -911,13 +913,13 @@ e.preventDefault() ot_gallery.remove($(this)) }) - + // Gallery edit $(document).on('click.ot_gallery.data-api', '.ot-gallery-edit', function (e) { e.preventDefault() ot_gallery.open($(this)) }) - + }(window.jQuery); /*! @@ -925,43 +927,43 @@ */ !function ($) { - $(document).on('ready', function () { - + $( document ).ready( function() { + // Loop over the metaboxes $('.ot-metabox-wrapper').each( function() { - + // Only if there is a tab option if ( $(this).find('.type-tab').length ) { - + // Add .ot-metabox-panels $(this).find('.type-tab').parents('.ot-metabox-wrapper').wrapInner('
    ') - + // Wrapp with .ot-metabox-tabs & add .ot-metabox-nav before .ot-metabox-panels $(this).find('.ot-metabox-panels').wrap('
    ').before('
      ') - + // Loop over settings and build the tabs nav $(this).find('.format-settings').each( function() { - + if ( $(this).find('.type-tab').length > 0 ) { var title = $(this).find('.type-tab').prev().find('label').text() , id = $(this).attr('id') - - // Add a class, hide & append nav item + + // Add a class, hide & append nav item $(this).addClass('is-panel').hide() $(this).parents('.ot-metabox-panels').prev('.ot-metabox-nav').append('
    • ' + title + '
    • ') - + } - + }) - + // Loop over the panels and wrap and ID them. $(this).find('.is-panel').each( function() { var id = $(this).attr('id') - + $(this).add( $(this).nextUntil('.is-panel') ).wrapAll('
      ') - + }) - + // Create the tabs $(this).find('.ot-metabox-tabs').tabs({ activate: function( event, ui ) { @@ -974,10 +976,10 @@ OT_UI.load_editors(); } }) - + // Move the orphaned settings to the top $(this).find('.ot-metabox-panels > .format-settings').prependTo($(this)) - + // Remove a bunch of classes to stop style conflicts. $(this).find('.ot-metabox-tabs').removeClass('ui-widget ui-widget-content ui-corner-all') $(this).find('.ot-metabox-nav').removeClass('ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all') @@ -985,11 +987,11 @@ $(this).find('.ot-metabox-nav li').on('mouseenter mouseleave', function() { $(this).removeClass('ui-state-hover') }) } - + }) - + }) - + }(window.jQuery); /*! @@ -997,69 +999,69 @@ */ !function ($) { - $(document).on('ready', function () { - + $( document ).ready( function() { + // Loop over the theme options $('#option-tree-settings-api .inside').each( function() { - + // Only if there is a tab option if ( $(this).find('.type-tab').length ) { - + // Add .ot-theme-option-panels $(this).find('.type-tab').parents('.inside').wrapInner('
      ') - + // Wrap with .ot-theme-option-tabs & add .ot-theme-option-nav before .ot-theme-option-panels $(this).find('.ot-theme-option-panels').wrap('
      ').before('
        ') - + // Loop over settings and build the tabs nav $(this).find('.format-settings').each( function() { - + if ( $(this).find('.type-tab').length > 0 ) { var title = $(this).find('.type-tab').prev().find('.label').text() , id = $(this).attr('id') - - // Add a class, hide & append nav item + + // Add a class, hide & append nav item $(this).addClass('is-panel').hide() $(this).parents('.ot-theme-option-panels').prev('.ot-theme-option-nav').append('
      • ' + title + '
      • ') - + } else { - + } - + }) - + // Loop over the panels and wrap and ID them. $(this).find('.is-panel').each( function() { var id = $(this).attr('id') - + $(this).add( $(this).nextUntil('.is-panel') ).wrapAll('
        ') - + }) - + // Create the tabs $(this).find('.ot-theme-option-tabs').tabs({ activate: function( event, ui ) { OT_UI.load_editors(); } }) - + // Move the orphaned settings to the top $(this).find('.ot-theme-option-panels > .format-settings').prependTo($(this).find('.ot-theme-option-tabs')) - + } - + }) - + }) - + }(window.jQuery); /*! * Fixes the state of metabox radio buttons after a Drag & Drop event. */ !function ($) { - - $(document).on('ready', function () { + + $( document ).ready( function() { // detect mousedown and store all checked radio buttons $('.hndle').on('mousedown', function () { @@ -1071,47 +1073,47 @@ // set live event listener for mouse up on the content .wrap // then give the dragged div time to settle before firing the reclick function $('.wrap').on('mouseup', function () { - + var ot_checked_radios = {} - + // loop over all checked radio buttons inside of parent element $('#' + parent_id + ' input[type="radio"]').each( function () { - + // stores checked radio buttons if ( $(this).is(':checked') ) { - + ot_checked_radios[$(this).attr('name')] = $(this).val() - + } - + // write to the object $(document).data('ot_checked_radios', ot_checked_radios) - + }) // restore all checked radio buttons setTimeout( function () { - + // get object of checked radio button names and values var checked = $(document).data('ot_checked_radios') - + // step thru each object element and trigger a click on it's corresponding radio button for ( key in checked ) { - + $('input[name="' + key + '"]').filter('[value="' + checked[key] + '"]').trigger('click') - + } - + $('.wrap').unbind('mouseup') - + }, 50 ) - + }) - + }) - + }) - + }(window.jQuery); /*! @@ -1290,4 +1292,4 @@ $('.hide-color-picker.ot-colorpicker-opacity').ot_wpColorPicker(); }); -})( jQuery, window, document ); \ No newline at end of file +})( jQuery, window, document ); diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index db90647..61aff92 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -39,8 +39,10 @@ function ot_register_theme_options_page() { /* build the Theme Options */ if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) { - - ot_register_settings( array( + + $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ); + + ot_register_settings( array( array( 'id' => ot_options_id(), 'pages' => array( @@ -49,7 +51,7 @@ function ot_register_theme_options_page() { 'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ), 'page_title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ), 'menu_title' => apply_filters( 'ot_theme_options_menu_title', __( 'Theme Options', 'option-tree' ) ), - 'capability' => $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ), + 'capability' => $caps, 'menu_slug' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ), 'icon_url' => apply_filters( 'ot_theme_options_icon_url', null ), 'position' => apply_filters( 'ot_theme_options_position', null ), @@ -66,7 +68,7 @@ function ot_register_theme_options_page() { ); // Filters the options.php to add the minimum user capabilities. - add_filter( 'option_page_capability_' . ot_options_id(), create_function( '$caps', "return '$caps';" ), 999 ); + add_filter( 'option_page_capability_' . ot_options_id(), function() use ( $caps ) { return $caps; }, 999 ); } @@ -5213,9 +5215,13 @@ function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) { $ot_google_fonts = array(); - /* API url and key */ + // API url and key. $ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' ); - $ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', 'AIzaSyB8G-4UtQr9fhDYTiNrDP40Y5GYQQKrNWI' ); + $ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', false ); + + if ( false === $ot_google_fonts_api_key ) { + return array(); + } /* API arguments */ $ot_google_fonts_fields = apply_filters( 'ot_google_fonts_fields', array( 'family', 'variants', 'subsets' ) ); @@ -5223,9 +5229,9 @@ function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) { /* Initiate API request */ $ot_google_fonts_query_args = array( - 'key' => $ot_google_fonts_api_key, - 'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', - 'sort' => $ot_google_fonts_sort + 'key' => $ot_google_fonts_api_key, + 'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', + 'sort' => $ot_google_fonts_sort, ); /* Build and make the request */ @@ -6121,4 +6127,4 @@ function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxon add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 ); /* End of file ot-functions-admin.php */ -/* Location: ./includes/ot-functions-admin.php */ \ No newline at end of file +/* Location: ./includes/ot-functions-admin.php */ diff --git a/languages/option-tree-et.mo b/languages/option-tree-et.mo deleted file mode 100644 index e8742be9466483ef186981e02a95d0750458e82c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 82270 zcmd?S37jQoRrg;L0wIBrux|>LG0O~e_hb^nGK3_P%p@6SCNoTT62dlA_r2YHr*Gfe z++`L(5J3gF6!Z}<6ehat@_@Omf_88#3*3vfj4S>5j zf87JJ?7hHM56rUP0=^IUXkcqB%O-&z1a1Z1Ydp)|18e|40L&-6y}tpf{fpOS+3kTZ z0^Sw)D&Q%=-vw$Y?*^U*{2cIP;MagB0lx#h1MuGho_MZbKOOiruHOszd%*t!o=m@g zZ$145-h5t`HGxlhP?mj}@4s|GmNAs<0}sx!^MQW{+yFe|Az5}I@Ug%*0bc>6%h?qV z%`%3P?FE9m>_#9>Wq%C36Y#%)F96=@VOjPz;A?>I0PdnuwR7^rv+TCOcLFue_X2MR z{79UC0{G9I|0VD?z>m`jjr&u;I|IJ}JPr8wK;iBG0)>y09^vhs22?-p1Kb8&3w#1_ zFHqz9JdiGCceyCb7;3f^_-f!U0ACEe|Hawqua==As@pvLt%;JtzW2dL*yxHQHAyf5c# zfqMUD;OW3e0yXYwpzyE=b4P1X0@OOaIo4jAAZT9is z54e@DJPWA#dS$>HfNJ-R!1n>)3gp$< z6L&dXz7Gg%X8#J*_{Jt3?@gfE>BaezfG2SNY~bDK&vSwQ%K2-jobFzBHT~fF*MI}A zpA1r7%lT7*x8?kP*Fp2ZGlA;QCZNW>6?hu((LmvC4^Z>}G@zb)F7VF4Uj^QW_HKyp z--{5`_a6bOy^jNR-)94U9jN|)Kh9S@#_8y;0nY^9kMA!4{xon3cpqR7cw64{e4yHU z@nanyuLp|$eh;Yry))nkfVb!TPXm4qDEj|vpy>Y_K;8c@K+$pbxGZBTvpWMd-f5uP z-3QctPXXQ)_-vr?^QwSv1ggDv0mU~T0_wg`1NHpZfwuvE8>r{L1LT$2f5r93KHlf= z2|(d%2KdLoJwVat1-pG7yHCh6rZ9USP~*CL;qSd4@Q$260Js785TN?o1KtJrb3jm? z{VMP#;J1M4$Lps3eQyCifb(|()&H*mHJFubXw>&jq!}$zQ@0|nc`2q0uz^4HK@g_XOGnzMuQQ*mXUB z{SxoseCmlVhfeHe+0!|{cOUxZ`BwqI%lT^%LVpc>@zCW|e=qut@AvFOE^+-?`@Q|M z4}fQ`Kl;h&X08`cK?ec<7I+D8%g>=l`2M-TI|JYSRCFEJ|Kw@R9q^i;cY62&kgu|Z zr~COgfjU1xqt^rf4OjqQ@eE`z@IQdp(%ze%NgKf1J`26T^~XNj?WxxTZ{++@zvScp zPvF})e;+S@9;|02aWzpMYKl{u%B3%CFHM;1gbHqAmNo zS20HJ+xlvk*Ixy`h4bt+u8-de{7p{34E!zNbC`@@2cCbu+pV7m>ibu|&hdNc4O#Y8 z&OZYDBjB64c{gwfa{dMQS>QhcKlXa(oA>^P|P~1UwP=aiHk^)A9Wmfx7>zz}o=71$+qbAAk=6p7Ta;=dnQDHxsZGunT-H z*N4E{1GC?D`EoK)^mqpFG%i2lce3nD!0o_oT%ULoGK2FczZu*BKLC6Z@Lz%I?-OAH z_2&Rk@BKO8-GR>lYW`jUyesgHz&iu~0C*bklfXLwzXVh}-v$Z~-v#Ra{{TvUp2nmJ zt_G^z3xJ}7tw7=F2|zv91gf2Oz(IWf6rjfY^nlL|_+lXBlf635Ukg zZ;tB+f#R2s0yW+zbE5Y@4XEdy3H&|{J{Q>4`P-Qz;CF$i0l##U%aiW_Vg2k8@1T9~ zdlT>(oZtLT?g3u%`>rp~c$eFAPX(UKeV+pse1Fn=oDN$+rY75QGqMr*pFruo=6jJ9 zz&`{^zMS$0@CWdXz-i!9-iIv>{A=LJ!1aIVbntNCDV$FN?+<)D@O0o)fp-MH04O}Z z8YunndZ6xqJ5bl(2mBQ9Bfz%-U-f?Oqu)C|;C%V`gUENzzx6?Ee!f5ZkDRVf`>^YW zYk&{s`jdf|0N)OL9q?b``pZA!^7@m&F|Ob4qpmm32i}A82Jl(HCj&L^6aJV!0B-<- zy6mEl`8@qw!2b(8iR&l+iI3xsK;h}0K+W$rfF}e04tOu%_kg0i)Bn`z_AH>DUk?-> z9tKoDHUT#R9|L?0@P7d>0e&C20l4AgKF%Q!k(9j|_-x?TPk8@64ZI`ge*ruf_%+}i zfcN~Q>*=2X3g4Fi?+M%j6kim;9Jmjt`+p6%19&5lCbI7WCx9Phkf#Cv8F**lZJ4w( zfp-V425tbVy~hFX2kZlN|BHY>1-t<$yu1&naeovjJbVVI`@R6w^WO$O5O~6;{r-u7 z4+V<8E(MBzrsMh?P|rURC^~pLP~&_z@KoSIpyuJvfTsh$2^8P`2k=h7RiANuoDO^| z=WBq!5By7@`t#z?X4!eb-vVv{egOyzWM_X4T?zaeumjxndHMi+Kk!As^Z(rE?~j0I zbAHlaxcxW*d^qRV0k;8P3VaIiE5Igj_g{MdKLphKKMq_E{r@fSfxvrw0eS{r`d99s z?f;_R|CYaYyuJ%4`SU@b=;33)R|5YW_CeA+sTn{|;Zya6>d>H3X1PcGZ4OBbt3iy8D37mfv_21K>+m5&!wR&--T>#Q9wR3!vIP^&2kd?+(;_t^o>f z4*`mvw*%Gh>wud7CkWEs6M-7nFMQM6c|K5d^HQMb`!&FO1K$EX1^CBt{#oGNIR6Kr z=<398Isg1L@cx`%1k`hn2g>f+AJ^aTZO7|JfTF)I0q+3(8c_ZIr?|fA@4O!;0o9Mw zf$INipzdD_6hB=6+z#9Y)cdXn3LozV-Vyi#pybLYfa>qpfOiG{2k^eY)BfJCKM<(- zz67ZEJSyOBpxT)QHh_Jg+W&K)`0q>c{a1m%!}&h}<=?*cADn;R{T;WLz6Ly*@9*)C z-v1n^ag71D11|y!zt01ze=i3Xz~2VG33%#1IUT(RsQLLQa2)t4pzyCCn8tT+pzt#R z)cZC7O|Am(%K2k}`o0Ui4ESWA#`8X)#`$5O+W8Dn^5h%9y8^!tyc6)$?>e3R6j1nB z2OI;w1gLp`KTvr5GEnV)ANbS2RsZ7c+&|#?K(&7bP<(kUQ2qU<`2Gh#RBm?qzxsT9 z0(f`MKL-^3ejBK9{3lRy_T=yRd)5H&#`)y|9|IJfEdfsj?geTb&jhXmz8H80@F4Ia z;8%f~hco}p`?n6bmh+2&=Kxzkeg8tB+I@AL-vB(H^EUy7k1qp7k9YdM)5#j(ojD%| zYTOqC)&Cv9djcN=)cE>9&BJrz`L%v5a1(B59?xa;2m$GjIX)622+po%Q0Dgy{@i)2t;!{>-U*i0!cU)zD!R}L6 zWkb$SrjaS&(}0Sfe+Kw1&cA-zD)YlWjWBvP=a0iVdo%E>z!w2u!p-jno^#h#W|w>g z_!iE8f#8+s?|g!4p8)%)cD^Cll}?t zmoeV;o=5%ED)V2y1$;l}FZgM1=aKhYmC;1D|Ng5iPWZxnRrUv*pLhoS0Ujh+_8#EO znX4>saDQGdI{O|_^LX2HRvG=@1$Z{+=K{qi*8=YY+y}g#=U)W88hHNNRoUZ!&%x=L z;rp+n?0y-zmC51N+2?^T=KSBrSDBuF-o&cxH#q+g@EyQ5!uD;zpTX$;0Pyp`-vho9 z<@pQ1?dPq^nBwe{Ku9C|%=xQKfB)HoR++#3hznL_f64Xp9=yur%&7!FZ{++QK+XSq zfWp`79_sV)Ac9WfgU9j_YGUJ$C_6@7o9zKCTFO6;SP64LlL}IH1~_4!8i692&&; zPXp@yX9CsU^MInm7Xj7o^>O_-f!A~XCg5#=S8eqBcLjVD5Oihx`R{Lmi$L+;zi|A9 zzTi)ErN7T`K(5&h9FMgt{@?uo?b`XJwa>rIz1KxM>et&jKE|QBdohP>e&KZ;hyEVQ zG0oA7XMQQ*BY`cBkMP~Ub0|l31;-!oS$|h>yn*9qbrOG)gX!;o^Fj0aLY{dg$5;9M z4;_DK8Q94aRJe0v7wi94!LE&#vz$g051pL33vk#5oJE?ukcxa zzs33cf#Rc=@%bJ=*%takEZN@^fcJ{e((~z0IN7ATobqh*IovceR`!X@b_4*NpI`#*$(V~#G&bpbm>j; zVMn?EM8#yNrR*w>vp62fwYSChuLhzL?e78n-{Sc7IQOf_AkNpv$)5+5jQAYK*Epn) zBzymqsTz@o284 zze_m3j1$S@H*)CjOZLD2Cpm{$9{HQ7o!!WH=W_mSj(vRoZQ$R;_f6ol;B!wV&g{evY5z^KWzL@7Fm# zY@e_z;+jrxhC^$-U-A6w7-9Lki9hEg#j_i%r@T+ z{12`zaBPWZZszlA;`3E}elwp>;&>9r7dZb#;46Uo8}K>(ZH~`FF1()OxtxC%_#uu@ zbF7K)|B=u7`!5G(+h5P;tNDIgT>E|C-8r7laSyJ)2KW@5;)9w9cZ!cH%(qX5gM_Qe{U(7c1#crcHkzYICnwifRn?R%f_4&F5i1Zf(u_7^+UiFb2KuaJt>hmwMe9hN9aC^Ti-vEIJ2rV7JrE2Q7_j zd_2EwzS{*!JGeGJo?Y1I;m+JemrYLQm$i$2|H5@~WrI*}SnMthTHQ|3&S!Lk&}ZHA z%lY8I5)GH_%y(P#q1MWj&|(jh>9y?sL%LJI z3WK86rujy7n~hxW8fkH*4miJ!`H+M_Nr5IPH=?r({Vqsr_L|0Fj2OhGv8&_L-NC$% ztGRzL-R{mTKxR|r=c(2}ovYJlHL@+6Y6IGs4?C?V4x71pz&i@&yJ#=X7jSX2*P1~p z^&s^zZew!$GhKvE+24|VwiVOOcCFP-CHe~q7+Tj2n(abZTFl{$Ma|<1v*XCAy1TvA z8Oyg9uoaAih^)Ql2;9P}eDua1>VnH!v8{T5cyVGrcWnK+9EqIQ^xLflH}|@W>4tG` zNMA#{Elmb2(ARLhjr8*9Vmlh(CyWb6oS)cp*ttJ&ZB;pWFoR=X*f`)oAk9mY%?jd zc2@FljX`%J_VX!3XYB zp?mhBU%CLUu(PYXuP)*@8(S55B6XXwl8Zx)fs7uHNotuU9>8P;qT&|yesXfmxKs^@ zp2e~HoKLnSVXK}_qBzhD`Hz5CQ`06RYSTEvvjxUMXXvu@7eq`>D zrPFK9fe~aq-HPXfS7y-ubKTy7F)_{VK{0oWcqVmfgjdRo%X#D|WU*Y^9v7J`6C5F# zWafp)DfXgO3)zJAIdf?&0oCYrmm1xDor!EC{IM7Gqz{toMZV39?MyhQaV$FjD5JqG zgezqsT;@iEeRoB-JICuT=aQXoZ#G(meY&c-&tULNd^Xd`K0j*vHiLyk=#QtlhMj(^ zm}fr(4Lg$^Ldd~fw?v4Rlv~-`2-3tjiJXtzWv8y64AbDqm{_KseY#2={X&*64SGk5c^t~z?B~?v&pjZEWb<3? z#sYESI%HobpK%MLLd0%)iX|d8hSwp#G^{^lc+wS(E*4*>JHW?6yZ#TE_B-rZQfICh~^JzOx|oGEaYa*q)3pqgOf z)B%ZmA5M3$JE_Rs8rp7#RyH*3xS=%NL^&r1PuiT2Ngt=CXlRVI)n7P}@9Pfnjc3(7 z3fwR@Z%*GW!7`05HpfGf-1>+%^JTfVUE{AS+H1!kF&lY5U(;(oaoECq;G*a%{QLSB zK}UR<8mNLIGC}-m#6*M)VeC*E)75FL6%Q$)vkirE;1B;yjV@+!@$QH+V2?XZ6%dP<_H628wrdx+wIz5qx)lETJLf?Y&cqFvsrtFiH9qAkoQ}} zYh+|=a*cQmFXH`niyo|=RJ6*ix&CTn1@&l#u*4h^mive!6-!I)7EzOt{z$?hWv4MB z;rBpqOch}p*klIx_(0w%7NG_gFs;r^dq^NB2^E^hCH9#;f)1+LkdOY(aD=L^Ia5thftG|3iD%uPu|dOb#Um`RIgYY;bm`b-_mZ~ zxm#g{{+hK(<7FF%#9^~bq3Jn7&7DSesWlAPpHI#gcoNyA2b|=RbeSFw2IvN&Ro#7K z5ifLgA|)A&hg}UF(U!W~P++d#B`70tAgnuv<<=;s&7gObJ|=E8{)HPfax8~SQc-$& zF&Gpx^YT7L-xImSqBsP0AyFV4*6(n7^N?<{)gz+WQ;2EHCR$WKOt0%9dMT2xy>}ub zXs*Kp=h>6O04!$@;9 z8;>^>oO@gdUZgf>PAGQhdAQjsZwrq;DnZH1=f=20b0~V~(%VyG^K)KrCb^ z5}j0Bg;U)LKPjofs1e_{#MMd@f3%E-Bctrxq(_6w-pz{lz(!w@Rl;q}eaL2)$)&Y& zm?0#^dh{`DE2B!D*}1F@iDs9{IxZELouzDsX%*d}Vf=Y;x#Ros3E{heLrr^LslH$7jTn8p?L#u!GBQX58E(?cwH5xDiXxnJIZrZ6-uy_R&N z!-}^pHkA-`bAcq2Z16CTW|T6s2CW@E)9m%S7>UmdVaELZdCy;I6X6 zYmuu!o&+z*IvE&IQ!b8~DWS+@Zwee8)@jWS`6guJrh>O@F>gqwh@H;Z5ak9c+g1Or zneTL>;y!Xx@*&d&cXhK(4ma>YQYb*O^89q9%XXixi2X1dUHXfDh8<>0f{w5vs#j8r zn_DyT{`gd;x9XouQ>$+&zg(0I`jijMHnryF_zw>0qnEOgU@2$&I+iL{H`p=nWp1J zpswXmyPG5LlEOO?B(VTPs3{zqJp^LFu4N=eRB{wVRem>NmSMYHZ|i?vLN?(+)@{<+ z_%0?2nP4+L!ouixXIikrzUH*3t`e$AZ3;o~7-pb}VV#<4OU|)gQ6bATO9<#*>2tfa zQgOU->^uy$noxK$&Wxzffq`ApN8oI>)njISf^Ye2Mx4ImdQoIXe+&|MX-*@n?y4r= z+O$H8IXvtl2pBoy-DRfTKnuRm+}Q*nbM$%H)YtAxR&Bfs+0hxa5Z1jk1$x}(Q>7is zTw8+!6$i+hK;SC#8}A7caVK9YQ#A)+SSmEbTg)}FHntO+!K;0cg&=wdPGn_m1AQ+dV5slSW@@p@JexlTf%R-RhY0cvscsBeyHz&xp*@ z2@AKMUyiYsE}Ct!&0;s$F9-7Z*4%uXBO+IbG@A?Q!A940_)K@{z`CV^>>raOT<6n7 zffw?LfvH`Twh9VVx)mz3G?Uz{P%Hi*)&>z+PRNgXOsooxOC9%)pqxz7MlU3C>4+%D z(cu*A`O!4&@r&HzNdc2oMHPcDv!6C#e6B){QW0H5hAI9do#)6jyrrgpG7*wcDceNy-c*Q$sKHb0z0h?Yso9gn@ZB; zS8qube4#rOaGP~~q+5fe@m4&tV9#^0bSGS?L0wDjA^D21Dvi`6hiL*i*)z$!ge-P< zH9`Oqs@$>IRQ)G8#wjBVS-KO}^9Ue}DQ!irD_q{9mW#BfX@g`K_MD7*e`hh>Y7;&X zTh+ARr3AN$b?UHJvyw^hr_*7*!)a*otCTUB(CEc<>Y9EVZ zKv-3wNDDiVRbfoDL6I%a6_SFffzG{JSH{WQuwCGW?^oHHxox0)i@Gdh@%!QJk zXL_;!vdfV?`L(SEIJ06^f8$!NN0M%r=CIkBX>Pz0+U-hs_kd*GniX#%@mJlq;w}9w zg-@<%cBpARjWz$$bSAA^-9YGR@d`)CmGOnyGwR5ON zSYGyw&sZV`a%!Mn^hMPy7!K@3Z&ci@{wVI0th~58qJ&o8B6Is=o>-3FFB-BWV%~10+RTq0np{uo9@ECE1L!T0)J?NKWjBP8Vgj;>x39z2rG{!1EKl*7PaOOL#0( zWw5PB5Hv@_#R*E;Y0WF^c}zYPV?lCS&03-~OGF@tOhz)lQP`ZQgU(>>2U3j4hD&q3 zLd{s{ot{&bov)wRUysI=QzAFO-)B4qJk0-W2px!Ly&~PW)0!*2 z_X5^afnqNn;4v8yMSd5O**IuY8iXloRl@hXcS7`}C zcs6|_FO5YatQj%Aei)+m{+s`$@=Dd`A!^+(jbtxVJL>N3Ztf@0SLQ7}GM#8%Qi`ND z>}O$9#S{Z~Wj4VWHBqsc8LOfRD=J`E<2ScZV0^RID=NgmLAO^1jI*Lmbn>pib7hVt z{@K?nEZwZ-0SH8+%OefUM!{<}g>yqGfk9LO8QY7={PAVVH))3CS5&44^JAu-{ht$2 z?UCqSV@qJ%2!sjR2i9_zdC);lp#b74D`Z?*rt_(~R!SFDak)iAnwgZDw3Sa@Iqg?k zhg2mQhiz9TfSj+%WG~MONqp^flUuI6?uuM=sjP$PWk}zuyTn8-cbTA6Mq!~6n=)4( z+}EvQ3J{(1<+24-M8Pd4hb&3q2k$d1G-$OUMB+d#iT(D_YQ9a2W7o1wixji3@*?qw z#UTo|6+BcZqhc^bFxQYQNotS>_mQkwTRMOnvY*9DoV2wpnXS{{e+DrKz|x8i+Fq@t zD=D2x%s)+2z}#m~nT~X22jkn@qE{Zwh#>f68w zt--9tTTz%MeBdl?Yf`7j&xJN-wWF z!kcz%*AmYp%zT+A`f8~s&ej4ToXABS6G=MV7CfOQRrn5J7w=OD%1haLDA*0k|($`=SDPSPbuIfb~RWIQ**UD3HR25RLE)#^xR zEHk1sC)5fW_evz1GOQ@`Xc183;fl}8np=0O)DA@~tYBl{;k{RF`@1xDx0>+k2p?H3 z5gL~vt1k%MDjR0cVn13j?ueX%Bo6TmTu_<(Z(SUAlZVq1h}C6#CA6!}owg(hVV72FU7sByJf zYf>Na1Sr@UF4exZnw>K3U5WY1$Sqxyou)$bIdiSg@>yNJu&4fFu}8$yMeh>6VRZ`8 zRynT12J_iULvcvC6?)mocp{HiHkwJLI(xY7%8<*9x!n(OEXhvg`C96{!UUAWi^DN8 zLttOg)9P+|of7|3mN(~AW>V743NlooqWUy~baMOnK9Zq%s`v4;sBqYck%%l%+-|3A zTEaquOrO zW+jOzE&F!+Zc^dG%e+>Wn>Yzc;3uW6%~xSLF1M7-kPT5HjLbM$D_)^e-=x$jLRTd& zayROl6;qX>NH`n_meC|y}9bO_m%{6y+1lam5^mC0OQ+Ii(p&m5LlwQ&~ zQ-Kz;$yid#2Wq$1Z(!#GFDDa~hR8oV7yl}rBNB*xH2i_{Se8uGLIquQ1zD$ z(i)diILA@~#%k;8^T=2CGXyusTqRU>5_6YUw{e57FRkAdSJJHrgDg3kS;f!_!@l<9aI-%E0OE8N?HCm6W@2W!Yu%~?8x%ty&R9q_@ zyc!%k`~bUJNY+$pD5Xal2S{3On2SZk@%pis&4`hWiG`mPGu~Q&>aoZ zO&w_)tZ&1xx}ctfc6YU`wrh!^v>;=dstg88_LG>lY-iX}bQJR?8uXwr*gFJQOcOX# zkw~LO#!4vhe#coT$L8LT~Jg;S6R~RWC9t@vcH4^ zSwRP0oj-zN=8h1ziCzQ;6HjtUdr`CqRNC~pO_Y3c?YQ8`H+S1Mv)lgbhpWF8cc|57I>IEDt^#HI*v<3-Pmx@yDCcD7vTcm8x!pljA z-Y!g%;y?&SeXP8!YRVT)h*%$)R!6pv&jx>_K2O_H2S<`Wl6n(lzq~uCTM7P9-Lnbt z0%}v9!hT(N_=I`sqwz|)BI8KYpSo6u-px|~swscFn05zjP?+^JZZ65z5sEtg2lQBHfUdIoY^M3xp>BdwNm)+DFR^vaHLxn;}m^I z5j${<&n*;I?6?O{VCM1l$r z)892$#FeU5Fe7vrSvS#9DhF1E$Ck}(*+gfzgcz4dx8<)^I_F7*#T44AKVn9tbvz

        | zEwc{SSt)9E#$mTBU&?ZpLgB8dB=!(NU05qY`?E6cv?Qrljs8TCg1gs8-5@ zph_AB=`Y_E$c^EVsab)A;oOuZM}U>3G*#B6+;_kXF@H&U?HFm%?zcA`3n%Bhd^s#c zB?iM$5-*k`3IJu7GKw`KCq745g^zDG*;-|J1vg`JXoVO13`?rXg`}@=t#3 z?S2!sQSUZ_nIvde+=mF+iMvj4w^}|-2^@I34wJ}uH_DieL!j_4}egrKW5 zlO{6WRs|7EK@xhOhrI}F&En7#!L*KyWFMvP2=v#~otm>1TAr|zs?sIG+FeRImgYxy z%qV^2S!$lFwz3Lx+M5wUNQ|<|(poK@q+u`FZ_=&Xlisf&Le%p7mfJ zV0}--;+@V%FG~JQH{}LIJ8oG#L`~oopj>V2j8;8htvIw%9ClDsGXEV}wvLOLHi3$Z zgqsv=)3qWAON5POHBhr*Y5{}_?aHwdJClpmA2))dgsc^QKRt1Q%nJ)S=W8gPsCKHv=PrmPEm?qx{TVm1GmxiLBd}*941Y?AIujil zt9wnRZt0hI5K<)M)9m>+nam35Ms0l>8?)L(S!4q-Lz~LC(iN~s27|FzJsaI-*QI?` zr;$k6qD+RAQSTL0xTAs9Xk|ZM^`Yr07oE6~RBKa2lz2E6*mGS-dai21&w5Ru`GT{7!qmT#i{iEZqiZm#WH<0WNP!t!yZDVBWKT&S!v zOjTHjJWOf;vqI|QsbH!M~^38% zR>es6_i&v_kq=dOxCwDgQIB-{aUjLIb8J3bYW?tY6L%cX>+8wwqhdohAA1bw_}oFC z9KGQfu~F~Lij;a>j+wpQD>>_?T#ZGJJwRhS#>khI#He>|S>P)ipyQaX6;Oj@OAKOE zn~Km)-FdyZGB0IO0pTUKXpUe&l7M>B*<%H5!W#x`Sj4VQ=oCCb?eeVf7*(5BBfLk| zL>+mmC}FW1Mjf`TZKc;CUqXPER;(JOR7Bdd;g~dn+xMXtqQ|ua?+67`V%ly!3G)HR zv$j8%6?V+ZlEH>39f8F0u>@J_*foNzDjfuZ_k|TJg9MaX)}K&2ezcU8#gOa6SAk@u zU8U%SDx{Iy!g@U?rd2H8I?Luyu|rbIUnEB_;d$iYDtA(5U;KXWo_ekJG*46Yk|X() zwp=G_^dO(no&{b#Wjun?8nJ0S+M{1XkJl1a$M%!y?yGW;x{F1RHEF0^djneA_Q4-? zm)Ji|t}OK>U3Q^jmvG^sO`)d?^#A{QwIshsQ0hh$_8D;&W`>#**KMjvWJ{ND3X5qK z;*ZdMJ%c{dVohcxsveMFKX$<#cOOlBq3~_9JlSHRAtw1Kar-LI|3h{-47V~`?>#P1RO=F1_vvVu-=6@OL^jw)k)mr(cCOjy$#rax>(g^X>O=zd=5xgvWybAx#oeN!oc z8mkwU^-GoMJq*Koms|;Jypg#wH-*!XWG4TR|NO*DK7|@s{))1oC`z+NtDu*4>sIZL z&7T+djlR^?NEqR+v)sk2DITqGC)fgZODAyI+{o)z8=>?L&1Y9*b0^!2bXKH=;CI6% zNGubZXdD)CmM)9AzV7aq8vg9mLG#XC-T0sfzDI~QS@lU0C0bW1<;}!d4&C3(4I^De zk-Lj)Mosy9DbkSUZbB#QjA?ScLk+O~2vUp>{zgqBJ#Cd0xU%S*h(unw8*Lq>lug2# ziGi4{?vrUoxs$>}AXv7JOs#6|p&TQmvMK20h+alT)`?pY!wR7Y!vsWr2o(R%!flNv z`?V6dDq0DV_4sit3ZE4tt<jR*TD1Lvi8d{vjkO#iN3W~mby|{ZLIy#|7s@MI zuv4d3@7f|U=PnV^S^K#dtt*zwwMvS;3O?E`T$=S=GmzH4-q4GFUGmmq+cJC_Ub*A_ zM?(6BvNDfpR{QGMQ(E+`KA0gbK4AL{E5oaG&IG1bOZ%2$CR>&LH)YHCdQEbmwn6~{ zHm3{^Rb!EpRz2)R`s!Fs1@dlW?kw?5)o~U*c03mUnf~{(Nk*;h8R7Asi)tFx{#e$q zRRqaLlSPAOTWPObk(u!pbarKT^lR{{l*~4qlX5Q==ZV3RI#1=u37ESJ`{vwNYx#(4N+%&)ZG~bczg?&tTwBipbc3J1hnvrdp|C|@oDYII?!$#VSK8ddy$P% z2U`B@$~|rP!}4M->!nO=E}=HRe(VJX`JIa7nv- zSSbWlopueav7qLdj7Dx|pGIxbCH*31Yz?7brgM3k`cX<#w-{}=8hDqV=CEoaACE?D z`9PjFkyI^Jq5vGK_to$a1e@YAru0i748NcF+HXrn+eb(H(~rp3Pb#+_S0+$|%CkcJQ@3#64gsqHML z(2cg^Mcr!ZB#o-9Kcla6x7&8^^o2%{C)Mp2?f+4esxcq(Lo7$0(Q2g?8n;IOu6Px_ zS4o80;P+Sy^jguEQX}lBUpn)>tXy5G2!K!`e$I*vg|RE^A=Rexw(1r9M$8_9Zc?Z$ zVdZBanJ~(s?4{huTVrQJXBwOth+h$B6)^Q$eKtndmPf=jjrf^eq>=aCCe?oRh0;U5 zkZT8Z!q7bskx?7w6t^zeqL2}mjUUGi!&r~_8`;8}2Q*5vTD$`i_NASX zFvvhzSjwG4E2d?lq+5iW7vn?m+9970l2yEXYazBIajPX36C@^joE7;7$$DZ?;kVT3VO{fr?n$6AYX zW5f1Xx6PMhCao#3;KxU1w7>f~dHS)3DCR@0BV_Rs``?Red{gLam;cyuc{7wcT8PAeZMP5*T3RYm^%-<# zRY|FeAfFnsI%FqU(pM^?HkY;7w@GDJ=bqEX;`9RY+WpP_%^5a^bu-B4O~1jUA2r_X zm0#sTAw}fcIku&nWjA|-Rahoa%0@(? zIUr^*;Jirq&}#V-M0#vmhAGW+vNS-5+#GF79o^HSiJ*z{NiTqrf%jf`$hMC>hSfcDE%lE1uKH8^y~zbtDCD6CQhV>_snGy<7nQOKD? z<#Cba8rmdGYyViOEE8l*mXoEn4l@k9!G9@<@Ji8N&<-)TWN6WTM4GTv=UItWPWLUM zh-gHn#;rmSU|xDQk%UvkXoruTETBP5uo!h{V5_fG2-#>I`>=1n7AX@+!3|z5chTZz z_3d5LuMslm@&WnXqeO}bLFP6sZIwO54o_)wRS}YcB(Wu|*5sOzZ38EjWZC9rh-@6l>tp83i-<2^i6tWbJSAsE zYbg*uzOkVpA2hHfE#LE--_Z*=)H;_6`s+2PQ7aDdmFB3mU4?SD*bZ@Jzap$V!3O=T z{AWD;P^Ah;>4n)?G7{_Eb}NT+YK?njD-3*T7aVdaBK~K~E-gx@+rzUncZSJzOWcq# zRkz{}LDgi6$^AFsD!o6&zz^x*NcaD{W^|+z^{zIG1KHGYak|~hrZCU(YBJI;@I#s9 z$*#62cXoB3gem{qVcG>Nn4m4Yqr=ywt4MKrPvz{Q{*g4}gr2qMR06MJFe8(4hcL(z zOUCOKpkmiB6WKLeCs??VT~n}lJ-Y^Z(&c}CByVj3d(t;Q9`h9v!C_#&JQ`E>mEDi110dLb>e5bgl0*bVjCK#US;x z4V}U`+`|XxR)g%2hzORW#>$FFqMt0-_CnYzJ_SBfa z?)=ctO!lZ}lP)8ExIeoNp(5#B&o)tjs7<NyGC7s6c4xLN6RsH()8T}pBV#Oo%jRkH!gwT^HgR;Gn6 zkaM_FhO)igrX=B@vP>%q%lQ`R2JsT)U|sshEz#o^#Qwr8l5An z2M!f4CN>dF=dB1u`d*7{AYr>+_SsZR+Dv?`hL_d&tyJe)DMOMw+ISd)HuPg{6=1C8 zajL6+%@TXNgQC%jhG3My9UJ?IT0H(c?wLo6G1O`|T^XhCcx~+4Mp39BnyV!eCnWiJ&w+*{=d zYD2yWakC&%i%iQeWK~FW;Sv~zP;JwG8du8vqEoixNUq4bEWr!F6VXmy`D z$o{nBn>%>XF#Lx6q0_CwDUTZW-$k&V@9c`q*bDw46A$JaKON_%srDf}`rD{>-;nR# z{qWt*hwt8vBaf-Hf3RWw*m)1%-EmM}-Q6K*7+=*s&v56=h6l}z*+ctvgD&kaFLn0& z-RYKQ+{32YyJ6}cZ!bSKtBlS4vJ?I;+T)i~ zYTe(EcUbzzY5x)DJzObEK0cz8pYe!%{llxLC)rzlW_~BnkDp5m6DxhQdB1HF*6=&l zP0Sg_1FuyBesdSdsMGD_A`z(xU; z<|4n-v`EYHJSVcV`s^BpTB55+vwU#y9S7f`Itrp4Y>nFd&>yte+y;fle}jWJ4F;~M z+s*mr!oi!{`nf-{Ukh{>iA#Qi=9GZphrhYBz$&#Ng#|pC5A~~lEnKi6J+XJODYiz| zYUK-TAy>?yF8Rz(I+o!|ZFq;;Y{1`V6Kr|aWTnvJBtTkd9a=zw@hG-Gj#$3;;7y1c zlECVTJa1$rw(*c|Ol0HZV$oK9@Mg9m9Usq9je@q$SZFf?Wrf0qe6q_%a^5p5N|7bP zPp~sY#6W9dI5>Fo!JGM^7e=WkC(6e3hJ|6H*3{y`oA&VjX`W=7_GrqeYt-jjQ<4C7 zx_~HZ5$)*}io};^t)(UVI^P2l2oJXW?&`f$Onhr`SRaEZh#{Z?3Vv|4Xk)kX6PWET zQY>GSx7ttw!;oQQmVREXXMFuio}CQKwUdytqC zag3LtP2^WG7}@zEZD*R8ESbOj1bp5;c+=7n)5FZ}K?8}GQXjUqdV5HAjLb#qh?mI1 z)eGq+4GRiRO^K1QrI@E78!!tE;@HubqorAAtC?sIr!}b)*rp~Z!1n-pWEh%xEizdc z&NFC7gEgm7lYCof87aZF>WN6i5#nFP`$XhRDu58`ssV1&ZEi?xr zj%GvLY9F07EeN0Dq0q}huhm-WiyUJFCHAhuEk=CQ-cX;51?0zG1bnNSv5r4LZPH4p zD%(Ytg6d*_el`Ks0m&D7qY9-BCTS1HCkgS0u#$6;EZWEe{zT0<5uZE8!sxN}$tzz& zn?vo8vbVtHfWcB`^xSdoOLxikL&~=K`M~r$6=e%7V!ui|h%I#6i$W|?1EdUs$wVKE zEi$@`!^M_HwLr}fA2p>64hic0M#h*z2oa>mOz@;R8O{xRAxT`KEw!pyww<444%JYl zW|d5wV||%a6Dp<9Eh1w0ig6UZy|4t7CTSryE;$&T0+S7E%(}Bw6(&x}`Hap9BL1)f z%+*XHP%ty@xRLNVM_-P~1w6+&J8I@BbUZP@?r1mB|%-`aToh6 z)<%{jL7D?+9G_pI5kK0d8-+o+w8AAqX>g|_mHL?N$Es9NZupKS>-4aZh?@`ft5t6& zn+pT%R%bMnr;X8*BiY2E{qI-})wdO|WUjoB~ zUfE=luTD-iWQ0FgHZ?(j8gG?f<0yHO+BTmrGuG@)q3ZeES;1nM$g#pP^Ji`AzZN`M zkGiN7Rnfl%st>3p^SMY8!&DE!rle`6VEis-`eLgnyLe=I=2;EifwcsUOTk40Qu-L0 zbHn_cv;*9jSYS74&f{gHTC;)LU>!Ett=7{urS;kide#bK~7VtxnUlD zZf}%Aj;08vY?f>IGNGovL_6TYOvI%E%LrX;m~nwBi^f%=Rt;}l&^FnivSzjy>6*wP z(@Z-C{A1bs+zb!zzKzGfuWhX37Zz0nNi4$}8WMuA513d^7;y^0$Gfz}wB7O}wfjJ! z*>z^-g*E5Wr8EWIKwQb}!!l1wLFQ#L_!ivDAjml1Vx8!yd3U5C{kW3!k^1b^WQ6sT zVpbd$9T?BUnzEI>Dfh$N32Aeej-^TuS$Ld^U37-rmdrbnUO(JzHR<4G4A|aSQVVj9 zTjph3>>uTg_1-{c@Y8{2+(=wZ%b$~C=buiA)h&Dt24CV9^n2?FbR#7-3*#3BfK86}r7jc$bY&~7|hWID`){Zt! zAP&)`J#exi5P>BdLu(*U`F(~~`gw-%?jaO;c(^&J2KK@kf;xXf#ca(v#?kEUR{wWX zmYlFd*+^;SG&{Vunie7&81~GT`A!Q%2yjr~uJ`FtvrQDiP*9kv9S>u z*kRgnsUejfLj16pJ{BA%#Feusye-p)_^N0_e0vu!hS0S_P#P@8ZCoCT2>!ZF8Xate*O4t7;9+|#tcmR?GH zp`{2Jkthm@`grs~wh_7Gm99ABRsJ}yXh3jVp*+ zB3U1e;^Jd?aE_QAjyPh+Lv_dYl-z8BNk_eTP)PpJKPI|QuAa9c+p0c2Vc03 zPa)(R{A7ueamc*d02pU_k$bU$cGQDSsNt8^J-U}~AHw^JJMvRi@SXf4q)&&ik;M!O z#o&0y>dB(b_PvOvgtca4HSxoxB?25%2XDgJxUt(7EeDbnq8LgZgCfN!7sYo@n6Wq} z)$T>GWr?5dvKZ@8h36RQ&sIa;yRn2x3_RfB!eA)Bywx6JJwkv>L#(NeihPdLztqJe z_3aqt7Pw&yu43sTN5`rqBpTzo^wJ$Y~!#z->zjx3>ykH3; z@DxWVSz=M8Hv}=wY(Q+0`kV{d+Cruw^cKQ`@Q|9w#rwn$Co-{v-3ko!*QAoE>~7oZIS)cL-@pZfDmR>8KgiM6p>rbwfrkns1A6PuKMag3V%k+=T3h`^n`u zz)J`1uEjx$^w;lq3qQ<-Azua=Y4u@WdRy{?dReI@IZvQRDhQehztb*~13)$?1y7e0 z{^=-exMkBgvd0X73ilHkF##POx@M@Tl5STTD&j`&tku4#JTRd84miGO2`?QR zX4t0MYpV=e_a_=7C)6f1mBe8(C1#}0msFxl$j!(XN@0eO2zxQnp`F@iNT+@9#_1Mh zOu$u&hZ0OrpYVzfzw?R|Lb;ZVO#uMcJ$6y|{+C}3BhGmUL#xOzu=CK=_F1x6q-%O+ zfKY<(N%l3D=qP+I9Ys)hng6t+36J4L+bgsu{G0i>Vq1r^dB?!wP0BqeD}rgFo-wl` zWmt~DCu3{Q>$fs6KTV_Le4!r<#*Nr4JKRF}GPTu$6pC>$58K@|CljdcvKg_D#8X72 zN3?)P=VhHU9#BI@0(zIWtNR|xa=GZD*a##-A2Lgj6V^-OH9IR)QvK%2=3|HmAO0qZ zJg1zEod)%3k}XzhiYzB>li5{dJQhnI`-Q{@Rn=C#itUN%Hykpl&ArCCdy4YhtOEQ# zlmdg*3;6PyXLs02$oss>uh8wMM9Q@_}p8zS}`l{OdBx~TUi;vJER%-h7r znN}CN-Da;jBOs)4yhSgbrlO zog{Wjfi=L4F=ps)#>G&nl#3(f&uFvVRCL(amrb$dv(z(cnuUJID44?81QU1}Yqc>t zTIR*u{?_4M@q15Ab<5-&tt;^)Za`Eh>RZYS3c^&CHI`d}s*mH!VSD)B((!thm7+GQ zN65CVbX7d0WMZj>6%a7u7bi_Zld|6xv}u9^L?t5IElr3E14QyY-$S+(2TLA1(MZ7wC zRRXmRIGMyO$nA!Sny9mh!+Y?VJ*_AJ!LTE?1w=@LggR7FB-UgZcZDnOu}BXtmQ==c zD(A@+miRl&Kr^oM)mM`>P0Y7i5h54_IW4iICMdIF-AJvOBfKs(bI7ZX2-f4mbN| zUsSi5dL!(otu&$#071i65wkiaH(cFnWS~$e)M6ST@;XjAkp_egBEUotaw5A*nxoZ^ zWpp6w;7tw2VnYfuPd=8}^+t)#B<>`+YXmi#`LL|9NVZDyPb*%qykR0~-Y{u0IspSp z;3Lobq|FiKTKgzf;4g6(^GKnp+DM2j>Fu5|xA+AuOLYc|j12Gi-m=*YszxhIAF#vR z#t{yxt74&&E!3N$$J$Uj*2Gd%{8s%j{f`oj>oNgA2{SY?&}tw>I8B6#VkIw9Xhq+! zNxckeBepPUO8Le0dTE-9VWsyyLQ0bxwPcE4T2rK$Sc*iGqRO%-7byQCMSvI~j%M?L z=qjyvpM@%#JARQObEwnti?*0ql_J0?gSs;rd{w$Qrb67Q&}4~6Vay$rpImeWHp}Gc zG2qIWhadU$hShf2YW9I@be#`%P$VwhfdIiVRVl1(gR zVSQ-WybE~}&PGbR>qmH^#KCFG`VrQYXjD#v^qQGpjnPy*X&mg|oIJHVU1Tk_%1f+3 zzZGx5Fq1EW5j*OjSdZMn(JSPkSieRo%x(zz_LECzQ?*jA!*b^3>}0Lq{>`Q^M23CJ zA_v*!I3)|cY@_`5D9j^jiu5)WSP6#w>MdA#d(EUusU))wqB6wi-pRv%Lqwq>pJ(JE zAKmv5U8(lYB%T6C>Udc<>!()2Lw{5gYdMc4F+)qS1?dD)v{{@MXRcN3T3fEABmphx zj;2yEt9I$c*s6jA9&99CCQs55H>BC{;}Bv}wU8qQt~yXX!Xi`gkLN6T(sr4uz9#TU zIKiw2-iM>Wqc^hFf_$f$is5`TwJdv%E%I1TgW6K!aJfUF5F16=J;JLt6_|B|5a~=m zUt?9Mhd5}1Vr_PLEk~yi=w1S#%?(tn@AhPyt>|8JxckWdRkx1b#dMVIWmk9xBs=)( zcEfWN*%ho)8BVh(MG@Nt3i#mbDut#KEGR;&TKHbS#T3n9zb-33QpKq3YkYsDmk{%u%uFI{U|ecWiZi8QpsX$LB^H3ICL(g3C${q$(%#47S1#h;TwOE zOI^Pok67-etJ7=bGE%rVe$g_v)LQo+pT2BP>Urs5rBxvg^v(-<6)M>SP)? z6FqxSvCVWz$~7C_XagJvU;n<3KVu*or;FFt)p1neQqo? z@;~#4e<_KG)mI)68??zzFxF*N=|~k<>18?VP&VAvra|2vm7AXRSY{We`=Akb3@Yyw zb4ig(#gjb6j3Q)XL7Ah9D{1)jS5>0eRc(l=LNKfEhLVnQq{tJH5M{N<{xZ;l6lMDX zh=P!{MLed_R0s+2OuN;hcHN^Z&{Np3@+lBuWwy@I1u=sKGxmA?e9^`=w~Pp1C>08~ z(S3s0pf|!cL95{gGDN;Evn@WTuoGMeDhHixSUO!5A1En3r$u0l&7>+OD^wq5s!xvF z*h=_%KG5TBPz`RrVm)T<(>rC^Et(icc{8WR%H+M00u-o(a+k`(5Zpib8s@7!? z5q!f$F&3b2j%bRXN8M|)hl$cL8dmP>W@MdyBp#ZkKlTbDlb)eA*~XdhuH-fOH;uPM zvP8T$p_)gHh5M`@-G%$}Axv+0?4lg#{@)B4RR!9wy6x z$7X_Hr;H;0qYEHL@jgmDNJFYv$JUWR-oDht$s3|0N|dk7f;+X zx2TyC&6R0TIq?=FHCxYu1JhVpAX7pfU5mW3AiJ`t#h2 z5ZVy0yQd#(r1mNdZB`wNmdnN8?!eQC*C^OZ9~xtFkfm&Wv9!BM=)c=rvsSy_q`Dk; zI5uR}54mLu5=)mQ9aw&Vd=aJ?ljRj5wM;nrte0MGdDEe}htx6+R`yW3=(oF~7-^CS zpJe2rxr+4U=ndY2WNZ4~TaM7|NYi`+4QY`As?4dW7%mjP@Il6?ig6cM&pcK04(Ppn zI&qH0mBa`&nZB--vMKAJ0&@l%Vlv%DIzf66KDC!&53@`Pvqu%bSY4j=D+{-fBJhfv zzD<4u0R|d0sqxeE8`oXR2}CA`j!&XD0-zM@xXN29+Ek;6`0yOH;s{D5DxvrY%`kmS zF=0p?7UP-PjcMugMuk*EO=ij8lQ7cLYm-0EZ-X#gxL06(j&a<(4QRJI;Y#&EVD;*;B9A$8j za!+DMI)wmfl(}FHSww`G8+2oeiOE$(lo}m(;jW^;;8%!WJcV=1Xyi&bVYd%?TecH2 zb*n=KJ~dV?X(y5xE;?#8m%5!n8gs(=q;f`NgfEVixhlT3P)>BtS}F~|QeI3Tfiz_d zMr(D+R+=$pss>M6LM8NQ$P@8qO_0d4a|^a)2fPv02FW;tz^GMYMkUkCKPI^!QYlG> z5T7!bwX)T6=QT9A)V1-N{6qUk zxV2X!cBKNBSexWz+bW25Ygl{>2O6hf`Agcx{Zt(uys14HlJgIHIj;r_KTDWmN2w|g zMDSiq>TQgCy=CZCrGmccFeiz#6e-7-fed5X{QdP%2wCDJ8Oc8TozAW07kk*wrYvaK ziJ^%srWUw?fvKg8Om~(9sWhnG6)mL8BMp=V@=F*8AfEt*1=VUEw438H%H&jPiFylj z752jD24ynt#kDqLQv|0-IAy!!X~oKEH+@SRH+lnpdhDqOo3b4Yr3~SI=2cW-P+oI& zlWp`8R@A%jk7k#+xBB{2@hJUIfjU1bknD4C9J1NXhSA)!)%hWGycLm7dA}%5i59ZW z$MKTG8wTuk!{oQYGH?aMU>Cj$)=xHN0x&#C6p~q>XeM)^vdN^wWygs4z(IK}37`74 zgr`x;OCl_p1jctRfTokJFSQ~j8gcI-dnVGN=+(1u1lb>yw6W4ibRhhO5YjLtG^1!j z>M9Gkc9qmTDgUX)Y1B<-ld;sVni#B)+FCyeZ)Ygw|%S~3k6p1M>yD)k}7Rr<-4?$Y{Qap_`DdEe`H;qOdaS&p$g3A zwyWH}^U9qT%kaCoVE&q(bQ5MJOW&Sd_H||FSMT#{_PQ#pR+Au;3#??xCfV|&L3Wj4 zQ^YhmQgVRF*C=Fj9J~=G2iMXlXkV*CvM4+jM%|UzTFmd!k`2cxd6}AzwZ#03NBoX3 zOQ5TAjk7X$v{-*( z0iV9ygd(J>U#S#C%^XIIm8S8CUZ`KMJz0}OA(SBTb}QRvaRd4;L(MO_%u+GTf?0^> zuplS=9>0!a;bw|B?cG8WbwXBI9`c#_H+Ew#2@fIUF+vw*nGilWcr%`i_8+m$Qd~IN ztEI0zS`y7^OOI3tVp)<9|0c$%oHGT7E>naIzoCI|+g4gKDvO=%msJ*9ReBOLCN-86 zsIw>=I1Rn7!pea!PyjJR31#qN?1X94ICwL8S3<#v8T?HGK_&`w)qsaZ;Oo@Dn~ZT( zL}YsWO{xjNCW7yziANtX`^$G)L4xr@Yr%3=^5iA^ZLNrAKu)l=@5b+_K7_BYO6uH< z^wK7T6+v~hBrntBhAO(%#Cf~s4l!=IL$%Ep zVp#TgIU>cyO=>8>7ub{cme!Qx3N5)?Z|Y%BL8wOigK#g%QvhQktuhE3DfGk0v?3Id zIAcU+RN6wo!lqT$Ur=(Xh|FHbArVW2>J~W|3dIai8yzj_vZgK6Yg}*fU0Oj+x{wNY zjmqSoBH>mUW7fz5C4jNsP+nUqH;q1u;Xs}5b8D;-h-8keGd}5j<7kyGob*v0wg)DY zA=(%|8_tw34LX-zt6rL3o}lpMvw4J0Tw|g^W9IH;S(tP{Vt5thQRKo_X4V#qh`wd@ zCXGKbrH6LYyQdjVcH-!)+9Hj5gJu|3!cY9BDS~B*N5#v;^H8Yh+GIT6OB67l%f!H3 zvxCi!MJ?MCQ7~Rl644kzi^}L;YPE`1$gP;zNSVDa;6SDw|4u0^j9a1yIGnz_2yqZa z>19k28s<$z)V!DBVS97_at2T#KggHo)FWcTnC6nNTHzaYw`Q{w3-;KH0wvTXS@o>q z{^AZ>>_#nu><*{Rl!&qYwQO2K^2fju#StU*Yp?J|(vnJTu4U7t6+BLU z;FAdYGU;OW2Sj1}Ke1I7L#&qluuw=9$C_`*#e{%Q3RMF#je3^Oz}g(vp40LoD-jPL zCY5MaC@rngj$B>YR5gRlHAOx^!!AIfK?Sa|M#fYc2BX~N-ro;5BCS~(9g%qQ@Z&kY zF^u*%zsdQkOOilV9VIaX|gh8l0}7!T`NkenzD_-%(Alg9`Y*t zenhb7X0xNFV_uSU(K3B$C=)RL1~h}omq1I25qsC+rHD*~Jz^~dq%ja+-0~L&y^KacZu_USbaf zr`(v*?dC;O5kjMippp`FGsSU}yL|;D zY>$;#BcmR5FWnEZ*B-p7Cwr~JF>K{)O8#ehA6eA?jf}q3F3=tpEh=c)&Y2W1S>z-6 z;)IIi-{sBGg0aw$hzZqQle zXF3&`k>WAgw#>-)3LDs!bxjN=BHUImuiq7_7L$j@8cyd_p%_ZUfDB)kjOQX55%%(@uGCf; z;3b@ogibD^%Yx8}1^KbF9(1N$%nP^&+CJ;SKpcRSh?p3?!loTb@SOD!J*U(SL1khX z@*fV{VhZvQDSwFoOg00^axiIr;R2o6k-Gx2*+`uxTjrhu1Qm|zb1L$d>d{cRssft z)~+ddxcm165>M1Wng#n|kuN*YM$UVf|=N736ejH;vFots@pXt%_Uf z^s!`9G3wJM{7%bdbPqgL{ouG*iA2@UBCi@&n)7B;HQ=ak1^MOjW9xU+=;ey zEN4Dg6?|37eE5Xm=`wCYW;m_Bv{LFvUZO8>O}MgcRTrFOP5t00vfU?yCR@auD64!H zNE|> zc$R1NoLTjO(ubqSQLJi9&4B}VZ2xy7EWN$-y|h zB_6h0!a9M4eyTgEQ`k~;L?wa9cTZnXBI;gF_(KH~t*NyR5T6dRja-K!CzFw!l+r2@ zD$xR=NQ#)BqP)J6-2Q&PSwX3qW4@vjL~)ANWmlSBv67mGC@I(iCL=BlkKQtG#=BdR z)3JMOD|U8tR-;qFi{5)?^eEFxAz#!=ji7O*DP0kZ$-AqYOvjGM^z<#nX4UmufYS8t z4Hm~QH-YOU07DlTp^>w#f(DSSc*gbZv^_wj#|*RViRO^2cqMeoN_N#Y9N~Pos_$RqmQJl{Eb#p zKo*GI0#$Lj)q*F)a;**mg_cyJ>nSYLz^dyPg^oc4_Ne5C_IX#P32QC19k$U?bP+bM z7m|G+T|4)z{im+S;hm^H?eThBPHHvV#^>;Yy4vzZ^dXGuk9*%2Hqq*=&WW zfiPMSI?ESfFmj|s?#-5xLv<)r`Poq3}afUQ(&1h8ao0X$0}F)fZYomo|FGC>QfybNki%%ezX ztr&o$wkN|%VlFkjet1G=uY1N88MGweQBw{)!h@D=Fl+Sif-JeC$1TWw1V`2io;f+r z0o1b2deX+>Hud30aTFE2%(9xoJBhO6n9-w6frLuA>$lr8$2JkQ2YkUG-kI3JD4K#K7hd8MCIXUCniO ziH}$$cgqjN*;+VrJqR|akOphp?n^7?N2CFdQToNtJiBF(qFrTAJrNl-b){y+_;z>Q zdgHCTI92pPuhc$Wsdz_WUHo7?*A;5drS_{EN028`Z=I{8_9&i^RKBLqoev>GVQ4*f zNRfNp{4iA%VJJ^hqv|NdCoFDM_5dlUuPZ}(m62C#a z%Z@r4X+@(tRmKm3WUaG!R#in#SQAuX`b5iB|IwhvY5^z^04cVB zV_J(FZN{p;E{vO~$H)VgO(7kX@Te{VKYLm1nTmJOp{j0I%(|Inr3N*1gPZ zr>()UFVd1@3aXo>uV*&DO3sj(TD0tooy|Fre}OEBz?r+C{-R__vb1^2xNB{sl~w^L zHvaz=cdol}6hRc8M{y!hKwA3&kO&G0l&chpkiU^H8)xHPukqR>;XQbRJO=;rVtnUR zRZow-R)`|VpBQ#`W_r4->vF2+T=vbZ}=jiYrKM?oLDMsaH}PC@fXs5THEq`5U3qGI1kG=UaKX-3+0KEzb&t8m#Z+ zJaec=P+$+=W0YRnO4^L6ZDJjkAk9?lGX?}*hZhxWi?#JO!nNs_RKTXgHu>6JT#J@Z zu5(`nDtY^P$W@d8KzNNWZ*%sDx-Q)`0ctbvSMg^)ssm4@D_HHWPCj9AD}_dTk_wkK z4njRo9H#V4Ewn)^a)lZ}u~>k^6p^|ET5ClO1`Y*_91X9b!$Kg#T(&HLW!g>Z!IwPN zxY{4FP$82l3@5l1ho~m^AfwjqB)8CpH5kMQ;02sTd+VVR9_qtVc^GdaNCq3qS=%f4 zUN2lq$CvT)JSz4Za#6kF3IF!Z;$x5m@cQHiU^;^uZYbzd3839(KEX7of7AQ@EIvFk zM3{+u&}d}KIZ%t!_`RJ$nO|9%;#Q3R+hmK2ziM(2Z&b!4FTCMf@L@5%QqmuHY(Jwn zQFnI&i}BR+1xXg3w zX<HrH^ur_xk(1mPA$nXu z{lOgKhk2Vk~8x0)cT`Nc{b94)AjqI;oW z6`_-lHoaOEoZK)ie1X-NLNdy>H&`pa52jy*J75uG1rimb_U6MN6IOA8FmuPXB)`L* zQ+tj5Yve&ehgIx2MnZ(h*eQUUuOJfr3*Ki$ADM_&(DnHN`Ds3(WAwv&SNLYa0qa-3 z8C$KkOJ-)r?7sCw_eAa^cfyA#2&{U9K|xcjdM@Tr#O{mSKQpGV0;{6hS3bh z8D;+J$Ult+bHzo`mAZz?9EoQr7cv{Jyv6@z=7YB$RuXnD4nap~b7$xKyE}Iy@4o_wzhG(=p&laoW8EtIqC11|O@HE@N*u0z_E;&2-PMy#YI}JxCTFfm` zrlkqTk?Hd5g(@ecTP!YIy{>3i)*&>vKs6~T7Xl)*b@60^BA@FgNP$~XG1&sUSchO@ z)_hI}W4lwH8IS1Dhov1}bZ%&^DnE>D@s@fTb-y2D6uU)}P&viS2r!;zjmRX3iX5Qq zL6v3|_4Gn?8;8Vjaifu;cXqLUflc8AjA~PjWzXNN-o4oNn-B)3PZ~w>V>MAC=7HxD zxINZ)hB4xK9_L%mLh$t7|I4n`IgB)Qr2xD{;S3r=tf!I}>IGvt+{R;HG3 zx~w8m6}@32n;$GV$}phvgxFwc({RbS z7sz1U7QpS4g zf@sKjFlM0gL=Ti39?xkqh6Z&x-w!I48tec0@{})%XNl|Zp2A2fUXD;!nMk7&&WvtyN|;S{0PX&8D^el!Oa!TE=;YK(~qy^9p;H@5z0 z?PdQniW8ED-FA;$m#G+i!=2s7d-}yE`3-%~p zHV?Uxs-L_VKtUV;9Bvn>)|70;LAjIs#aa1|UL z6tg_qJ6x~SXckrphBnS{;olYiK2~xt-S!b6xOR5Q` z48-B6xCWK@3%%r;TNEKK&i&vZx-~q(c`}r)Zbv%Pc%8b*4_8mb;9 zRIN{02;PsOwljiyLu2pBq3)@@{U~X3*g_$Hyk+cBxCp zdMDd(S@w1wq6gyKQ^}`tVj;U_Nf@^i>Mf1oJU#fnIXG_ZG)*Ec zqc;4^2xONCOBblesWjwKk2`vLH9@?rrYVnc+uM17VHaGC-@?i^@!|b62L*d8DaQ7Q zbr$P%`^Fnh(ShprRW-ObUH$?>_UcXsy)6b@ghy`cZph(`Yb$mT-s zd;i(F7@;SZZ3w`IgXQJYu-pP(nPcm#5@9r(r5n#1)j=UKXDa{U&F5j_* ptw{LSm7I@lKia6Q^p#u4&$yahtdh~a0SsYqhG}@SIJ$T>`~z|nPD=m) diff --git a/languages/option-tree-et.po b/languages/option-tree-et.po deleted file mode 100644 index b6b1c46..0000000 --- a/languages/option-tree-et.po +++ /dev/null @@ -1,3021 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: OptionTree\n" -"POT-Creation-Date: 2016-01-31 23:24-0800\n" -"PO-Revision-Date: 2016-01-31 23:24-0800\n" -"Last-Translator: Derek Herman \n" -"Language-Team: Valen Designs\n" -"Language: et_EE\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.7.6\n" -"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" -"_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;" -"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" -"X-Poedit-Basepath: .\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Poedit-SearchPath-0: ..\n" -"X-Poedit-SearchPathExcluded-0: ../.git\n" -"X-Poedit-SearchPathExcluded-1: ../composer.json\n" -"X-Poedit-SearchPathExcluded-2: ../assets\n" - -#: ../includes/ot-cleanup-api.php:84 ../includes/ot-cleanup-api.php:101 -#: ../includes/ot-cleanup-api.php:130 -msgid "OptionTree Cleanup" -msgstr "OptionTree puhastus" - -#: ../includes/ot-cleanup-api.php:101 -#, php-format -msgid "" -"OptionTree has outdated data that should be removed. Please go to %s for " -"more information." -msgstr "" -"OptionTreel on aegunud andmeid, mis tuleks eemaldada. Lisainformatsiooni " -"saamiseks mine palun %s." - -#: ../includes/ot-cleanup-api.php:136 -msgid "Multiple Media Posts" -msgstr "Mitme meediaga postitused" - -#: ../includes/ot-cleanup-api.php:138 -#, php-format -msgid "" -"There are currently %s OptionTree media posts in your database. At some " -"point in the past, a version of OptionTree added multiple %s media post " -"objects cluttering up your %s table. There is no associated risk or harm " -"that these posts have caused other than to add size to your overall " -"database. Thankfully, there is a way to remove all these orphaned media " -"posts and get your database cleaned up." -msgstr "" -"Sul on hetkel %s OptionTree meedia postitust andmebaasis. Millalgi varem " -"lisas OptionTree mitu %s meedia postitust, risustades %s tabelit. Nende " -"postitustega ei kaasne mingeid riske või kahju peale selle, et andmebaasi " -"maht on suurem. Õnneks on nende orbudeks jäänud postituste eemaldamiseks " -"moodus olemas, nii et saab andmebaasi jälle puhtaks." - -#: ../includes/ot-cleanup-api.php:140 -#, php-format -msgid "" -"By clicking the button below, OptionTree will delete %s records and " -"consolidate them into one single OptionTree media post for uploading " -"attachments to. Additionally, the attachments will have their parent ID " -"updated to the correct media post." -msgstr "" -"Vajutades allolevat nuppu, kustutab OptionTree %s kirjet ning ühendab nad " -"ainsasse OptionTree meedia postitusse, kuhu manuseid üles laaditakse. Lisaks " -"määratakse nende manuste vanema ID-le õige väärtus." - -#: ../includes/ot-cleanup-api.php:142 -msgid "" -"This could take a while to fully process depending on how many records you " -"have in your database, so please be patient and wait for the script to " -"finish." -msgstr "" -"See protsess võtab aega sõltuvalt andmebaasis olevate kirjete arvust, seega " -"palun olge kannatlikud ja laske skriptil oma töö lõpetada." - -#: ../includes/ot-cleanup-api.php:144 -#, php-format -msgid "" -"%s Your server is running in safe mode. Which means this page will " -"automatically reload after deleting %s posts, you can filter this number " -"using %s if your server is having trouble processing that many at one time." -msgstr "" -"%s Sinu server töötab turvarežiimis, mistõttu see lehekülg laetakse peale %s " -"postituse kustutamist uuesti. Kui serveril on nii korraga nii mitme " -"postituse töötlemisega probleeme, siis on seda numbrit võimalik %s filtriga " -"muuta." - -#: ../includes/ot-cleanup-api.php:146 -msgid "Consolidate Posts" -msgstr "Konsolideeri postitused" - -#: ../includes/ot-cleanup-api.php:174 -msgid "Reloading..." -msgstr "Värskendame..." - -#: ../includes/ot-cleanup-api.php:210 -msgid "Clean up script has completed, the page will now reload..." -msgstr "Puhastusskript on töö lõpetanud, leht laeb end kohe uuesti..." - -#: ../includes/ot-cleanup-api.php:230 -msgid "Outdated Table" -msgstr "Aegunud tabel" - -#: ../includes/ot-cleanup-api.php:232 -#, php-format -msgid "" -"If you have upgraded from an old 1.x version of OptionTree at some point, " -"you have an extra %s table in your database that can be removed. It's not " -"hurting anything, but does not need to be there. If you want to remove it. " -"Click the button below." -msgstr "" -"Kui oled millalgi OptionTreed uuendanud vanalt 1.x versioonilt, on sul " -"andmebaasis üleliigne tabel %s, mille saaks eemaldada. See ei tee midagi " -"halba ning ei pea seal olema. Eemaldamiseks vajuta allolevat nuppu." - -#: ../includes/ot-cleanup-api.php:234 -msgid "Drop Table" -msgstr "Eemalda tabel" - -#: ../includes/ot-cleanup-api.php:238 -#, php-format -msgid "Deleting the outdated and unused %s table..." -msgstr "Kustutan aegunud ja kasutamata tabeli %s..." - -#: ../includes/ot-cleanup-api.php:244 -#, php-format -msgid "The %s table has been successfully deleted. The page will now reload..." -msgstr "Tabel %s kustutatu edukalt. Leht laetakse kohe uuesti..." - -#: ../includes/ot-cleanup-api.php:256 -#, php-format -msgid "Something went wrong. The %s table was not deleted." -msgstr "Midagi läks valesti. Tabelit %s ei kustutatud." - -#: ../includes/ot-functions-admin.php:50 ../includes/ot-functions-admin.php:51 -#: ../includes/ot-functions-admin.php:169 -#: ../includes/ot-functions-admin.php:193 ../includes/ot-functions.php:388 -msgid "Theme Options" -msgstr "Teema seaded" - -#: ../includes/ot-functions-admin.php:56 -#: ../includes/ot-functions-admin.php:126 -#: ../includes/ot-functions-admin.php:220 -msgid "Theme Options updated." -msgstr "Teema seaded on uuendatud." - -#: ../includes/ot-functions-admin.php:57 -#: ../includes/ot-functions-admin.php:127 -#: ../includes/ot-functions-admin.php:221 -msgid "Theme Options reset." -msgstr "Teema valikute algseadistamine." - -#: ../includes/ot-functions-admin.php:58 -#: ../includes/ot-functions-settings-page.php:94 -#: ../includes/ot-functions-settings-page.php:133 -msgid "Save Changes" -msgstr "Salvesta muudatused" - -#: ../includes/ot-functions-admin.php:97 -msgid "" -"The Theme Options UI Builder is being overridden by a custom file in your " -"theme. Any changes you make via the UI Builder will not be saved." -msgstr "" -"Teema kaustas on kohandatud fail, mistõttu Teema Valikute ehitaja " -"kasutajaliideses tehtud muudatused ei salvestu." - -#: ../includes/ot-functions-admin.php:109 -#: ../includes/ot-functions-admin.php:110 -#: ../includes/ot-functions-docs-page.php:821 -msgid "OptionTree" -msgstr "OptionTree" - -#: ../includes/ot-functions-admin.php:120 -#: ../includes/ot-functions-admin.php:121 -#: ../includes/ot-functions-admin.php:163 -#: ../includes/ot-functions-admin.php:187 -#: ../includes/ot-functions-docs-page.php:49 -msgid "Settings" -msgstr "Seaded" - -#: ../includes/ot-functions-admin.php:128 -#: ../includes/ot-functions-admin.php:222 -msgid "Save Settings" -msgstr "Salvesta seaded" - -#: ../includes/ot-functions-admin.php:133 -msgid "Theme Options UI" -msgstr "Teema valikute kasutajaliides" - -#: ../includes/ot-functions-admin.php:137 -msgid "Import" -msgstr "Impordi" - -#: ../includes/ot-functions-admin.php:141 -msgid "Export" -msgstr "Ekspordi" - -#: ../includes/ot-functions-admin.php:145 -#: ../includes/ot-functions-admin.php:175 -#: ../includes/ot-functions-admin.php:199 -msgid "Layouts" -msgstr "Paigutused" - -#: ../includes/ot-functions-admin.php:151 -msgid "Theme Options UI Builder" -msgstr "Teema valikute kasutajaliidese ehitaja" - -#: ../includes/ot-functions-admin.php:157 -msgid "Settings XML" -msgstr "Seadete XML" - -#: ../includes/ot-functions-admin.php:181 -msgid "Settings PHP File" -msgstr "Seadete PHP fail" - -#: ../includes/ot-functions-admin.php:205 -msgid "Layout Management" -msgstr "Paigutuste haldus" - -#: ../includes/ot-functions-admin.php:214 -#: ../includes/ot-functions-admin.php:215 -msgid "Documentation" -msgstr "Dokumentatsioon" - -#: ../includes/ot-functions-admin.php:227 -msgid "Creating Options" -msgstr "Seadete loomine" - -#: ../includes/ot-functions-admin.php:231 -msgid "Option Types" -msgstr "Valikute tüübid" - -#: ../includes/ot-functions-admin.php:235 -msgid "Function References" -msgstr "Funktsioonide ülevaade" - -#: ../includes/ot-functions-admin.php:239 -#: ../includes/ot-functions-admin.php:281 -#: ../includes/ot-functions-settings-page.php:366 -msgid "Theme Mode" -msgstr "Teema režiim" - -#: ../includes/ot-functions-admin.php:243 -#: ../includes/ot-functions-admin.php:287 -msgid "Meta Boxes" -msgstr "Meta kastid" - -#: ../includes/ot-functions-admin.php:247 -msgid "Code Examples" -msgstr "Koodinäited" - -#: ../includes/ot-functions-admin.php:251 -msgid "Layouts Overview" -msgstr "Paigutuste ülevaade" - -#: ../includes/ot-functions-admin.php:257 -msgid "Overview of available Theme Option fields." -msgstr "Võimalike teema valikute väljade ülevaade." - -#: ../includes/ot-functions-admin.php:263 -msgid "Option types in alphabetical order & hooks to filter them." -msgstr "" -"Valikutüübid tähestikulises järjekorras ja konksud nende filtreerimiseks." - -#: ../includes/ot-functions-admin.php:269 -msgid "Function Reference:ot_get_option()" -msgstr "Funktsiooni ülevaade:ot_get_option()" - -#: ../includes/ot-functions-admin.php:275 -msgid "Function Reference:get_option_tree()" -msgstr "Funktsiooni ülevaade:get_option_tree()" - -#: ../includes/ot-functions-admin.php:293 -msgid "Code examples for front-end development." -msgstr "Koodinäited veebilehe välise poole arenduseks." - -#: ../includes/ot-functions-admin.php:299 -msgid "What's a layout anyhow?" -msgstr "Mis siis ikkagi on paigutus?" - -#: ../includes/ot-functions-admin.php:502 -#: ../includes/ot-functions-admin.php:604 -#: ../includes/ot-functions-admin.php:673 -#, php-format -msgid "The %s input field for %s only allows numeric values." -msgstr "%s sisendväli %s jaoks lubab vaid numbrilisi väärtusi." - -#: ../includes/ot-functions-admin.php:563 -#, php-format -msgid "The %s Colorpicker only allows valid hexadecimal or rgba values." -msgstr "%s värvi valija lubab väärtuseid vaid kuueteistkümnendiksüsteemis." - -#: ../includes/ot-functions-admin.php:847 -#: ../includes/ot-functions-docs-page.php:398 -#: ../includes/ot-functions-settings-page.php:170 ../ot-loader.php:785 -msgid "Send to OptionTree" -msgstr "Saada OptionTree-le" - -#: ../includes/ot-functions-admin.php:848 -#: ../includes/ot-functions-option-types.php:257 -#: ../includes/ot-functions-option-types.php:3218 -msgid "Remove Media" -msgstr "Eemalda meedia" - -#: ../includes/ot-functions-admin.php:849 -msgid "Are you sure you want to reset back to the defaults?" -msgstr "Kas olete kindel, et soovite taastada algseaded?" - -#: ../includes/ot-functions-admin.php:850 -msgid "You can't remove this! But you can edit the values." -msgstr "Te ei saa seda eemaldada! Väärtuste muutmine on lubatud." - -#: ../includes/ot-functions-admin.php:851 -msgid "Are you sure you want to remove this?" -msgstr "Kas olete kindel, et soovite seda eemaldada?" - -#: ../includes/ot-functions-admin.php:852 -msgid "Are you sure you want to activate this layout?" -msgstr "Kas olete kindel, et soovite seda paigutust aktiveerida?" - -#: ../includes/ot-functions-admin.php:853 -msgid "Sorry, you can't have settings three levels deep." -msgstr "Kahjuks ei saa sätteid määrata kolmanda taseme sügavusega." - -#: ../includes/ot-functions-admin.php:854 -#: ../includes/ot-functions-option-types.php:1159 -msgid "Delete Gallery" -msgstr "Kustuta galerii" - -#: ../includes/ot-functions-admin.php:855 -#: ../includes/ot-functions-option-types.php:1160 -msgid "Edit Gallery" -msgstr "Muuda galeriid" - -#: ../includes/ot-functions-admin.php:856 -#: ../includes/ot-functions-option-types.php:1167 -msgid "Create Gallery" -msgstr "Loo galerii" - -#: ../includes/ot-functions-admin.php:857 -msgid "Are you sure you want to delete this Gallery?" -msgstr "Kas olete kindel, et soovite seda galeriid kustutada?" - -#: ../includes/ot-functions-admin.php:858 -msgid "Today" -msgstr "Täna" - -#: ../includes/ot-functions-admin.php:859 -msgid "Now" -msgstr "Praegu" - -#: ../includes/ot-functions-admin.php:860 -msgid "Close" -msgstr "Sulge" - -#: ../includes/ot-functions-admin.php:861 -msgid "Featured Image" -msgstr "Tunuuspilt" - -#: ../includes/ot-functions-admin.php:862 -#: ../includes/ot-functions-admin.php:3251 -#: ../includes/ot-functions-admin.php:3312 -msgid "Image" -msgstr "Pilt" - -#: ../includes/ot-functions-admin.php:930 -msgid "Option Tree" -msgstr "Option Tree" - -#: ../includes/ot-functions-admin.php:1068 -msgid "General" -msgstr "Üldseaded" - -#: ../includes/ot-functions-admin.php:1074 -msgid "Sample Text Field Label" -msgstr "Tekstisisendi nimetuse näide" - -#: ../includes/ot-functions-admin.php:1075 -msgid "Description for the sample text field." -msgstr "Tekstisisendi kirjelduse näide" - -#: ../includes/ot-functions-admin.php:2317 -msgid "Settings updated." -msgstr "Seaded on uuendatud." - -#: ../includes/ot-functions-admin.php:2321 -msgid "Settings could not be saved." -msgstr "Seadeid ei suudetud uuendada." - -#: ../includes/ot-functions-admin.php:2329 -msgid "Settings Imported." -msgstr "Seaded on imporditud." - -#: ../includes/ot-functions-admin.php:2333 -msgid "Settings could not be imported." -msgstr "Seadeid ei suudetud importida." - -#: ../includes/ot-functions-admin.php:2340 -msgid "Data Imported." -msgstr "Andmed on imporditud." - -#: ../includes/ot-functions-admin.php:2344 -msgid "Data could not be imported." -msgstr "Andmeid ei suudetud importida." - -#: ../includes/ot-functions-admin.php:2352 -msgid "Layouts Imported." -msgstr "Paigutused on imporditud." - -#: ../includes/ot-functions-admin.php:2356 -msgid "Layouts could not be imported." -msgstr "Paigutusi ei suudetud importida." - -#: ../includes/ot-functions-admin.php:2364 -msgid "Layouts Updated." -msgstr "Paigutused on uuendatud." - -#: ../includes/ot-functions-admin.php:2368 -msgid "Layouts could not be updated." -msgstr "Paigutusi ei suudetud uuendada." - -#: ../includes/ot-functions-admin.php:2372 -msgid "Layouts have been deleted." -msgstr "Paigutused on kustutatud." - -#: ../includes/ot-functions-admin.php:2378 -msgid "Layout activated." -msgstr "Paigutus on aktiveeritud." - -#: ../includes/ot-functions-admin.php:2417 -#: ../includes/ot-functions-docs-page.php:110 -msgid "Background" -msgstr "Taust" - -#: ../includes/ot-functions-admin.php:2418 -#: ../includes/ot-functions-docs-page.php:113 -msgid "Border" -msgstr "Ääris" - -#: ../includes/ot-functions-admin.php:2419 -#: ../includes/ot-functions-docs-page.php:116 -msgid "Box Shadow" -msgstr "Kasti vari" - -#: ../includes/ot-functions-admin.php:2420 -#: ../includes/ot-functions-docs-page.php:119 -msgid "Category Checkbox" -msgstr "Kategooriate valikkastid" - -#: ../includes/ot-functions-admin.php:2421 -#: ../includes/ot-functions-docs-page.php:122 -msgid "Category Select" -msgstr "Kategooria rippvalik" - -#: ../includes/ot-functions-admin.php:2422 -#: ../includes/ot-functions-docs-page.php:125 -msgid "Checkbox" -msgstr "Valikkastid" - -#: ../includes/ot-functions-admin.php:2423 -#: ../includes/ot-functions-docs-page.php:128 -msgid "Colorpicker" -msgstr "Värvivalik" - -#: ../includes/ot-functions-admin.php:2424 -#: ../includes/ot-functions-docs-page.php:131 -msgid "Colorpicker Opacity" -msgstr "Värvivalija läbipaistmatus" - -#: ../includes/ot-functions-admin.php:2425 -#: ../includes/ot-functions-docs-page.php:134 -msgid "CSS" -msgstr "CSS" - -#: ../includes/ot-functions-admin.php:2426 -#: ../includes/ot-functions-docs-page.php:153 -msgid "Custom Post Type Checkbox" -msgstr "Enda loodud postitüübi valikkastid" - -#: ../includes/ot-functions-admin.php:2427 -#: ../includes/ot-functions-docs-page.php:156 -msgid "Custom Post Type Select" -msgstr "Enda loodud postitüübi rippvalik" - -#: ../includes/ot-functions-admin.php:2428 -#: ../includes/ot-functions-docs-page.php:159 -msgid "Date Picker" -msgstr "Kuupäev valija" - -#: ../includes/ot-functions-admin.php:2429 -#: ../includes/ot-functions-docs-page.php:162 -msgid "Date Time Picker" -msgstr "Kuupäeva ja kellaaja valija" - -#: ../includes/ot-functions-admin.php:2430 -#: ../includes/ot-functions-docs-page.php:165 -msgid "Dimension" -msgstr "Mõõtmed" - -#: ../includes/ot-functions-admin.php:2431 -#: ../includes/ot-functions-admin.php:5466 -#: ../includes/ot-functions-docs-page.php:168 -msgid "Gallery" -msgstr "Galerii" - -#: ../includes/ot-functions-admin.php:2432 -#: ../includes/ot-functions-docs-page.php:171 -msgid "Google Fonts" -msgstr "Google Fondid" - -#: ../includes/ot-functions-admin.php:2433 -#: ../includes/ot-functions-docs-page.php:174 -msgid "JavaScript" -msgstr "JavaScript" - -#: ../includes/ot-functions-admin.php:2434 -#: ../includes/ot-functions-docs-page.php:177 -msgid "Link Color" -msgstr "Lingi värv" - -#: ../includes/ot-functions-admin.php:2435 -#: ../includes/ot-functions-docs-page.php:180 -msgid "List Item" -msgstr "Nimekirja element" - -#: ../includes/ot-functions-admin.php:2436 -#: ../includes/ot-functions-docs-page.php:183 -msgid "Measurement" -msgstr "Mõõt" - -#: ../includes/ot-functions-admin.php:2437 -#: ../includes/ot-functions-docs-page.php:214 -msgid "Numeric Slider" -msgstr "Numbriskaala" - -#: ../includes/ot-functions-admin.php:2438 -#: ../includes/ot-functions-docs-page.php:217 -msgid "On/Off" -msgstr "Sees/väljas" - -#: ../includes/ot-functions-admin.php:2439 -#: ../includes/ot-functions-docs-page.php:220 -msgid "Page Checkbox" -msgstr "Lehekülgede valikkastid" - -#: ../includes/ot-functions-admin.php:2440 -#: ../includes/ot-functions-docs-page.php:223 -msgid "Page Select" -msgstr "Lehekülje rippvalik" - -#: ../includes/ot-functions-admin.php:2441 -#: ../includes/ot-functions-docs-page.php:226 -msgid "Post Checkbox" -msgstr "Postituste valikkastid" - -#: ../includes/ot-functions-admin.php:2442 -#: ../includes/ot-functions-docs-page.php:229 -msgid "Post Select" -msgstr "Postituse rippvalik" - -#: ../includes/ot-functions-admin.php:2443 -#: ../includes/ot-functions-docs-page.php:232 -msgid "Radio" -msgstr "Raadiokastid" - -#: ../includes/ot-functions-admin.php:2444 -#: ../includes/ot-functions-docs-page.php:235 -msgid "Radio Image" -msgstr "Pildiga raadiokastid" - -#: ../includes/ot-functions-admin.php:2445 -#: ../includes/ot-functions-docs-page.php:262 -msgid "Select" -msgstr "Rippvalik" - -#: ../includes/ot-functions-admin.php:2446 -#: ../includes/ot-functions-docs-page.php:265 -msgid "Sidebar Select" -msgstr "Küljeriba rippvalik" - -#: ../includes/ot-functions-admin.php:2447 -#: ../includes/ot-functions-docs-page.php:269 -msgid "Slider" -msgstr "Slaidiesitaja" - -#: ../includes/ot-functions-admin.php:2448 -#: ../includes/ot-functions-docs-page.php:272 -msgid "Social Links" -msgstr "Sotsiaalmeedia" - -#: ../includes/ot-functions-admin.php:2449 -#: ../includes/ot-functions-docs-page.php:275 -msgid "Spacing" -msgstr "Vahed" - -#: ../includes/ot-functions-admin.php:2450 -#: ../includes/ot-functions-docs-page.php:278 -msgid "Tab" -msgstr "Sakk" - -#: ../includes/ot-functions-admin.php:2451 -#: ../includes/ot-functions-docs-page.php:281 -msgid "Tag Checkbox" -msgstr "Sildi valikkastid" - -#: ../includes/ot-functions-admin.php:2452 -#: ../includes/ot-functions-docs-page.php:284 -msgid "Tag Select" -msgstr "Sildi rippvalik" - -#: ../includes/ot-functions-admin.php:2453 -#: ../includes/ot-functions-docs-page.php:287 -msgid "Taxonomy Checkbox" -msgstr "Taksonoomia valikkastid" - -#: ../includes/ot-functions-admin.php:2454 -#: ../includes/ot-functions-docs-page.php:290 -msgid "Taxonomy Select" -msgstr "Taksonoomia rippvalik" - -#: ../includes/ot-functions-admin.php:2455 -#: ../includes/ot-functions-docs-page.php:293 -msgid "Text" -msgstr "Tekstisisend" - -#: ../includes/ot-functions-admin.php:2456 -#: ../includes/ot-functions-docs-page.php:296 -msgid "Textarea" -msgstr "Tekstiväli" - -#: ../includes/ot-functions-admin.php:2457 -#: ../includes/ot-functions-docs-page.php:355 -msgid "Textarea Simple" -msgstr "Lihtne tekstiväli" - -#: ../includes/ot-functions-admin.php:2458 -#: ../includes/ot-functions-docs-page.php:371 -msgid "Textblock" -msgstr "Tekstiblokk" - -#: ../includes/ot-functions-admin.php:2459 -#: ../includes/ot-functions-docs-page.php:374 -msgid "Textblock Titled" -msgstr "Pealkirjaga tekstiblokk" - -#: ../includes/ot-functions-admin.php:2460 -#: ../includes/ot-functions-docs-page.php:377 -msgid "Typography" -msgstr "Tüpograafia" - -#: ../includes/ot-functions-admin.php:2461 -#: ../includes/ot-functions-docs-page.php:397 -msgid "Upload" -msgstr "Lae üles" - -#: ../includes/ot-functions-admin.php:3196 -msgid "Left Sidebar" -msgstr "Vasak küljendusmenüü" - -#: ../includes/ot-functions-admin.php:3201 -msgid "Right Sidebar" -msgstr "Parem küljendusmenüü" - -#: ../includes/ot-functions-admin.php:3206 -msgid "Full Width (no sidebar)" -msgstr "Täies pikkuses (ilma küljendusmenüüta)" - -#: ../includes/ot-functions-admin.php:3211 -msgid "Dual Sidebar" -msgstr "Topelt küljendusmenüü" - -#: ../includes/ot-functions-admin.php:3216 -msgid "Left Dual Sidebar" -msgstr "Kaks küljendusmenüüd vasakul" - -#: ../includes/ot-functions-admin.php:3221 -msgid "Right Dual Sidebar" -msgstr "Kaks küljendusmenüüd paremal" - -#: ../includes/ot-functions-admin.php:3262 -#: ../includes/ot-functions-admin.php:3318 -#: ../includes/ot-functions-admin.php:5506 -msgid "Link" -msgstr "Viide" - -#: ../includes/ot-functions-admin.php:3273 -#: ../includes/ot-functions-admin.php:3324 -#: ../includes/ot-functions-docs-page.php:43 -#: ../includes/ot-functions-docs-page.php:428 -#: ../includes/ot-functions-docs-page.php:478 -msgid "Description" -msgstr "Kirjeldus" - -#: ../includes/ot-functions-admin.php:3388 -msgid "Name" -msgstr "Nimetus" - -#: ../includes/ot-functions-admin.php:3389 -msgid "Enter the name of the social website." -msgstr "Sisesta sotsiaalmeedia veebilehe nimi." - -#: ../includes/ot-functions-admin.php:3397 -msgid "Enter the text shown in the title attribute of the link." -msgstr "Sisesta tekst, mida näidatakse lingi pealkirja atribuudis." - -#: ../includes/ot-functions-admin.php:3403 -#, php-format -msgid "" -"Enter a link to the profile or page on the social website. Remember to add " -"the %s part to the front of the link." -msgstr "" -"Sisesta link profiilile või lehele sellel sotsiaalmeedia veebilehel. Ära " -"unusta lisada lingi ette %s osa." - -#: ../includes/ot-functions-admin.php:3756 -#, php-format -msgid "Unable to write to file %s." -msgstr "" - -#: ../includes/ot-functions-admin.php:4026 -msgid "edit" -msgstr "muuda" - -#: ../includes/ot-functions-admin.php:4027 -#: ../includes/ot-functions-admin.php:4095 -#: ../includes/ot-functions-admin.php:4096 -#: ../includes/ot-functions-admin.php:4258 -#: ../includes/ot-functions-admin.php:4259 -#: ../includes/ot-functions-admin.php:4324 -#: ../includes/ot-functions-admin.php:4325 -#: ../includes/ot-functions-admin.php:4452 -#: ../includes/ot-functions-admin.php:4453 -#: ../includes/ot-functions-admin.php:4605 -#: ../includes/ot-functions-admin.php:4606 -msgid "Edit" -msgstr "Muuda" - -#: ../includes/ot-functions-admin.php:4029 -#: ../includes/ot-functions-admin.php:4030 -#: ../includes/ot-functions-admin.php:4098 -#: ../includes/ot-functions-admin.php:4099 -#: ../includes/ot-functions-admin.php:4261 -#: ../includes/ot-functions-admin.php:4262 -#: ../includes/ot-functions-admin.php:4327 -#: ../includes/ot-functions-admin.php:4328 -#: ../includes/ot-functions-admin.php:4386 -#: ../includes/ot-functions-admin.php:4387 -#: ../includes/ot-functions-admin.php:4455 -#: ../includes/ot-functions-admin.php:4456 -#: ../includes/ot-functions-admin.php:4608 -#: ../includes/ot-functions-admin.php:4609 -msgid "Delete" -msgstr "Kustuta" - -#: ../includes/ot-functions-admin.php:4036 -msgid "" -"Section Title: Displayed as a menu item on the Theme " -"Options page." -msgstr "" -"Sektsiooni pealkiri: Näidatakse menüü elemendina teema " -"valikute lehel." - -#: ../includes/ot-functions-admin.php:4044 -msgid "" -"Section ID: A unique lower case alphanumeric string, " -"underscores allowed." -msgstr "" -"Sektsiooni ID: unikaalne väiketähtedega tähtnumbriline " -"string, alakriipsud lubatud." - -#: ../includes/ot-functions-admin.php:4105 -msgid "" -"Label: Displayed as the label of a form element on the " -"Theme Options page." -msgstr "" -"Nimetus: Näidatakse kui vormi elemendi nimetust teema " -"valikute lehel." - -#: ../includes/ot-functions-admin.php:4113 -#: ../includes/ot-functions-admin.php:4342 -msgid "" -"ID: A unique lower case alphanumeric string, underscores " -"allowed." -msgstr "" -"ID: unikaalne väiketähtedega tähtnumbriline string, " -"alakriipsud lubatud." - -#: ../includes/ot-functions-admin.php:4121 -msgid "" -"Type: Choose one of the available option types from the " -"dropdown." -msgstr "" -"Tüüp: vali rippmenüüst üks pakutavatest valiku tüüpidest." - -#: ../includes/ot-functions-admin.php:4132 -msgid "" -"Description: Enter a detailed description for the users to " -"read on the Theme Options page, HTML is allowed. This is also where you " -"enter content for both the Textblock & Textblock Titled option types." -msgstr "" -"Kirjeldus: sisesta detailne kirjeldus, mida kasutajad " -"saavad lugeda teema valikute lehel. HTML on lubatud. See on ühtlasi ka koht, " -"kuhu sisestada tekstibloki ja pealkirjaga tekstibloki valikutüüpide sisu." - -#: ../includes/ot-functions-admin.php:4140 -msgid "" -"Choices: This will only affect the following option types: " -"Checkbox, Radio, Select & Select Image." -msgstr "" -"Valikud: mõjutab vaid järgnevaid valikutüüpe: valikkastid, " -"raadiokastid, rippvalik ja pildi valik." - -#: ../includes/ot-functions-admin.php:4145 -msgid "Add Choice" -msgstr "Lisa valik" - -#: ../includes/ot-functions-admin.php:4151 -msgid "" -"Settings: This will only affect the List Item option type." -msgstr "Sätted: mõjutab vaid nimekirja elemendi valikutüüpi." - -#: ../includes/ot-functions-admin.php:4156 -#: ../includes/ot-functions-settings-page.php:93 -msgid "Add Setting" -msgstr "Lisa säte" - -#: ../includes/ot-functions-admin.php:4162 -msgid "" -"Standard: Setting the standard value for your option only " -"works for some option types. Read the OptionTree->Documentation " -"for more information on which ones." -msgstr "" -"Standard. standardväärtuse määramine mõjub vaid mõnele " -"valikutüübile. Lisainfot leiad OptionTree->Dokumentatsioon " -"lehelt." - -#: ../includes/ot-functions-admin.php:4170 -msgid "" -"Rows: Enter a numeric value for the number of rows in your " -"textarea. This will only affect the following option types: CSS, Textarea, & " -"Textarea Simple." -msgstr "" -"Ridu: sisesta numbriline väärtus, mis määrab ridade arvu " -"tekstiväljal. Mõjutab vaid järgnevaid valikutüüpe: CSS, tekstiväli ja lihtne " -"tekstiväli." - -#: ../includes/ot-functions-admin.php:4178 -msgid "" -"Post Type: Add a comma separated list of post type like " -"'post,page'. This will only affect the following option types: Custom Post " -"Type Checkbox, & Custom Post Type Select." -msgstr "" -"Postituse tüüp: lisa siia komaga eraldatud loend " -"postitüüpidest - näiteks 'post,page'. See mõjutab vaid järgnevaid " -"valikutüüpe: enda loodud postitüübi valikkastid ja enda loodud postitüübi " -"rippvalik." - -#: ../includes/ot-functions-admin.php:4186 -msgid "" -"Taxonomy: Add a comma separated list of any registered " -"taxonomy like 'category,post_tag'. This will only affect the following " -"option types: Taxonomy Checkbox, & Taxonomy Select." -msgstr "" -"Taksonoomia: lisa komaga eraldatud loend registreeritud " -"taksonoomiatest nagu 'category,post_tag'. See mõjutab vaid järgnevaid " -"valikutüüpe: taksonoomia valikukastid & taksonoomia rippvalik." - -#: ../includes/ot-functions-admin.php:4194 -msgid "" -"Min, Max, & Step: Add a comma separated list of options in " -"the following format 0,100,1 (slide from 0-100 in " -"intervals of 1). The three values represent the minimum, " -"maximum, and step options and will only affect the Numeric Slider option " -"type." -msgstr "" -"min, max & aste: lisa komaga eraldatud loend valikutest " -"järgnevas formaadis: 0,100,1 ( liugle vahemikus 0-100 intervalliga 1 ). Need kolm väärtust näitavad miinimumi, " -"maksimumi ja astme valikuid ning mõjutavad vaid numbriliuguri valikutüüpi." - -#: ../includes/ot-functions-admin.php:4202 -msgid "CSS Class: Add and optional class to this option type." -msgstr "" -"CSS klass: Soovi korral lisa sellele valikutüübile klass." - -#: ../includes/ot-functions-admin.php:4210 -#, php-format -msgid "" -"Condition: Add a comma separated list (no spaces) of " -"conditions in which the field will be visible, leave this setting empty to " -"always show the field. In these examples, value is a " -"placeholder for your condition, which can be in the form of %s." -msgstr "" -"Tingimus: lisa komaga eraldatud loend ( ilma tühikuteta ) " -"tingimustest, mille korral see väli on nähtav. Välja alati näitamiseks jäta " -"tühjaks. Nendes näidetes on value kohahoidja teie tingimustele, " -"mis võivad olla kujul %s." - -#: ../includes/ot-functions-admin.php:4218 -msgid "" -"Operator: Choose the logical operator to compute the result " -"of the conditions." -msgstr "" -"Operaator: vali loogiline operaator, millega arvutada välja " -"tingimuste tulemus." - -#: ../includes/ot-functions-admin.php:4221 -#: ../includes/ot-functions-docs-page.php:111 -#: ../includes/ot-functions-docs-page.php:378 -msgid "and" -msgstr "ja" - -#: ../includes/ot-functions-admin.php:4222 -msgid "or" -msgstr "või" - -#: ../includes/ot-functions-admin.php:4268 -#: ../includes/ot-functions-docs-page.php:29 -msgid "Label" -msgstr "Nimetus" - -#: ../includes/ot-functions-admin.php:4278 -msgid "Value" -msgstr "Väärtus" - -#: ../includes/ot-functions-admin.php:4288 -msgid "Image Source (Radio Image only)" -msgstr "Pildi allikas ( ainult pildiga raadiovaliku jaoks )" - -#: ../includes/ot-functions-admin.php:4334 -msgid "" -"Title: Displayed as a contextual help menu item on the " -"Theme Options page." -msgstr "" -"Pealkiri: kuvatakse kui kontekstipõhine abimenüü element " -"teema valikute lehel." - -#: ../includes/ot-functions-admin.php:4350 -msgid "" -"Content: Enter the HTML content about this contextual help " -"item displayed on the Theme Option page for end users to read." -msgstr "" -"Sisu: sisesta HTML sisu selle kontekstipõhise elemendi " -"kohta. Näidatakse teema valikute lehel lõppkasutajatele." - -#: ../includes/ot-functions-admin.php:4381 -msgid "Layout" -msgstr "Paigutus" - -#: ../includes/ot-functions-admin.php:4383 -#: ../includes/ot-functions-admin.php:4384 -msgid "Activate" -msgstr "Aktiveeri" - -#: ../includes/ot-functions-admin.php:4420 ../includes/ot-meta-box-api.php:231 -#: ../includes/ot-settings-api.php:610 -msgid "Title" -msgstr "Pealkiri" - -#: ../includes/ot-functions-admin.php:4760 -msgid "New Layout" -msgstr "Uus paigutus" - -#: ../includes/ot-functions-admin.php:5515 -msgid "Link URL" -msgstr "Viide" - -#: ../includes/ot-functions-admin.php:5522 -msgid "Link Title" -msgstr "Lingi pealkiri" - -#: ../includes/ot-functions-admin.php:5552 -msgid "Quote" -msgstr "Tsitaat" - -#: ../includes/ot-functions-admin.php:5561 -msgid "Source Name (ex. author, singer, actor)" -msgstr "Allika nimi (nt autor, laulja, näitleja)" - -#: ../includes/ot-functions-admin.php:5568 -msgid "Source URL" -msgstr "Allika URL" - -#: ../includes/ot-functions-admin.php:5575 -msgid "Source Title (ex. book, song, movie)" -msgstr "Allika pealkiri (nt raamat, laul, film)" - -#: ../includes/ot-functions-admin.php:5582 -msgid "Source Date" -msgstr "Allika kuupäev" - -#: ../includes/ot-functions-admin.php:5612 -msgid "Video" -msgstr "Video" - -#: ../includes/ot-functions-admin.php:5621 -#, php-format -msgid "" -"Embed video from services like Youtube, Vimeo, or Hulu. You can find a list " -"of supported oEmbed sites in the %1$s. Alternatively, you could use the " -"built-in %2$s shortcode." -msgstr "" -"Lisa video välisest allikast, nagu näiteks Youtube, Vimeo või Hulu. " -"Nimekirja toetatud oEmbed veebilehtedest leiad %1$s. Teine variant oleks " -"kasutada sisse ehitatud lühikoodi %2$s." - -#: ../includes/ot-functions-admin.php:5621 -#: ../includes/ot-functions-admin.php:5660 -msgid "Wordpress Codex" -msgstr "Wordpress Codex" - -#: ../includes/ot-functions-admin.php:5651 -msgid "Audio" -msgstr "Audio" - -#: ../includes/ot-functions-admin.php:5660 -#, php-format -msgid "" -"Embed audio from services like SoundCloud and Rdio. You can find a list of " -"supported oEmbed sites in the %1$s. Alternatively, you could use the built-" -"in %2$s shortcode." -msgstr "" -"Lisa heli teenustest SoundCloud, Rdio või teistest sarnastest. Nimekirja " -"toetatud oEmbed veebilehtedest leiad %1$s. Teine variant oleks kasutada " -"sisse ehitatud lühikoodi %2$s." - -#: ../includes/ot-functions-docs-page.php:30 -msgid "" -"The Label field should be a short but descriptive block of text 100 " -"characters or less with no HTML." -msgstr "" -"Nimetuse väli peaks olema lühike kuid kirjeldav tekstiblokk, mis on kuni 100 " -"tähemärki pikk ja ei sisalda HTML-i." - -#: ../includes/ot-functions-docs-page.php:32 -msgid "ID" -msgstr "ID" - -#: ../includes/ot-functions-docs-page.php:33 -msgid "" -"The ID field is a unique alphanumeric key used to differentiate each theme " -"option (underscores are acceptable). Also, the plugin will change all text " -"you write in this field to lowercase and replace spaces and special " -"characters with an underscore automatically." -msgstr "" -"ID väli on unikaalne tähtnumbriline võti eristamaks teema valikuid " -"( alakriipsud on lubatud ). Lisaks muudetakse kõik siia välja kirjutatav " -"tekst väiketähtedeks ning erimärgid asendatakse automaatselt alakriipsudega." - -#: ../includes/ot-functions-docs-page.php:35 -msgid "Type" -msgstr "Tüüp" - -#: ../includes/ot-functions-docs-page.php:36 -msgid "" -"You are required to choose one of the supported option types when creating a " -"new option. Here is a list of the available option types. For more " -"information about each type click the Option Types tab to the " -"left." -msgstr "" -"Uue valiku loomisel peate valima mõne toetatud valikutüüpidest. Siin on " -"nimekiri saadaolevatest valikutüüpidest. Lisainfo igaühe kohta neist on " -"saadaval vajutades vasakul olevat Valiku tüüp sakki." - -#: ../includes/ot-functions-docs-page.php:44 -msgid "" -"Enter a detailed description for the users to read on the Theme Options " -"page, HTML is allowed. This is also where you enter content for both the " -"Textblock & Textblock Titled option types." -msgstr "" -"Sisesta detailne kirjeldus, mida kasutajad saavad lugeda teema valikute " -"lehel. HTML on lubatud. See on ka koht sisu sisestamiseks tekstibloki ja " -"pealkirjaga tekstibloki valikutüüpide jaoks." - -#: ../includes/ot-functions-docs-page.php:46 -msgid "Choices" -msgstr "Valikud" - -#: ../includes/ot-functions-docs-page.php:47 -msgid "" -"Click the \"Add Choice\" button to add an item to the choices array. This " -"will only affect the following option types: Checkbox, Radio, Select & " -"Select Image." -msgstr "" -"Elemendi lisamiseks valikute massiivi vajuta \"Lisa valik\" nuppu. See " -"mõjutab järgnevaid valikutüüpe: valikkastid, raadiokastid, rippvalik ja " -"pildivalik." - -#: ../includes/ot-functions-docs-page.php:50 -msgid "" -"Click the \"Add Setting\" button found inside a newly created setting to add " -"an item to the settings array. This will only affect the List Item type." -msgstr "" -"Elemendi lisamiseks sätete massiivi vajuta vastloodud sättes asuvat \"Lisa " -"säte\" nuppu. See mõjutab vaid nimekirja elemendi tüüpi." - -#: ../includes/ot-functions-docs-page.php:52 -msgid "Standard" -msgstr "Standartne" - -#: ../includes/ot-functions-docs-page.php:53 -msgid "" -"Setting the standard value for your option only works for some option types. " -"Those types are one that have a single string value saved to them and not an " -"array of values." -msgstr "" -"Standard väärtuse määramine oma valikule töötab vaid mõnede valikutüüpidega. " -"Need tüübid on sellised, kus hoitakse vaid ühte väärtust stringi kujul, " -"mitte väärtuste massiivi." - -#: ../includes/ot-functions-docs-page.php:55 -msgid "Rows" -msgstr "Ridasid" - -#: ../includes/ot-functions-docs-page.php:56 -msgid "" -"Enter a numeric value for the number of rows in your textarea. This will " -"only affect the following option types: CSS, Textarea, & Textarea Simple." -msgstr "" -"Sisesta numbriline väärtus, mis määrab ridade arvu tekstialas. See mõjutab " -"vaid järgnevaid valikutüüpe: CSS, tekstiala & lihtne tekstiala." - -#: ../includes/ot-functions-docs-page.php:58 -msgid "Post Type" -msgstr "Postitüüp" - -#: ../includes/ot-functions-docs-page.php:59 -msgid "" -"Add a comma separated list of post type like post,page. This " -"will only affect the following option types: Custom Post Type Checkbox, & " -"Custom Post Type Select. Below are the default post types available with " -"WordPress and that are also compatible with OptionTree. You can also add " -"your own custom post_type. At this time any does " -"not seem to return results properly and is something I plan on looking into." -msgstr "" -"Lisa komaga eraldatud loetelu postitüüpidest, näiteks post,page. See mõjutab vaid järgnevaid valikutüüpe: kohandatud postitüübi " -"valikkastid ja kohandatud postitüübi rippmenüü. All on vaikimisi Wordpressis " -"saadaval postitüübid, mis on OptionTreega kokkusobivad. Saad kasutada ka " -"enda loodud post_type. Hetkel any ei tagasta " -"õigeid väärtusi." - -#: ../includes/ot-functions-docs-page.php:67 -msgid "Taxonomy" -msgstr "Taksonoomia" - -#: ../includes/ot-functions-docs-page.php:68 -msgid "" -"Add a comma separated list of any registered taxonomy like category," -"post_tag. This will only affect the following option types: Taxonomy " -"Checkbox, & Taxonomy Select." -msgstr "" -"Lisa komaga eraldatud loend registreeritud taksonoomiatest nagu 'category," -"post_tag'. See mõjutab vaid järgnevaid valikutüüpe: taksonoomia valikukastid " -"& taksonoomia rippvalik." - -#: ../includes/ot-functions-docs-page.php:70 -msgid "Min, Max, & Step" -msgstr "Miinimum, maksimum ning aste" - -#: ../includes/ot-functions-docs-page.php:71 -msgid "" -"Add a comma separated list of options in the following format 0,100,1 (slide from 0-100 in intervals of 1). The " -"three values represent the minimum, maximum, and step options and will only " -"affect the Numeric Slider option type." -msgstr "" -"Lisa komaga eraldatud loend valikutest järgnevas formaadis: 0,100,1 ( liugle vahemikus 0-100 intervalliga 1 ). " -"Need kolm väärtust näitavad miinimumi, maksimumi ja astme valikuid ning " -"mõjutavad vaid numbriliuguri valikutüüpi." - -#: ../includes/ot-functions-docs-page.php:73 -msgid "CSS Class" -msgstr "CSS klass" - -#: ../includes/ot-functions-docs-page.php:74 -msgid "Add and optional class to any option type." -msgstr "Soovi korral lisa klassi-atribuut ükskõik millisele valikutüübile." - -#: ../includes/ot-functions-docs-page.php:76 -msgid "Condition" -msgstr "Tingimus" - -#: ../includes/ot-functions-docs-page.php:77 -#, php-format -msgid "" -"Add a comma separated list (no spaces) of conditions in which the field will " -"be visible, leave this setting empty to always show the field. In these " -"examples, %s is a placeholder for your condition, which can be in the form " -"of %s." -msgstr "" -"Lisa komaga eraldatud loend ( ilma tühikuteta ) tingimustest, mille korral " -"see väli on nähtav. Tühjaks jättes on väli alati nähtav. Nendes näidetes on " -"%s tingimuse kohahoidjaks, mis tohib olla kujul %s." - -#: ../includes/ot-functions-docs-page.php:79 -msgid "Operator" -msgstr "Operaator" - -#: ../includes/ot-functions-docs-page.php:80 -#, php-format -msgid "" -"Choose the logical operator to compute the result of the conditions. Your " -"options are %s and %s." -msgstr "" -"Vali loogiline operaator, millega arvutada tingimuste tulemus. Sinu " -"valikuteks on %s ja %s." - -#: ../includes/ot-functions-docs-page.php:111 -#, php-format -msgid "" -"The Background option type is for adding background styles to your theme " -"either dynamically via the CSS option type below or manually with %s. The " -"Background option type has filters that allow you to remove fields or change " -"the defaults. For example, you can filter %s to remove unwanted fields from " -"all Background options or an individual one. You can also filter %s. These " -"filters allow you to fine tune the select lists for your specific needs." -msgstr "" -"Tausta valikutüüpi kasutatakse teemasse tausta stiilide lisamiseks " -"dünaamiliselt alloleva CSS valikutüübiga või käsitsi kasutades %s. Tausta " -"valikutüübil on filtrid, mis võimaldavad eemaldada välju või muuta " -"vaikeväärtusi. Näiteks saab filtreerida %s eemaldamaks soovimatuid välju " -"kõikidelt tausta valikutelt või ainult ühelt neist. Saab filtreerida ka %s. " -"Need filtrid võimaldavad sul sättida valikute nimekirja täpselt oma " -"vajadustele vastavaks." - -#: ../includes/ot-functions-docs-page.php:114 -#, php-format -msgid "" -"The Border option type is used to set width, unit, style, and color values. " -"The text input excepts a numerical value and the unit select lets you choose " -"the unit of measurement to add to that value. Currently the default units " -"are %s, %s, %s, and %s. However, you can change them with the %s filter. The " -"style select lets you choose the border style. The default styles are %s, " -"%s, %s, %s, %s, %s, %s, and %s. However, you can change them with the %s " -"filter. The colorpicker saves a hexadecimal color code." -msgstr "" -"Äärise valikutüüp kasutatakse laiuse, ühiku, stiili ja värvi määramiseks. " -"Tekstisisendisse saab kirjutada numbrilise väärtuse ning rippmenüü laseb " -"valida talle mõõtühiku. Hetkel on vaikimisi ühikuteks %s, %s, %s ja %s. Neid " -"saab muuta %s filtriga. Stiili rippmenüü laseb valida äärise stiili. " -"Vaikimisi stiilid on %s, %s, %s, %s, %s, %s, %s ja %s. Neid saab muuta %s " -"filtriga. Värvivalija salvestab värvikoodi kuueteistkümnendiksüsteemis." - -#: ../includes/ot-functions-docs-page.php:117 -#, php-format -msgid "" -"The Box Shadow option type is used to set %s, %s, %s, %s, %s, and %s values." -msgstr "" -"Kasti varju valikutüüpi kasutatakse %s, %s, %s, %s, %s ja %s väärtuse " -"määramiseks." - -#: ../includes/ot-functions-docs-page.php:120 -msgid "" -"The Category Checkbox option type displays a list of category IDs. It allows " -"the user to check multiple category IDs and will return that value as an " -"array for use in a custom function or loop." -msgstr "" -"Kategooria valikkastide valikutüüp näitab loendit kategooriate ID-dest. See " -"laseb kasutajal märkida mitu kategooria ID-d ja tagastab selle väärtuse " -"massiivina, enda funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:123 -msgid "" -"The Category Select option type displays a list of category IDs. It allows " -"the user to select only one category ID and will return that value for use " -"in a custom function or loop." -msgstr "" -"Kategooria rippvaliku valikutüüp näitab loendit kategooriate ID-dest. See " -"laseb kasutajal märkida üks kategooria ID ja tagastab selle väärtuse enda " -"funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:126 -msgid "" -"The Checkbox option type displays a group of choices. It allows the user to " -"check multiple choices and will return that value as an array for use in a " -"custom function or loop." -msgstr "" -"Valikkastide valikutüüp kuvab valikute grupi. See laseb kasutajal märkida " -"mitu valikut ning tagastab selle väärtuse massiivina enda funktsioonis või " -"tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:129 -msgid "" -"The Colorpicker option type saves a hexadecimal color code for use in CSS. " -"Use it to modify the color of something in your theme." -msgstr "" -"Värvi valija valikutüüp salvestab värvikoodi kuueteistkümnendiksüsteemis, " -"mida saab kasutada CSS-is. Kasuta seda millegi värvi muutmiseks enda teemas." - -#: ../includes/ot-functions-docs-page.php:132 -#, php-format -msgid "" -"The Colorpicker Opacity option type saves a hexadecimal color code with an " -"opacity value from %s to %s in increments of %s. Though the value is saved " -"as hexadecimal, if used within the CSS option type the color and opacity " -"values will be converted into a valid RGBA CSS value." -msgstr "" -"Värvivalija läbipaistmatuse valikutüüp salvestab värvikoodi " -"kuueteistkümnendiksüsteemis läbipaistmatuse väärtusega %s kuni %s sammuga " -"%s. Kuigi väärtus salvestatakse kuueteistkümnendiksüsteemis, kasutades teda " -"koos CSS valikutüübiga teisendatakse ja korrektseks RGBA CSS väärtuseks." - -#: ../includes/ot-functions-docs-page.php:135 -#, php-format -msgid "" -"The CSS option type is a textarea that when used properly can add dynamic " -"CSS to your theme from within OptionTree. Unfortunately, due server " -"limitations you will need to create a file named %s at the root level of " -"your theme and change permissions using %s so the server can write to the " -"file. I have had the most success setting this single file to %s but feel " -"free to play around with permissions until everything is working. A good " -"starting point is %s. When the server can save to the file, CSS will " -"automatically be updated when you save your Theme Options." -msgstr "" -"CSS valikutüüp on tekstiväli, mille õigel kasutamisel saab teemale lisada " -"dünaamiliselt genereeritud CSS-i OptionTree kaudu. Serveri piirangute tõttu " -"peate selleks looma teema juurkausta faili nimega %s ning muutma õiguseid " -"kasutades %s, et server saaks faili kirjutada. Mul on tulnud parimad " -"tulemused siis, kui muutsin selle ainsa faili õiguste väärtuseks %s, kuid " -"katsetage teisi variante, kuni kõik toimib nagu vaja. Hea alguspunkt on %s. " -"Kui server saab edukalt faili salvestada. siis uuendatakse CSS automaatselt " -"teema salvestamisel." - -#: ../includes/ot-functions-docs-page.php:137 -#, php-format -msgid "" -"This example assumes you have an option with the ID of %1$s. Which means " -"this option will automatically insert the value of %1$s into the %2$s when " -"the Theme Options are saved." -msgstr "" -"See näide eeldab, et sul on valik ID-ga %1$s. See tähendab, et teema " -"valikute salvestamisel sisestatakse %1$s väärtus automaatselt %2$s külge." - -#: ../includes/ot-functions-docs-page.php:139 -msgid "Input" -msgstr "Sisend" - -#: ../includes/ot-functions-docs-page.php:145 -msgid "Output" -msgstr "Väljund" - -#: ../includes/ot-functions-docs-page.php:154 -#, php-format -msgid "" -"The Custom Post Type Select option type displays a list of IDs from any " -"available WordPress post type or custom post type. It allows the user to " -"check multiple post IDs for use in a custom function or loop. Requires at " -"least one valid %1$s in the %1$s field." -msgstr "" -"Enda loodud postitüübi rippvaliku valikutüüp kuvab nimekirja kõikidest " -"WordPressi postitüüpide või enda loodud postitüüpide ID-dest. See võimaldab " -"kasutajal märgistada mitu postituse ID-d, mida kasutada enda funktsioonis " -"või tsüklis. Vajab vähemalt ühte sobivat %1$s väljal %1$s." - -#: ../includes/ot-functions-docs-page.php:157 -#, php-format -msgid "" -"The Custom Post Type Select option type displays a list of IDs from any " -"available WordPress post type or custom post type. It will return a single " -"post ID for use in a custom function or loop. Requires at least one valid " -"%1$s in the %1$s field." -msgstr "" -"Enda loodud postitüübi rippvaliku valikutüüp kuvab nimekirja kõikidest " -"WordPressi postitüüpide või enda loodud postitüüpide ID-dest. See tagastab " -"ühe postituse ID, mida kasutada enda funktsioonis või tsüklis. Vajab " -"vähemalt ühte sobivat %1$s väljal %1$s." - -#: ../includes/ot-functions-docs-page.php:160 -msgid "" -"The Date Picker option type is tied to a standard form input field which " -"displays a calendar pop-up that allow the user to pick any date when focus " -"is given to the input field. The returned value is a date formatted string." -msgstr "" -"Kuupäeva valiku valikutüüp on seotud standartse vormi sisendväljaga. Kui " -"sellele antakse fookus, siis kuvatakse kalendri aken, mis laseb kasutajal " -"valida suvalise kuupäeva. Tagastatav väärtus on kuupäeva formaadis string." - -#: ../includes/ot-functions-docs-page.php:163 -msgid "" -"The Date Time Picker option type is tied to a standard form input field " -"which displays a calendar pop-up that allow the user to pick any date and " -"time when focus is given to the input field. The returned value is a date " -"and time formatted string." -msgstr "" -"Kuupäeva ja aja valiku valikutüüp on seotud standartse vormi sisendväljaga. " -"Kui sellele antakse fookus, siis kuvatakse kalendri aken, mis laseb " -"kasutajal valida suvalise kuupäeva ja kellaaja. Tagastatav väärtus on " -"kuupäeva ja kellaaja formaadis string." - -#: ../includes/ot-functions-docs-page.php:166 -#, php-format -msgid "" -"The Dimension option type is used to set width and height values. The text " -"inputs except numerical values and the select lets you choose the unit of " -"measurement to add to that value. Currently the default units are %s, %s, " -"%s, and %s. However, you can change them with the %s filter." -msgstr "" -"Mõõtme valikutüüpi kasutatakse laiuse ja kõrguse väärtuste jaoks. " -"Tekstisisendisse saab kirjutada numbrilise väärtuse ning rippmenüü laseb " -"valida talle mõõtühiku. Hetkel on vaikimisi ühikuteks %s, %s, %s ja %s. Neid " -"saab muuta %s filtriga." - -#: ../includes/ot-functions-docs-page.php:169 -msgid "" -"The Gallery option type saves a comma separated list of image attachment " -"IDs. You will need to create a front-end function to display the images in " -"your theme." -msgstr "" -"Galerii valikutüüp salvestab komaga eraldatud loendi pildi tüüpi manuste ID-" -"dest. Nende piltide teemas näitamiseks tuleb luua kuvatava lehe jaoks " -"funktsioon." - -#: ../includes/ot-functions-docs-page.php:172 -#, php-format -msgid "" -"The Google Fonts option type will dynamically enqueue any number of Google " -"Web Fonts into the document %1$s. As well, once the option has been saved " -"each font family will automatically be inserted into the %2$s array for the " -"Typography option type. You can further modify the font stack by using the " -"%3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s " -"parameter is being passed from %7$s, so it will be the ID of a Typography " -"option type. This will allow you to add additional web safe fonts to " -"individual font families on an as-need basis." -msgstr "" -"Google Fontide valikutüüp kaasab dokumendi %1$s dünaamiliselt soovitud hulga " -"Google veebifonte. Lisaks salvestub iga valitud fondi perekond automaatselt " -"%2$s massiivi tüpograafia valikutüübis. Fondi salve saab veel rohkem " -"modifitseerida %3$s filtriga, mis saab kaasa %4$s, %5$s ja %6$s parameetrid. " -"%6$s parameeter antakse %7$s, nii et ta on tüpograafia valikutüübi ID. See " -"võimaldab lisada veebis kasutamiseks sobilikke fonte erinevatele fondi " -"perekondadele vastavalt vajadusele." - -#: ../includes/ot-functions-docs-page.php:175 -#, php-format -msgid "" -"The JavaScript option type is a textarea that uses the %s code editor to " -"highlight your JavaScript and display errors as you type." -msgstr "" -"JavaScript valikutüüp on tekstiväli, mis kasutab %s koodi redaktorit sinu " -"kirjutatava JavaScripti süntaksi esile toomiseks ning vigade näitamiseks " -"kirjutamise ajal." - -#: ../includes/ot-functions-docs-page.php:178 -msgid "The Link Color option type is used to set all link color states." -msgstr "" -"Lingi värvi valikutüüpi kasutatakse kõikide linkide värviolekute määramiseks." - -#: ../includes/ot-functions-docs-page.php:181 -msgid "" -"The List Item option type replaced the Slider option type and allows for a " -"great deal of customization. You can add settings to the List Item and those " -"settings will be displayed to the user when they add a new List Item. " -"Typical use is for creating sliding content or blocks of code for custom " -"layouts." -msgstr "" -"Nimekirja valikutüüp vahetas välja slaidiesitaja valikutüübi ning võimaldab " -"põhjalikku kohandamist. Nimekirja elementidele saab lisada sätteid, mida " -"näidatakse kasutajale uue elemendi lisamisel. Tüüpiline kasutusjuht on " -"liugleva sisu või koodiblokkide loomiseks." - -#: ../includes/ot-functions-docs-page.php:184 -#, php-format -msgid "" -"The Measurement option type is a mix of input and select fields. The text " -"input excepts a value and the select lets you choose the unit of measurement " -"to add to that value. Currently the default units are %s, %s, %s, and %s. " -"However, you can change them with the %s filter." -msgstr "" -"Mõõdu valikutüüp on segu sisendväljast ja valikuväljast. Tekstisisend eeldab " -"väärtust ning rippvalik laseb valida mõõduühiku sellele väärtusele. Hetkel " -"on vaikimisi ühikuteks %s, %s, %s ja %s. Neid saab muuta %s filtriga." - -#: ../includes/ot-functions-docs-page.php:186 -#, php-format -msgid "" -"Example filter to add new units to the Measurement option type. Added to %s." -msgstr "Näidisfilter mõõdu valikutüüpi ühikute lisamiseks. Lisatakse %s faili." - -#: ../includes/ot-functions-docs-page.php:199 -msgid "" -"Example filter to completely change the units in the Measurement option " -"type. Added to functions.php." -msgstr "" -"Näidisfilter, mis muudab mõõdu valikutüübi ühikud täiesti teistsugusteks. " -"Lisatakse functions.php faili." - -#: ../includes/ot-functions-docs-page.php:215 -msgid "" -"The Numeric Slider option type displays a jQuery UI slider. It will return a " -"single numerical value for use in a custom function or loop." -msgstr "" -"Numbriliuguri valikutüüp kuvab jQuery UI liuguri. See tagastab ühe " -"numbrilise väärtuse enda funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:218 -#, php-format -msgid "" -"The On/Off option type displays a simple switch that can be used to turn " -"things on or off. The saved return value is either %s or %s." -msgstr "" -"Sees/väljas valikutüüp kuvab lihtsa lüliti, millega saab asju sisse või " -"välja lülitada. Salvestatud väärtus on kas %s või %s." - -#: ../includes/ot-functions-docs-page.php:221 -msgid "" -"The Page Checkbox option type displays a list of page IDs. It allows the " -"user to check multiple page IDs for use in a custom function or loop." -msgstr "" -"Lehe valikkastide valikutüüp kuvab nimekirja kõikidest lehtede ID-dest. See " -"võimaldab kasutajal märgistada mitu lehe ID-d, mida kasutada enda " -"funktsioonis või tsüklis." - -#: ../includes/ot-functions-docs-page.php:224 -msgid "" -"The Page Select option type displays a list of page IDs. It will return a " -"single page ID for use in a custom function or loop." -msgstr "" -"Lehe rippvaliku valikutüüp kuvab nimekirja kõikidest lehtede ID-dest. See " -"tagastab ühe lehe ID, mida kasutada enda funktsioonis või tsüklis." - -#: ../includes/ot-functions-docs-page.php:227 -msgid "" -"The Post Checkbox option type displays a list of post IDs. It allows the " -"user to check multiple post IDs for use in a custom function or loop." -msgstr "" -"Postituse valikkastid valikutüüp kuvab nimekirja kõikidest postituste ID-" -"dest. See võimaldab kasutajal märgistada mitu postituse ID-d, mida kasutada " -"enda funktsioonis või tsüklis." - -#: ../includes/ot-functions-docs-page.php:230 -msgid "" -"The Post Select option type displays a list of post IDs. It will return a " -"single post ID for use in a custom function or loop." -msgstr "" -"Postituse rippvaliku valikutüüp kuvab nimekirja kõikidest postituste ID-" -"dest. See tagastab ühe postituse ID, mida kasutada enda funktsioonis või " -"tsüklis." - -#: ../includes/ot-functions-docs-page.php:233 -msgid "" -"The Radio option type displays a group of choices. It allows the user to " -"choose one and will return that value as a string for use in a custom " -"function or loop." -msgstr "" -"Raadiovaliku valikutüüp näitab valikute gruppi. See laseb kasutajal valida " -"neist ühe ning tagastab selle väärtuse string-ina enda funktsioonis või " -"tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:236 -#, php-format -msgid "" -"the Radio Images option type is primarily used for layouts. However, you can " -"filter the image list using %s. As well, you can add your own custom images " -"using the choices array." -msgstr "" -"Piltidega raadiovaliku valikutüüpi kasutatakse peamiselt paigutuste jaoks. " -"Piltide loendit saab filtreerida %s abil. Valikute massiivi saab lisada enda " -"pilte." - -#: ../includes/ot-functions-docs-page.php:238 -msgid "" -"This example executes the ot_radio_images filter on layout " -"images attached to the my_radio_images field. Added to " -"functions.php." -msgstr "" -"See näide käivitab ot_radio_images filtri " -"my_radio_images väljale lisatud paigutuse piltidel. Lisatakse " -"functions.php faili." - -#: ../includes/ot-functions-docs-page.php:263 -msgid "" -"The Select option type is used to list anything you want that would be " -"chosen from a select list." -msgstr "" -"Rippvaliku valikutüüpi saab kasutada ükskõik mille loendamiseks, mida saab " -"valida rippmenüüst." - -#: ../includes/ot-functions-docs-page.php:266 -#, php-format -msgid "" -"This option type makes it possible for users to select a WordPress " -"registered sidebar to use on a specific area. By using the two provided " -"filters, %s, and %s we can be selective about which sidebars are available " -"on a specific content area." -msgstr "" -"See valikutüüp võimaldab kasutajatel valida WordPressis registreeritud " -"küljeriba, kasutamaks seda kindlas kohas. Kahe kaasa antud filtri, %s ja %s " -"abil saab määrata, millist küljeriba millises sisuosas näidata." - -#: ../includes/ot-functions-docs-page.php:267 -#, php-format -msgid "" -"For example, if we create a WordPress theme that provides the ability to " -"change the Blog Sidebar and we don't want to have the footer sidebars " -"available on this area, we can unset those sidebars either manually or by " -"using a regular expression if we have a common name like %s." -msgstr "" -"Näiteks kui luua WordPressi teema, mis võimaldab muuta blogi küljeriba ning " -"me ei soovi siin alas näha jaluse küljeribasid, siis saame need küljeribad " -"ära võtta kas käsitsi või kasutades regulaaravaldist, nagu näiteks %s." - -#: ../includes/ot-functions-docs-page.php:270 -msgid "" -"The Slider option type is technically deprecated. Use the List Item option " -"type instead, as it's infinitely more customizable. Typical use is for " -"creating sliding image content." -msgstr "" -"Tehniliselt on slaidiesitaja valikutüübi kasutamine taunitud. Kasutage parem " -"nimekirja elemendi valikutüüpi, kuna see on lõpmatult kohandatav. Tüüpiline " -"kasutusjuht on libisevate piltidega sisu jaoks." - -#: ../includes/ot-functions-docs-page.php:273 -#, php-format -msgid "" -"The Social Links option type utilizes a drag & drop interface to create a " -"list of social links. There are a few filters that make extending this " -"option type easy. You can set the %s filter to %s and turn off loading " -"default values. Use the %s filter to change the default values that are " -"loaded. To filter the settings array use the %s filter." -msgstr "" -"Sotsiaalmeedia linkide valikutüübis kasutatakse nimekirja loomiseks tiri-ja-" -"pilla liidest. On loodud mõned filtrid, mis teevad selle valikutüübi " -"täiendamise kergeks. Filter %s väärtuseks saab määrata %s, et lülitada välja " -"vaikimisi väärtuste laadimine. %s filtriga saab muuta vaikeväärtuseid. " -"Sätete massiivi filtreerimiseks on %s." - -#: ../includes/ot-functions-docs-page.php:276 -#, php-format -msgid "" -"The Spacing option type is used to set spacing values such as padding or " -"margin in the form of top, right, bottom, and left. The text inputs except " -"numerical values and the select lets you choose the unit of measurement to " -"add to that value. Currently the default units are %s, %s, %s, and %s. " -"However, you can change them with the %s filter." -msgstr "" -"Vahede valikutüüpi kasutatakse \"padding\" ja \"margin\" väärtuste jaoks " -"kujul \"top\", \"right\", \"bottom\", \"left\". Tekstisisendisse saab " -"kirjutada numbrilise väärtuse ning rippmenüü laseb valida talle mõõtühiku. " -"Hetkel on vaikimisi ühikuteks %s, %s, %s ja %s. Neid saab muuta %s filtriga." - -#: ../includes/ot-functions-docs-page.php:279 -msgid "" -"The Tab option type will break a section or metabox into tabbed content." -msgstr "" -"Saki valikutüüp muudab sektsiooni või meta-kasti sakkidega sisuelemendiks." - -#: ../includes/ot-functions-docs-page.php:282 -msgid "" -"The Tag Checkbox option type displays a list of tag IDs. It allows the user " -"to check multiple tag IDs and will return that value as an array for use in " -"a custom function or loop." -msgstr "" -"Sildi valikukasti valikutüüp kuvab loendi siltide ID-dega. See laseb " -"kasutajal märkida mitu sildi ID-d ning tagastab selle väärtuse massiivina " -"enda funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:285 -msgid "" -"The Tag Select option type displays a list of tag IDs. It allows the user to " -"select only one tag ID and will return that value for use in a custom " -"function or loop." -msgstr "" -"Sildi rippvaliku valikutüüp kuvab loendi siltide ID-dega. See laseb " -"kasutajal märkida ainult ühe sildi ID ning tagastab selle väärtuse enda " -"funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:288 -msgid "" -"The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows " -"the user to check multiple taxonomy IDs and will return that value as an " -"array for use in a custom function or loop." -msgstr "" -"Taksonoomia valikukasti valikutüüp kuvab loendi taksonoomiate ID-dega. See " -"laseb kasutajal märkida mitu taksonoomia ID-d ning tagastab selle väärtuse " -"massiivina enda funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:291 -msgid "" -"The Taxonomy Select option type displays a list of taxonomy IDs. It allows " -"the user to select only one taxonomy ID and will return that value for use " -"in a custom function or loop." -msgstr "" -"Taksonoomia rippvaliku valikutüüp kuvab loendi taksonoomiate ID-dega. See " -"laseb kasutajal märkida ainult ühe taksonoomia ID ning tagastab selle " -"väärtuse enda funktsioonis või tsüklis kasutamiseks." - -#: ../includes/ot-functions-docs-page.php:294 -msgid "" -"The Text option type is used to save string values. For example, any " -"optional or required text that is of reasonably short character length." -msgstr "" -"Teksti valikutüüpi kasutatakse väärtuste salvestamiseks stringi kujul. " -"Näiteks mõni valikuline või nõutud tekst, mis on piisavalt lühike." - -#: ../includes/ot-functions-docs-page.php:297 -#, php-format -msgid "" -"The Textarea option type is a large string value used for custom code or " -"text in the theme and has a WYSIWYG editor that can be filtered to change " -"the how it is displayed. For example, you can filter %s, %s, %s, and %s." -msgstr "" -"Tekstivälja valikutüüp on suur väärtus stringi kujul salvestamiseks, millel " -"on WYSIWYG toimetaja, mida saab filtreerida muutmaks tema kuvamist. Näiteks " -"saab filtreerida %s, %s, %s ja %s." - -#: ../includes/ot-functions-docs-page.php:299 -msgid "" -"Example filters to alter the Textarea option type. Added to functions." -"php." -msgstr "" -"Näidisfiltrid, millega muuta tekstivälja valikutüüpi. Lisatakse " -"functions.php faili." - -#: ../includes/ot-functions-docs-page.php:301 -msgid "" -"This example keeps WordPress from executing the wpautop filter " -"on the line breaks. The default is true which means it wraps " -"line breaks with an HTML p tag." -msgstr "" -"See näide takistab Wordpressil kasutada wpautop filtrit " -"reavahetustel. Vaikeväärtus on true, mis tähendab, et " -"reavahtused mähitakse HTML p elemendiga." - -#: ../includes/ot-functions-docs-page.php:314 -msgid "" -"This example keeps WordPress from executing the media_buttons " -"filter on the textarea WYSIWYG. The default is true which means " -"show the buttons." -msgstr "" -"See näide takistab Wordpressil kasutada media_buttons filtrit " -"tekstivälja WYSIWYG toimetajas. Vaikeväärtus on true, mis " -"tähendab, et nuppe näidatakse." - -#: ../includes/ot-functions-docs-page.php:327 -msgid "" -"This example keeps WordPress from executing the tinymce filter " -"on the textarea WYSIWYG. The default is true which means show " -"the tinymce." -msgstr "" -"See näide takistab Wordpressil kasutada tinymce filtrit " -"tekstivälja WYSIWYG toimetajas. Vaikeväärtus on true, mis " -"tähendab, et tinymce on nähtaval." - -#: ../includes/ot-functions-docs-page.php:340 -msgid "" -"This example alters the quicktags filter on the textarea " -"WYSIWYG. The default is array( 'buttons' => 'strong,em,link,block,del," -"ins,img,ul,ol,li,code,spell,close' ) which means show those " -"quicktags. It also means you can filter in your own custom quicktags." -msgstr "" -"See näide muudab quicktags filtrit tekstivälja WYSIWYG " -"toimetajas. Vaikeväärtus on array('buttons' => 'strong,em,link,block," -"del,ins,img,ul,ol,li,code,spell,close'), mis tähendab, et neid " -"elemente näidatakse. Siitkaudu saad kaasata endale sobivaid elemente." - -#: ../includes/ot-functions-docs-page.php:356 -msgid "" -"The Textarea Simple option type is a large string value used for custom code " -"or text in the theme. The Textarea Simple does not have a WYSIWYG editor." -msgstr "" -"Lihtsa tekstivälja valikutüüp on suur string-tüüpi väärtus teemas oleva " -"kohandatud koodi või teksti jaoks. Lihtsal tekstiväljal ei ole WYSIWYG " -"toimetajat." - -#: ../includes/ot-functions-docs-page.php:358 -#, php-format -msgid "" -"This example tells WordPress to execute the %s filter on the line breaks. " -"The default is %s which means it does not wraps line breaks with an HTML %s " -"tag. Added to %s." -msgstr "" -"See näide ütleb Wordpressile, et reavahetuste korral kasutada %s filtrit. " -"Vaikeväärtus on %s, mis tähendab, et reavahetusi ei mähita HTML %s " -"elemendiga. Lisatakse %s faili." - -#: ../includes/ot-functions-docs-page.php:372 -msgid "" -"The Textblock option type is used only on the Theme Option page. It will " -"allow you to create & display HTML, but has no title above the text block. " -"You can then use the Textblock to add a more detailed set of instruction on " -"how the options are used in your theme. You would never use this in your " -"themes template files as it does not save a value." -msgstr "" -"Tekstibloki valikutüüpi kasutatakse teema valikute lehel. See võimaldab luua " -"ja kuvada HTML-i, kuid tal puudub pealkiri. Sellega saab lisada detailsemaid " -"kirjeldusi teemas kasutatavate valikute jaoks. Seda ei kasutata teema " -"mallifailides, kuna ta ei salvesta mingit väärtust." - -#: ../includes/ot-functions-docs-page.php:375 -msgid "" -"The Textblock Titled option type is used only on the Theme Option page. It " -"will allow you to create & display HTML, and has a title above the text " -"block. You can then use the Textblock Titled to add a more detailed set of " -"instruction on how the options are used in your theme. You would never use " -"this in your themes template files as it does not save a value." -msgstr "" -"Pealkirjaga tekstibloki valikutüüpi kasutatakse teema valikute lehel. See " -"võimaldab luua ja kuvada HTML-i ning tema kohal on pealkiri. Sellega saab " -"lisada detailsemaid kirjeldusi teemas kasutatavate valikute jaoks. Seda ei " -"kasutata teema mallifailides, kuna ta ei salvesta mingit väärtust." - -#: ../includes/ot-functions-docs-page.php:378 -#, php-format -msgid "" -"The Typography option type is for adding typography styles to your theme " -"either dynamically via the CSS option type above or manually with %s. The " -"Typography option type has filters that allow you to remove fields or change " -"the defaults. For example, you can filter %s to remove unwanted fields from " -"all Background options or an individual one. You can also filter %s. These " -"filters allow you to fine tune the select lists for your specific needs." -msgstr "" -"Tüpograafia valikutüübiga saab teemale lisada stiile, kas dünaamiliselt ülal " -"oleva CSS valikutüübiga või käsitsi %s abil. Tüpograafia valikutüübil on " -"filtrid, mis lasevad välju eemaldada või vaikimisi välju muuta. Näiteks saab " -"filtreerida %s, eemaldamaks soovimatuid välju kõikidelt tausta valikutelt " -"või mõnelt neist. Saab filtreerida ka %s. Need filtrid aitavad valikute " -"nimekirja täpselt oma vajaduste järgi häälestada." - -#: ../includes/ot-functions-docs-page.php:380 -msgid "" -"This example would filter ot_recognized_font_families to build " -"your own font stack. Added to functions.php." -msgstr "" -"See näide filtreerib ot_recognized_font_families loomaks enda " -"fondipinu. Lisatakse functions.php faili." - -#: ../includes/ot-functions-docs-page.php:398 -#, php-format -msgid "" -"The Upload option type is used to upload any WordPress supported media. " -"After uploading, users are required to press the \"%s\" button in order to " -"populate the input with the URI of that media. There is one caveat of this " -"feature. If you import the theme options and have uploaded media on one site " -"the old URI will not reflect the URI of your new site. You will have to re-" -"upload or %s any media to your new server and change the URIs if necessary." -msgstr "" -"Üleslaadimise valikutüüp kasutatakse suvalise Wordpressi toetatava meedia " -"üles laadimiseks. Peale üleslaadimist peab kasutaja vajutama \"%s\" nuppu, " -"et täita sisend selle meediaelemendi URI-ga. Selle omadusega kaasneb üks " -"probleem - kui importida teema valikuid teistsuguse aadressiga veebilehelt, " -"siis URI-d automaatselt ei uuene. Meediafailid tuleb kas uuesti üles laadida " -"või %s, vajadusel muutes URI-sid." - -#: ../includes/ot-functions-docs-page.php:430 -msgid "" -"This function returns a value from the \"option_tree\" array of saved values " -"or the default value supplied. The returned value would be mixed. Meaning it " -"could be a string, integer, boolean, or array." -msgstr "" -"See funktsioon tagastab või vajadusel trükib väärtuse \"option_tree\" " -"massiivi salvestatud väärtustest või kaasaantud vaikeväärtuse. Tagastatud " -"väärtus tüüp on segunenud. See tähendab, et ta võib olla string, integer, " -"boolean või massiiv." - -#: ../includes/ot-functions-docs-page.php:432 -#: ../includes/ot-functions-docs-page.php:482 -msgid "Usage" -msgstr "Kasutus" - -#: ../includes/ot-functions-docs-page.php:436 -#: ../includes/ot-functions-docs-page.php:486 -msgid "Parameters" -msgstr "Parameetrid" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:490 -msgid "string" -msgstr "string" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:490 -msgid "required" -msgstr "nõutud" - -#: ../includes/ot-functions-docs-page.php:440 -msgid "Enter the options unique identifier." -msgstr "Sisesta valikule unikaalne identifikaator." - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:490 -msgid "Default:" -msgstr "Vaikimisi:" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:490 -#: ../includes/ot-functions-docs-page.php:494 -msgid "None" -msgstr "Puudub" - -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:494 -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -#: ../includes/ot-functions-docs-page.php:506 -msgid "optional" -msgstr "valikuline" - -#: ../includes/ot-functions-docs-page.php:444 -msgid "" -"Enter a default return value. This is just incase the request returns null." -msgstr "Sisesta vaikeväärtus. See on vajalik juhul, kui päring tagastab nulli." - -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:494 -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -#: ../includes/ot-functions-docs-page.php:506 -msgid "Default" -msgstr "Vaikimisi" - -#: ../includes/ot-functions-docs-page.php:474 -msgid "" -"This function has been deprecated. That means it has been replaced by a new " -"function or is no longer supported, and may be removed from future versions. " -"All code that uses this function should be converted to use its replacement." -msgstr "" -"Selle funktsiooni kasutamist taunitakse. See tähendab, et ta on asendatud " -"uue funktsiooniga või teda ei toetata enam ning ta võidakse tulevastest " -"versioonidest välja jätta. Kõik seda funktsiooni kasutav kood tuleks ümber " -"muuta kasutamaks tema asendust." - -#: ../includes/ot-functions-docs-page.php:476 -msgid "Use" -msgstr "Kasuta" - -#: ../includes/ot-functions-docs-page.php:476 -msgid "instead" -msgstr "asemel" - -#: ../includes/ot-functions-docs-page.php:480 -msgid "" -"This function returns, or echos if asked, a value from the \"option_tree\" " -"array of saved values." -msgstr "" -"See funktsioon tagastab või vajadusel trükib väärtuse \"option_tree\" " -"massiivi salvestatud väärtustest." - -#: ../includes/ot-functions-docs-page.php:490 -msgid "Enter a unique Option Key to get a returned value or array." -msgstr "Sisesta unikaalne valiku võti saamaks väärtust või massiivi." - -#: ../includes/ot-functions-docs-page.php:494 -msgid "array" -msgstr "array" - -#: ../includes/ot-functions-docs-page.php:494 -msgid "Used to cut down on database queries in template files." -msgstr "Kasutatakse andmebaasi päringute vähendamiseks mallifailides." - -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -msgid "boolean" -msgstr "boolean" - -#: ../includes/ot-functions-docs-page.php:498 -msgid "Echo the output." -msgstr "Trüki väljund." - -#: ../includes/ot-functions-docs-page.php:502 -msgid "Used to indicate the $item_id is an array of values." -msgstr "Kasutatakse märkimaks, et $item_id on väärtuste massiiv." - -#: ../includes/ot-functions-docs-page.php:506 -msgid "integer" -msgstr "integer" - -#: ../includes/ot-functions-docs-page.php:506 -msgid "" -"Numeric offset key for the $item_id array, -1 will return all values (an " -"array starts at 0)." -msgstr "" -"Numbriline nihkevõti $item_id massiivi jaoks, -1 tagastab kõik väärtused " -"( massiiv algab 0-st )." - -#: ../includes/ot-functions-docs-page.php:534 -msgid "" -"If you're using the plugin version of OptionTree it is highly recommended to " -"include a function_exists check in your code, as described in " -"the examples below. If you've integrated OptionTree directly into your " -"themes root directory, you will not need to wrap your code " -"with function_exists, as you're guaranteed to have the " -"ot_get_option() function available." -msgstr "" -"Kui kasutate OptionTree mooduli versiooni, siis on soovitatav oma koodi " -"lisada function_exists kontroll, nagu kirjeldatud allpool " -"toodud näidetes. Kui olete OptionTree otse oma teema juurkataloogi sisse " -"ehitanud, siis teil ei ole vaja mähkida oma koodi " -"function_exists kontrolliga, sest teil on " -"ot_get_option() funktsiooni saadavus garanteeritud." - -#: ../includes/ot-functions-docs-page.php:536 -msgid "String Examples" -msgstr "String-i näited" - -#: ../includes/ot-functions-docs-page.php:538 -msgid "Returns the value of test_input." -msgstr "Tagastab test_input väärtuse." - -#: ../includes/ot-functions-docs-page.php:544 -msgid "" -"Returns the value of test_input, but also has a default value " -"if it returns empty." -msgstr "" -"Tagastab test_input väärtuse või vaikeväärtuse, kui tagastatud " -"väärtus on tühi." - -#: ../includes/ot-functions-docs-page.php:550 -msgid "Array Examples" -msgstr "Array näited" - -#: ../includes/ot-functions-docs-page.php:552 -msgid "" -"Assigns the value of navigation_ids to the variable $ids. It then echos an unordered list of links (navigation) using " -"wp_list_pages()." -msgstr "" -"Omistab navigation_ids väärtuse $ids muutujale. " -"See trükib välja järjestamata loetelu ( navigatsiooni ) linkidest, kasutades " -"wp_list_pages()." - -#: ../includes/ot-functions-docs-page.php:572 -msgid "" -"The next two examples demonstrate how to use the Measurement option type. The Measurement option type is an array with two key/" -"value pairs. The first is the value of measurement and the second is the " -"unit of measurement." -msgstr "" -"Järgnevad kaks näidet demonstreerivad, kuidas kasutada mõõdu valikutüüpi. Mõõdu valikutüüp on massiiv kahe võti-väärtus paariga. " -"Esimene on mõõdu väärtus ning teine on mõõduühik." - -#: ../includes/ot-functions-docs-page.php:598 -msgid "This example displays a very basic slider loop." -msgstr "See näide kuvab väga algelise slaidi esitleja tsükli." - -#: ../includes/ot-functions-docs-page.php:643 -msgid "It's Super Simple" -msgstr "See on imelihtne" - -#: ../includes/ot-functions-docs-page.php:645 -msgid "" -"Layouts make your theme awesome! With theme options data that you can save/" -"import/export you can package themes with different color variations, or " -"make it easy to do A/B testing on text and so much more. Basically, you save " -"a snapshot of your data as a layout." -msgstr "" -"Paigutused teevad su teema aukartust äratavaks! Teema valikute infoga, mida " -"saad salvestada/importida/eksportida, saad pakendada teemasid erinevate " -"värvivariatsioonidega või kergelt teostada A/B testimist tekstiosadel ning " -"palju muud. Põhimõtteliselt on paigutus sinu andmete ülesvõtte salvestus." - -#: ../includes/ot-functions-docs-page.php:647 -msgid "" -"Once you have created all your different layouts, or theme variations, you " -"can save them to a separate text file for repackaging with your theme. " -"Alternatively, you could just make different variations for yourself and " -"change your theme with the click of a button, all without deleting your " -"previous options data." -msgstr "" -"Peale kõikide erinevate paigutuste või teema variatsioonide loomist saab nad " -"salvestada eraldi tekstifaili, mida teemaga kaasa pakendada. Teine " -"kasutusviis oleks teha enda jaoks erinevad variatsioonid ja muuta oma teemat " -"ainsa nupuvajutusega, ilma eelnevate andmete kustutamiseta." - -#: ../includes/ot-functions-docs-page.php:649 -msgid "" -" Adding a layout is ridiculously easy, follow these steps and you'll be on " -"your way to having a WordPress super theme." -msgstr "" -"Paigutuse lisamine on naeruväärselt lihtne. Järgi neid samme ning oled teel " -"WordPressi superteema omamisele." - -#: ../includes/ot-functions-docs-page.php:651 -msgid "For Developers" -msgstr "Arendajatele" - -#: ../includes/ot-functions-docs-page.php:653 -#: ../includes/ot-functions-docs-page.php:682 -msgid "Creating a Layout" -msgstr "Paigutuse loomine" - -#: ../includes/ot-functions-docs-page.php:655 -#: ../includes/ot-functions-docs-page.php:662 -#: ../includes/ot-functions-docs-page.php:668 -msgid "Go to the OptionTre->Settings->Layouts tab." -msgstr "Mine OptionTree->Sätted->Paigutused sakile." - -#: ../includes/ot-functions-docs-page.php:656 -msgid "" -"Enter a name for your layout in the text field and hit \"Save Layouts\", " -"you've created your first layout." -msgstr "" -"Sisesta tekstivälja oma paigutuse nimi ja vajuta \"Salvesta paigutused\" " -"nuppu. Oled loonud oma esimese paigutuse." - -#: ../includes/ot-functions-docs-page.php:657 -#: ../includes/ot-functions-docs-page.php:686 -msgid "Adding a new layout is as easy as repeating the steps above." -msgstr "Uue paigutuse lisamine on lihtne, kui järgid ülaltoodud samme." - -#: ../includes/ot-functions-docs-page.php:660 -#: ../includes/ot-functions-docs-page.php:689 -msgid "Activating a Layout" -msgstr "Paigutuse aktiveerimine" - -#: ../includes/ot-functions-docs-page.php:663 -msgid "Click on the activate layout button in the actions list." -msgstr "Vajuta paigutuse aktiveerimise nupul tegevuste nimekirjas." - -#: ../includes/ot-functions-docs-page.php:666 -#: ../includes/ot-functions-docs-page.php:695 -msgid "Deleting a Layout" -msgstr "Paigutuse kustutamine" - -#: ../includes/ot-functions-docs-page.php:669 -msgid "Click on the delete layout button in the actions list." -msgstr "Vajuta paigutuse kustutamise nupul tegevuste nimekirjas." - -#: ../includes/ot-functions-docs-page.php:672 -#: ../includes/ot-functions-docs-page.php:700 -msgid "Edit Layout Data" -msgstr "Muuda paigutuse andmeid" - -#: ../includes/ot-functions-docs-page.php:674 -#: ../includes/ot-functions-docs-page.php:684 -#: ../includes/ot-functions-docs-page.php:691 -msgid "Go to the Appearance->Theme Options page." -msgstr "Mine Välimus->Teema valikud lehele." - -#: ../includes/ot-functions-docs-page.php:675 -#: ../includes/ot-functions-docs-page.php:703 -msgid "" -"Modify and save your theme options and the layout will be updated " -"automatically." -msgstr "" -"Muuda ja salvesta oma teema valikuid ning paigutust uuendatakse automaatselt." - -#: ../includes/ot-functions-docs-page.php:676 -#: ../includes/ot-functions-docs-page.php:704 -msgid "" -"Saving theme options data will update the currently active layout, so before " -"you start saving make sure you want to modify the current layout." -msgstr "" -"Teema valikute andmete salvestamine uuendab hetkel aktiivset paigutust, " -"seega enne salvestamist veendu, et soovid muuta hetkel kasutuses olevat " -"paigutust." - -#: ../includes/ot-functions-docs-page.php:677 -msgid "" -"If you want to edit a new layout, first create it then save your theme " -"options." -msgstr "" -"Kui soovid muuta uut paigutust, tuleb see kõigepealt luua ja seejärel teema " -"valikud salvestada." - -#: ../includes/ot-functions-docs-page.php:680 -msgid "End-Users Mode" -msgstr "Lõppkasutaja režiim" - -#: ../includes/ot-functions-docs-page.php:685 -msgid "" -"Enter a name for your layout in the text field and hit \"New Layout\", " -"you've created your first layout." -msgstr "" -"Sisesta tekstivälja oma uue paigutuse nimi ja vajuta nuppu \"Uus paigutus\". " -"Oled loonud oma esimese paigutuse." - -#: ../includes/ot-functions-docs-page.php:692 -msgid "" -"Choose a layout from the select list and click the \"Activate Layout\" " -"button." -msgstr "Vali rippmenüüst paigutus ja vajuta \"Aktiveeri paigutus\" nuppu." - -#: ../includes/ot-functions-docs-page.php:697 -msgid "End-Users mode does not allow deleting layouts." -msgstr "Lõppkasutaja režiim ei luba paigutusi kustutada." - -#: ../includes/ot-functions-docs-page.php:702 -msgid "Go to the Appearance->Theme Options tab." -msgstr "Mine Välimus->Teema valikud sakile." - -#: ../includes/ot-functions-docs-page.php:733 -#: ../includes/ot-functions-docs-page.php:815 -msgid "How-to-guide" -msgstr "Õpetus" - -#: ../includes/ot-functions-docs-page.php:735 -msgid "" -"There are a few simple steps you need to take in order to use OptionTree's " -"built in Meta Box API. In the code below I'll show you a basic demo of how " -"to create your very own custom meta box using any number of the option types " -"you have at your disposal. If you would like to see some demo code, there is " -"a directory named theme-mode inside the assets " -"directory that contains a file named demo-meta-boxes.php you " -"can reference." -msgstr "" -"OptionTreele sisse ehitatud Meta Box API kasutamiseks on vaja paari lihtsat " -"toimingut. Allolevas koodis demonstreeritakse meta kasti loomist suvalise " -"hulga saadaolevate valikutüüpidega. Koodinäiteid leiab ka failist demo-" -"meta-boxes.php, mis asub kaustas theme-mode, mis " -"omakorda asub kaustas assets." - -#: ../includes/ot-functions-docs-page.php:737 -msgid "" -"It's important to note that Meta Boxes do not support WYSIWYG editors at " -"this time and if you set one of your options to Textarea it will " -"automatically revert to a Textarea Simple until a valid solution is found. " -"WordPress released this statement regarding the wp_editor() function:" -msgstr "" -"Tähtis märkus: meta kastid ei toeta hetkel WYSIWYG redaktoreid. Kui määrata " -"mõne valiku tüübiks tekstiala, muudetakse see automaatselt lihtsustatud " -"tekstialaks, kuni leitakse töötav lahendus. Wordpress väljastas järgneva " -"teadaande wp_editor() funktsiooni kohta:" - -#: ../includes/ot-functions-docs-page.php:739 -msgid "" -"Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. " -"What this means in practical terms, is that you cannot put it in meta-boxes " -"that can be dragged and placed elsewhere on the page." -msgstr "" -"Korra loodud WYSIWYG toimetajat ei saa DOM-is ringi liigutada. Praktikas " -"tähendab see, et teda ei saa panna meta-kastidesse, mida on võimalik " -"leheküljel ringi liigutada." - -#: ../includes/ot-functions-docs-page.php:741 -msgid "Create and include your custom meta boxes file." -msgstr "Loo ja kaasa oma kohandatud meta kastide fail." - -#: ../includes/ot-functions-docs-page.php:743 -msgid "" -"Create a file and name it anything you want, maybe meta-boxes.php." -msgstr "" -"Loo fail ja anna talle meelepärane nimi, näiteks meta-boxes.php." - -#: ../includes/ot-functions-docs-page.php:744 -msgid "" -"As well, you'll probably want to create a directory named includes to put your meta-boxes.php into which will help keep you " -"file structure nice and tidy." -msgstr "" -"Tõenäoliselt soovid luua kausta nimega includes, kuhu panna oma " -"meta-boxes.php fail, hoidmaks oma failistruktuuri ilusa ja " -"puhtana." - -#: ../includes/ot-functions-docs-page.php:745 -#: ../includes/ot-functions-docs-page.php:845 -msgid "Add the following code to your functions.php." -msgstr "Lisa järgnev kood oma functions.php faili." - -#: ../includes/ot-functions-docs-page.php:755 -msgid "" -"Add a variation of the following code to your meta-boxes.php. " -"You'll obviously need to fill it in with all your custom array values. It's " -"important to note here that we use the admin_init filter " -"because if you were to call the ot_register_meta_box function " -"before OptionTree was loaded the sky would fall on your head." -msgstr "" -"Lisa variatsioon järgnevast koodist oma meta-boxes.php faili. " -"Loomulikult tuleb see täita enda kohandatud massiivi väärtustega. Oluline " -"märkus: kasutame admin_init filtrit, sest kui kutsuda " -"ot_register_meta_box funktsiooni enne OptionTree laadimist, " -"kukuks taevas kaela." - -#: ../includes/ot-functions-docs-page.php:817 -msgid "" -"There are a few simple steps you need to take in order to use OptionTree as " -"a theme included module. In the code below I'll show you a basic demo of how " -"to include the entire plugin as a module, which will allow you to have the " -"most up-to-date version of OptionTree without ever needing to hack the core " -"of the plugin. If you would like to see some demo code, there is a directory " -"named theme-mode inside the assets directory that " -"contains a file named demo-theme-options.php you can reference." -msgstr "" -"Paari lihtsa sammuga saab Optiontreed kasutada teemasse kaasatud moodulina. " -"Allolevas koodis näidatakse lihtsat demonstratsiooni, kuidas kaasata terve " -"moodul moodulina. Sellisel moel on sul kõige uuem versioon OptionTreest, " -"ilma et peaks mooduli tuuma häkkima. Näidiskoodi leiab failist demo-" -"theme-options.php, mis asub kaustas theme-mode, mis " -"omakorda asub kaustas assets." - -#: ../includes/ot-functions-docs-page.php:819 -msgid "Step 1: Include the plugin & turn on theme mode." -msgstr "Samm 1: kaasa moodul ja lülita sisse teemarežiim." - -#: ../includes/ot-functions-docs-page.php:821 -#, php-format -msgid "Download the latest version of %s and unarchive the %s directory." -msgstr "Lae alla viimane %s versioon ja paki ta lahti %s kausta." - -#: ../includes/ot-functions-docs-page.php:822 -#, php-format -msgid "" -"Put the %s directory in the root of your theme. For example, the server path " -"would be %s." -msgstr "Pane %s kaust oma teema juurkausta. Serveri rada oleks näiteks %s." - -#: ../includes/ot-functions-docs-page.php:823 -#, php-format -msgid "Add the following code to the beginning of your %s." -msgstr "Lisa järgnev kood oma %s algusesse." - -#: ../includes/ot-functions-docs-page.php:837 -#, php-format -msgid "" -"For a list of all the OptionTree UI display filters refer to the %s file " -"found in the %s directory of this plugin. This file is the starting point " -"for developing themes with Theme Mode." -msgstr "" -"Täieliku OptionTree UI kuvamise filtrite nimekirja leiad selle plugina %s " -"failist %s kaustast. See fail on teemarežiimis teemade arenduse " -"alguspunktiks." - -#: ../includes/ot-functions-docs-page.php:839 -msgid "" -"You now have OptionTree built into your theme and anytime an update is " -"available replace the old version with the new one." -msgstr "" -"Sul on nüüd OptionTree teemasse sisse ehitatud. Iga kord, kui saadaval on " -"uus versioon, vaheta oma vana versioon uue vastu välja." - -#: ../includes/ot-functions-docs-page.php:841 -msgid "Step 2: Create Theme Options without using the UI Builder." -msgstr "Samm 2: loo teema valikud ilma UI ehitajata." - -#: ../includes/ot-functions-docs-page.php:843 -msgid "" -"Create a file and name it anything you want, maybe theme-options.php, or use the built in file export to create it for you. Remember, you " -"should always check the file for errors before including it in your theme." -msgstr "" -"Loo fail ja anna talle suvaline nimi, näiteks theme-options.php, või kasuta selle loomiseks sisse ehitatud faili eksporti. Enne teemas " -"kasutamist tuleks failile kindlasti vigade kontroll teha." - -#: ../includes/ot-functions-docs-page.php:844 -msgid "" -"As well, you'll probably want to create a directory named includes to put your theme-options.php into which will help keep " -"you file structure nice and tidy." -msgstr "" -"Tõenäoliselt soovid luua ka kausta includes, kuhu oma " -"theme-options.php fail panna. See hoiab failistruktuuri ilusa " -"ja puhtana." - -#: ../includes/ot-functions-docs-page.php:855 -msgid "" -"Add a variation of the following code to your theme-options.php. You'll obviously need to fill it in with all your custom array values " -"for contextual help (optional), sections (required), and settings (required)." -msgstr "" -"Lisa oma theme-options.php faili mingi variatsioon järgnevast " -"koodist. Loomulikult tuleb see täita enda massiiviväärtustega " -"kontekstipõhise abi ( valikuline ), sektsioonide ( nõutud ) ja sätete " -"( nõutud ) jaoks." - -#: ../includes/ot-functions-docs-page.php:858 -msgid "" -"The code below is a boilerplate to get your started. For a full list of the " -"available option types click the \"Option Types\" tab above. Also a quick " -"note, you don't need to put OptionTree in theme mode to manually create " -"options but you will want to hide the docs and settings as each time you " -"load the admin area the settings be written over with the code below if " -"they've changed in any way. However, this ensures your settings do not get " -"tampered with by the end-user." -msgstr "" -"Allolev kood on stereotüüp, millega saad alustada. Saadaolevate " -"valikutüüpide täieliku nimekirja saad ülalolevast \"Valikutüübid\" sakist. " -"Kiire vahemärkus: käsitsi valikute loomiseks ei pea OptionTree olema " -"teemarežiimis, kuid sel juhul tuleks peita ära dokumentatsioon ja sätted, " -"sest iga kord kui haldusliides laaditakse kirjutatakse sätted üle alloleva " -"koodiga. Samas see kindlustab, et lõppkasutaja ei saa sätteid näppida." - -#: ../includes/ot-functions-option-types.php:46 -msgid "Sorry, this function does not exist" -msgstr "Kahjuks sellist funktsiooni pole." - -#: ../includes/ot-functions-option-types.php:134 -msgid "background-repeat" -msgstr "background-repeat" - -#: ../includes/ot-functions-option-types.php:152 -msgid "background-attachment" -msgstr "background-attachment" - -#: ../includes/ot-functions-option-types.php:171 -msgid "background-position" -msgstr "background-position" - -#: ../includes/ot-functions-option-types.php:224 -msgid "background-size" -msgstr "background-size" - -#: ../includes/ot-functions-option-types.php:238 -msgid "background-image" -msgstr "background-image" - -#: ../includes/ot-functions-option-types.php:241 -#: ../includes/ot-functions-option-types.php:3202 -msgid "Add Media" -msgstr "Lisa meediat" - -#: ../includes/ot-functions-option-types.php:316 -#: ../includes/ot-functions-option-types.php:1045 -msgid "width" -msgstr "width" - -#: ../includes/ot-functions-option-types.php:327 -#: ../includes/ot-functions-option-types.php:1065 -#: ../includes/ot-functions-option-types.php:1550 -#: ../includes/ot-functions-option-types.php:2506 -msgid "unit" -msgstr "ühik" - -#: ../includes/ot-functions-option-types.php:346 -msgid "style" -msgstr "style" - -#: ../includes/ot-functions-option-types.php:439 -msgid "offset-x" -msgstr "offset-x" - -#: ../includes/ot-functions-option-types.php:448 -msgid "offset-y" -msgstr "offset-y" - -#: ../includes/ot-functions-option-types.php:457 -msgid "blur-radius" -msgstr "blur-radius" - -#: ../includes/ot-functions-option-types.php:466 -msgid "spread-radius" -msgstr "spread-radius" - -#: ../includes/ot-functions-option-types.php:538 -#: ../includes/ot-functions-option-types.php:592 -msgid "No Categories Found" -msgstr "Kategooriaid ei leitud" - -#: ../includes/ot-functions-option-types.php:587 -#: ../includes/ot-functions-option-types.php:870 -#: ../includes/ot-functions-option-types.php:1819 -#: ../includes/ot-functions-option-types.php:1930 -#: ../includes/ot-functions-option-types.php:2646 -#: ../includes/ot-functions-option-types.php:2761 -msgid "Choose One" -msgstr "Valik üks" - -#: ../includes/ot-functions-option-types.php:818 -#: ../includes/ot-functions-option-types.php:876 -#: ../includes/ot-functions-option-types.php:1881 -#: ../includes/ot-functions-option-types.php:1936 -msgid "No Posts Found" -msgstr "Postitusi ei leitud" - -#: ../includes/ot-functions-option-types.php:1054 -msgid "height" -msgstr "height" - -#: ../includes/ot-functions-option-types.php:1232 -#: ../includes/ot-functions-option-types.php:1275 -msgid "Remove Google Font" -msgstr "Eemalda Google Font" - -#: ../includes/ot-functions-option-types.php:1234 -#: ../includes/ot-functions-option-types.php:1277 -msgid "-- Choose One --" -msgstr "-- Vali üks --" - -#: ../includes/ot-functions-option-types.php:1298 -msgid "Add Google Font" -msgstr "Lisa Google Font" - -#: ../includes/ot-functions-option-types.php:1384 -msgctxt "color picker" -msgid "Standard" -msgstr "Standard" - -#: ../includes/ot-functions-option-types.php:1385 -msgctxt "color picker" -msgid "Hover" -msgstr "Hõljudes" - -#: ../includes/ot-functions-option-types.php:1386 -msgctxt "color picker" -msgid "Active" -msgstr "Aktiivne" - -#: ../includes/ot-functions-option-types.php:1387 -msgctxt "color picker" -msgid "Visited" -msgstr "Külastatud" - -#: ../includes/ot-functions-option-types.php:1388 -msgctxt "color picker" -msgid "Focus" -msgstr "Fookus" - -#: ../includes/ot-functions-option-types.php:1497 -#: ../includes/ot-functions-option-types.php:2246 -#: ../includes/ot-functions-option-types.php:2411 -msgid "Add New" -msgstr "Lisa uus" - -#: ../includes/ot-functions-option-types.php:1500 -#: ../includes/ot-functions-option-types.php:2249 -#: ../includes/ot-functions-option-types.php:2414 -msgid "You can re-order with drag & drop, the order will update after saving." -msgstr "" -"Lohistades saab elemente ümber paigutada. Järjekord uueneb peale " -"salvestamist." - -#: ../includes/ot-functions-option-types.php:1670 -msgid "On" -msgstr "Sees" - -#: ../includes/ot-functions-option-types.php:1692 -msgid "Off" -msgstr "Väljas" - -#: ../includes/ot-functions-option-types.php:1770 -#: ../includes/ot-functions-option-types.php:1825 -msgid "No Pages Found" -msgstr "Lehekülgi ei leitud" - -#: ../includes/ot-functions-option-types.php:2169 -msgid "Choose Sidebar" -msgstr "Vali küljendusmenüü" - -#: ../includes/ot-functions-option-types.php:2174 -msgid "No Sidebars" -msgstr "Küljendusmenüüd puuduvad" - -#: ../includes/ot-functions-option-types.php:2282 -msgid "Facebook" -msgstr "Facebook" - -#: ../includes/ot-functions-option-types.php:2287 -msgid "Twitter" -msgstr "Twitter" - -#: ../includes/ot-functions-option-types.php:2292 -msgid "Google+" -msgstr "Google+" - -#: ../includes/ot-functions-option-types.php:2297 -msgid "LinkedIn" -msgstr "LinkedIn" - -#: ../includes/ot-functions-option-types.php:2302 -msgid "Pinterest" -msgstr "Pinterest" - -#: ../includes/ot-functions-option-types.php:2307 -msgid "Youtube" -msgstr "Youtube" - -#: ../includes/ot-functions-option-types.php:2312 -msgid "Dribbble" -msgstr "Dribbble" - -#: ../includes/ot-functions-option-types.php:2317 -msgid "Github" -msgstr "Github" - -#: ../includes/ot-functions-option-types.php:2322 -msgid "Forrst" -msgstr "Forrst" - -#: ../includes/ot-functions-option-types.php:2327 -msgid "Digg" -msgstr "Digg" - -#: ../includes/ot-functions-option-types.php:2332 -msgid "Delicious" -msgstr "Delicious" - -#: ../includes/ot-functions-option-types.php:2337 -msgid "Tumblr" -msgstr "Tumblr" - -#: ../includes/ot-functions-option-types.php:2342 -msgid "Skype" -msgstr "Skype" - -#: ../includes/ot-functions-option-types.php:2347 -msgid "SoundCloud" -msgstr "SoundCloud" - -#: ../includes/ot-functions-option-types.php:2352 -msgid "Vimeo" -msgstr "Vimeo" - -#: ../includes/ot-functions-option-types.php:2357 -msgid "Flickr" -msgstr "Flickr" - -#: ../includes/ot-functions-option-types.php:2362 -msgid "VK.com" -msgstr "VK.com" - -#: ../includes/ot-functions-option-types.php:2468 -msgid "top" -msgstr "top" - -#: ../includes/ot-functions-option-types.php:2477 -msgid "right" -msgstr "right" - -#: ../includes/ot-functions-option-types.php:2486 -msgid "bottom" -msgstr "bottom" - -#: ../includes/ot-functions-option-types.php:2495 -msgid "left" -msgstr "left" - -#: ../includes/ot-functions-option-types.php:2597 -#: ../includes/ot-functions-option-types.php:2651 -msgid "No Tags Found" -msgstr "Märksõnu ei leitud" - -#: ../includes/ot-functions-option-types.php:2709 -#: ../includes/ot-functions-option-types.php:2766 -msgid "No Taxonomies Found" -msgstr "Taksonoomiaid ei leitud" - -#: ../includes/ot-functions-settings-page.php:35 -msgid "Warning!" -msgstr "Hoiatus!" - -#: ../includes/ot-functions-settings-page.php:36 -#, php-format -msgid "" -"Go to the %s page if you want to save data, this page is for adding settings." -msgstr "Info salvestamiseks on %s leht, see leht siin on sätete lisamiseks." - -#: ../includes/ot-functions-settings-page.php:37 -#, php-format -msgid "" -"If you're unsure or not completely positive that you should be editing these " -"settings, you should read the %s first." -msgstr "Kui kahtled, kas peaksid neid sätteid muutma, loe kõigepealt %s." - -#: ../includes/ot-functions-settings-page.php:38 -msgid "" -"Things could break or be improperly displayed to the end-user if you do one " -"of the following:" -msgstr "" -"Kui teed ühte järgnevatest, võivad asjad katki minna või olla lõpp-" -"kasutajale valesti kuvatud:" - -#: ../includes/ot-functions-settings-page.php:39 -msgid "" -"Give two sections the same ID, give two settings the same ID, give two " -"contextual help content areas the same ID, don't create any settings, or " -"have a section at the end of the settings list." -msgstr "" -"annad kahele sektsioonile sama ID, annad kahele sättele sama ID, annad " -"kahele kontekstipõhise abi alale sama ID, ei loo ühtegi sätet või jätad " -"sektsiooni sätete nimekirja lõppu." - -#: ../includes/ot-functions-settings-page.php:40 -msgid "" -"You can create as many settings as your project requires and use them how " -"you see fit. When you add a setting here, it will be available on the Theme " -"Options page for use in your theme. To separate your settings into sections, " -"click the \"Add Section\" button, fill in the input fields, and a new " -"navigation menu item will be created." -msgstr "" -"Sätteid saab luua nii palju kui vaja ning kasutada oma parema äranägemise " -"järgi. Siia sätte lisamisel tekib see teema valikute lehele oma teemas " -"kasutamiseks. Sätete sektsioonidesse eraldamiseks vajuta \"Lisa sektsioon\" " -"nupule, täida sisendväljad ning uus navigatsioonimenüü element on loodud." - -#: ../includes/ot-functions-settings-page.php:41 -msgid "" -"All of the settings can be sorted and rearranged to your liking with Drag & " -"Drop. Don't worry about the order in which you create your settings, you can " -"always reorder them." -msgstr "" -"Kõiki sätteid saab sorteerida ja ümber paigutada lohistamise abil. Sätete " -"loomise järjekorra üle ei pea muretsema, sest neid saab alati ümber " -"järjestada." - -#: ../includes/ot-functions-settings-page.php:92 -msgid "Add Section" -msgstr "Lisa sektsioon" - -#: ../includes/ot-functions-settings-page.php:99 -msgid "Contextual Help" -msgstr "Konteksti põhine abi" - -#: ../includes/ot-functions-settings-page.php:103 -msgid "Contextual Help Sidebar" -msgstr "Konteksti põhise abi küljeriba" - -#: ../includes/ot-functions-settings-page.php:103 -msgid "" -"If you decide to add contextual help to the Theme Option page, enter the " -"optional \"Sidebar\" HTML here. This would be an extremely useful place to " -"add links to your themes documentation or support forum. Only after you've " -"added some content below will this display to the user." -msgstr "" -"Kui soovida lisada kontekstipõhist abiteksti, sisesta \"Küljeriba\" HTML " -"siia. See oleks väga hea koht, kuhu lisada linke oma teema " -"dokumentatsioonile või kasutajatoe foorumile. Seda näidatakse kasutajale " -"vaid juhul, kui allpool on mingi sisu lisatud." - -#: ../includes/ot-functions-settings-page.php:132 -msgid "Add Contextual Help Content" -msgstr "Lisa konteksti põhine abitekst" - -#: ../includes/ot-functions-settings-page.php:168 -msgid "" -"This import method has been deprecated. That means it has been replaced by a " -"new method and is no longer supported, and may be removed from future " -"versions. All themes that use this import method should be converted to use " -"its replacement below." -msgstr "" -"Impordi meetodit taunitakse. See tähendab, et teda asendab uuem meetod ja " -"enam teda ei toetata. Ta võidakse tulevastes versioonides eemaldada. Kõik " -"teemad, mis seda impordi meetodit kasutavad, tuleks ümber muuta allolevat " -"asendust kasutama." - -#: ../includes/ot-functions-settings-page.php:170 -#, php-format -msgid "" -"If you were given a Theme Options XML file with a premium or free theme, " -"locate it on your hard drive and upload that file by clicking the upload " -"button. A popup window will appear, upload the XML file and click \"%s\". " -"The file URL should be in the upload input, if it is click \"Import XML\"." -msgstr "" -"Kui sulle anti teemaga kaasa valikute XML fail, leia see oma kõvakettalt " -"ning vajuta üleslaadimise nuppu. Avanevas aknas lae üles XML fail ja vajuta " -"\"%s\". Faili URL peaks olema üleslaadimise sisendis. Kui see seal on, " -"vajuta nuppu \"Impordi XML\"." - -#: ../includes/ot-functions-settings-page.php:173 -msgid "Import XML" -msgstr "Impordi XML" - -#: ../includes/ot-functions-settings-page.php:189 -msgid "Add XML" -msgstr "Lisa XML" - -#: ../includes/ot-functions-settings-page.php:226 -msgid "" -"To import your Settings copy and paste what appears to be a random string of " -"alpha numeric characters into this textarea and press the \"Import Settings" -"\" button." -msgstr "" -"Sätete importimiseks kopeeri ja kleebi näiliselt juhuslik string tähtedest " -"ja numbritest siia tekstialasse ning vajuta \"Impordi sätted\" nuppu." - -#: ../includes/ot-functions-settings-page.php:229 -msgid "Import Settings" -msgstr "Impordi seaded" - -#: ../includes/ot-functions-settings-page.php:271 -msgid "" -"Only after you've imported the Settings should you try and update your Theme " -"Options." -msgstr "Enne teema valikute uuendamist impordi sätted." - -#: ../includes/ot-functions-settings-page.php:273 -msgid "" -"To import your Theme Options copy and paste what appears to be a random " -"string of alpha numeric characters into this textarea and press the \"Import " -"Theme Options\" button." -msgstr "" -"Teema valikute importimiseks kopeeri ja kleebi näiliselt juhuslik string " -"tähtedest ja numbritest siia tekstialasse ning vajuta \"Impordi teema valikud" -"\" nuppu." - -#: ../includes/ot-functions-settings-page.php:276 -msgid "Import Theme Options" -msgstr "Impordi teema valikud" - -#: ../includes/ot-functions-settings-page.php:318 -msgid "" -"Only after you've imported the Settings should you try and update your " -"Layouts." -msgstr "Enne paigutuste uuendamist impordi sätted." - -#: ../includes/ot-functions-settings-page.php:320 -msgid "" -"To import your Layouts copy and paste what appears to be a random string of " -"alpha numeric characters into this textarea and press the \"Import Layouts\" " -"button. Keep in mind that when you import your layouts, the active layout's " -"saved data will write over the current data set for your Theme Options." -msgstr "" -"Paigutuste importimiseks kopeeri ja kleebi näiliselt juhuslik string " -"tähtedest ja numbritest siia tekstialasse ning vajuta \"Impordi paigutus\" " -"nuppu. Arvesta, et aktiivse paigutuse salvestatud andmed kirjutavad " -"hetkeandmed üle." - -#: ../includes/ot-functions-settings-page.php:323 -msgid "Import Layouts" -msgstr "Impordi paigutused" - -#: ../includes/ot-functions-settings-page.php:366 -#, php-format -msgid "" -"Export your Settings into a fully functional %s file. If you want to add " -"your own custom %s text domain to the file, enter it into the text field " -"before exporting. For more information on how to use this file read the " -"documentation on %s. Remember, you should always check the file for errors " -"before including it in your theme." -msgstr "" -"Ekspordi oma sätted täisfunktsionaalsesse %s faili. Kui soovid failile " -"lisada enda kohandatud %s tekstidomeeni, sisesta see tekstivälja enne " -"eksportimist. Lisainformatsiooni selle faili kasutamise kohta leiad " -"dokumentatsioonis %s. Pea meeles, et failile tuleks teha vigade kontroll " -"enne teemasse kaasamist." - -#: ../includes/ot-functions-settings-page.php:375 -msgid "Export Settings File" -msgstr "Ekspordi seadete fail" - -#: ../includes/ot-functions-settings-page.php:405 -msgid "" -"Export your Settings by highlighting this text and doing a copy/paste into a " -"blank .txt file. Then save the file for importing into another install of " -"WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Settings textarea " -"on another web site." -msgstr "" -"Ekspordi oma sätted, markeerides see tekst ja kopeerides ta tühja .txt " -"faili. Seejärel salvesta fail hilisemaks importimiseks teise WordPressi " -"installatsiooni. Alternatiivina võib selle kleepida otse teise veebilehe " -"OptionTree->Sätted->Import Sätted tekstialasse." - -#: ../includes/ot-functions-settings-page.php:441 -msgid "" -"Export your Theme Options data by highlighting this text and doing a copy/" -"paste into a blank .txt file. Then save the file for importing into another " -"install of WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Theme Options " -"textarea on another web site." -msgstr "" -"Ekspordi oma teema valikud, markeerides see tekst ja kopeerides ta tühja ." -"txt faili. Seejärel salvesta fail hilisemaks importimiseks teise WordPressi " -"installatsiooni. Alternatiivina võib selle kleepida otse teise veebilehe " -"OptionTree->Sätted->Import Teema valikud " -"tekstialasse." - -#: ../includes/ot-functions-settings-page.php:477 -msgid "" -"Export your Layouts by highlighting this text and doing a copy/paste into a " -"blank .txt file. Then save the file for importing into another install of " -"WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Layouts textarea " -"on another web site." -msgstr "" -"Ekspordi oma paigutused, markeerides see tekst ja kopeerides ta tühja .txt " -"faili. Seejärel salvesta fail hilisemaks importimiseks teise WordPressi " -"installatsiooni. Alternatiivina võib selle kleepida otse teise veebilehe " -"OptionTree->Sätted->Import Paigutused " -"tekstialasse." - -#: ../includes/ot-functions-settings-page.php:519 -msgid "" -"To add a new layout enter a unique lower case alphanumeric string (dashes " -"allowed) in the text field and click \"Save Layouts\"." -msgstr "" -"Uue paigutuse lisamiseks sisestage tekstivälja unikaalne väiketähtedega " -"alfanumbriline string ( sidekriipsud lubatud ) ning vajutage \"Salvesta " -"paigutused\" nupul." - -#: ../includes/ot-functions-settings-page.php:520 -msgid "" -"As well, you can activate, remove, and drag & drop the order; all situations " -"require you to click \"Save Layouts\" for the changes to be applied." -msgstr "" -"Saate ka aktiveerida, eemaldada ning lohistades järjekorda muuta. Muudatused " -"ei mõju enne, kui vajutate \"Salvesta paigutused\" nuppu." - -#: ../includes/ot-functions-settings-page.php:521 -msgid "" -"When you create a new layout it will become active and any changes made to " -"the Theme Options will be applied to it. If you switch back to a different " -"layout immediately after creating a new layout that new layout will have a " -"snapshot of the current Theme Options data attached to it." -msgstr "" -"Uue paigutuse loomisel muudetakse see aktiivseks ning edasised muudatused " -"teema valikutes mõjuvad talle. Kui peale uue paigutuse loomist kohe mõne muu " -"paigutuse peale vahetada, siis uue paigutuse külge jääb teema valikute " -"andmete hetkeseis paigutuse loomisel." - -#: ../includes/ot-functions-settings-page.php:522 -msgid "" -"Visit OptionTree->Documentation->Layouts Overview to see a more " -"in-depth description of what layouts are and how to use them." -msgstr "" -"Lehel OptionTree->Dokumentatsioon->Paigutuste ülevaade leiad " -"põhjalikuma paigutuste kirjelduse ja kasutusjuhendi." - -#: ../includes/ot-functions-settings-page.php:559 -msgid "Save Layouts" -msgstr "Salvesta paigutused" - -#: ../includes/ot-settings-api.php:364 -msgid "Reset Options" -msgstr "Algseadista seaded" - -#: ../ot-loader.php:22 -msgid "" -"OptionTree is installed as a plugin and also embedded in your current theme. " -"Please deactivate the plugin to load the theme dependent version of " -"OptionTree, and remove this warning." -msgstr "" -"OptionTree on paigaldatud nii moodulina kui ka kaasatud aktiivses teemas. " -"Palun lülita moodul välja, et laetaks teemast sõltuv versioon OptionTreest " -"ja see hoiatus kaoks." - -#~ msgid "The Colorpicker only allows valid hexadecimal values." -#~ msgstr "" -#~ "Värvi valija lubab vaid sobivaid kuueteistkümnendiksüsteemis väärtuseid." - -#~ msgid "Congratulations! You have a clean install." -#~ msgstr "Õnnitlused! Sul on puhas paigaldus." - -#~ msgid "" -#~ "Your version of OptionTree does not have any outdated data. If there was " -#~ "outdated data, you would be presented with options to clean it up." -#~ msgstr "" -#~ "Sinu OptionTree versioonis ei ole aegunud andmeid. Kui neid oleks, siis " -#~ "pakutaks võimalust puhastamiseks." - -#~ msgid "Hide This Page" -#~ msgstr "Peida lehekülg" - -#~ msgid "Demo Meta Box" -#~ msgstr "Näidis meta kast" - -#~ msgid "Conditions" -#~ msgstr "Tingimused" - -#~ msgid "Show Gallery" -#~ msgstr "Näita galeriid" - -#~ msgid "Shows the Gallery when set to %s." -#~ msgstr "Näitab galeriid, kui on määratud asendisse %s" - -#~ msgid "Congratulations, you created a gallery!" -#~ msgstr "Õnnitlused, lõite just galerii!" - -#~ msgid "This is a Gallery option type. It displays when %s." -#~ msgstr "See on galerii valikutüüp. Nähtaval, kui ta on %s" - -#~ msgid "More Options" -#~ msgstr "Rohkem seadeid" - -#~ msgid "This is a demo Text field." -#~ msgstr "See on näidis tekstisisend." - -#~ msgid "This is a demo Textarea field." -#~ msgstr "See on näidis tekstiväli." - -#~ msgid "Help content goes here!" -#~ msgstr "Siia lähevad abitekstid!" - -#~ msgid "Sidebar content goes here!" -#~ msgstr "Siia läheb küljeriba sisu!" - -#~ msgid "No" -#~ msgstr "Ei" - -#~ msgid "Yes" -#~ msgstr "Jah" - -#~ msgid "Gallery Shortcode" -#~ msgstr "Galerii lühikood" - -#~ msgid "" -#~ "The Gallery option type can also be saved as a shortcode by adding %s to " -#~ "the class attribute. Using the Gallery option type in this manner will " -#~ "result in a better user experience as you're able to save the link, " -#~ "column, and order settings." -#~ msgstr "" -#~ "Lisades %s klassiatribuudiks saab galerii valikutüübi salvestada ka " -#~ "lühikoodina. Sellisel moel galerii valikutüüpi kasutades on tulemuseks " -#~ "parem kasutajakogemus, kuna saad salvestada lingi, tulba ja järjekorra " -#~ "sätteid." - -#~ msgid "" -#~ "The List Item option type allows for a great deal of customization. You " -#~ "can add settings to the List Item and those settings will be displayed to " -#~ "the user when they add a new List Item. Typical use is for creating " -#~ "sliding content or blocks of code for custom layouts." -#~ msgstr "" -#~ "Nimekirja elemendi valikutüüpi on väga hästi kohandatav. Nimekirja " -#~ "elementidele saab lisada sätteid ning neid näidatakse kasutajale uue " -#~ "elemendi lisamisel. Tüüpiline kasutus on liugleva sisu jaoks või " -#~ "kohandatud paigutuse koodiblokkide tarvis." - -#~ msgid "Content" -#~ msgstr "Sisu" - -#~ msgid "Maybe" -#~ msgstr "Võib-olla" - -#~ msgid "Upload Attachment ID" -#~ msgstr "Üles laetud manuse ID" - -#~ msgid "" -#~ "The Upload option type can also be saved as an attachment ID by adding %s " -#~ "to the class attribute." -#~ msgstr "" -#~ "Üleslaadimise valikutüüpi saab salvestada ka manuse ID-na, lisades %s " -#~ "klassi atribuudile." - -#~ msgid "Color Picker" -#~ msgstr "Värvi valija" diff --git a/languages/option-tree.po b/languages/option-tree.po deleted file mode 100644 index 4300914..0000000 --- a/languages/option-tree.po +++ /dev/null @@ -1,2461 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: OptionTree\n" -"POT-Creation-Date: 2016-01-31 23:23-0800\n" -"PO-Revision-Date: 2016-01-31 23:24-0800\n" -"Last-Translator: Derek Herman \n" -"Language-Team: Valen Designs\n" -"Language: en\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.7.6\n" -"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" -"_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;" -"esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" -"X-Poedit-Basepath: .\n" -"Plural-Forms: nplurals=2; plural=n != 1;\n" -"X-Poedit-SearchPath-0: ..\n" -"X-Poedit-SearchPathExcluded-0: ../.git\n" -"X-Poedit-SearchPathExcluded-1: ../composer.json\n" -"X-Poedit-SearchPathExcluded-2: ../assets\n" - -#: ../includes/ot-cleanup-api.php:84 ../includes/ot-cleanup-api.php:101 -#: ../includes/ot-cleanup-api.php:130 -msgid "OptionTree Cleanup" -msgstr "" - -#: ../includes/ot-cleanup-api.php:101 -#, php-format -msgid "" -"OptionTree has outdated data that should be removed. Please go to %s for " -"more information." -msgstr "" - -#: ../includes/ot-cleanup-api.php:136 -msgid "Multiple Media Posts" -msgstr "" - -#: ../includes/ot-cleanup-api.php:138 -#, php-format -msgid "" -"There are currently %s OptionTree media posts in your database. At some " -"point in the past, a version of OptionTree added multiple %s media post " -"objects cluttering up your %s table. There is no associated risk or harm " -"that these posts have caused other than to add size to your overall " -"database. Thankfully, there is a way to remove all these orphaned media " -"posts and get your database cleaned up." -msgstr "" - -#: ../includes/ot-cleanup-api.php:140 -#, php-format -msgid "" -"By clicking the button below, OptionTree will delete %s records and " -"consolidate them into one single OptionTree media post for uploading " -"attachments to. Additionally, the attachments will have their parent ID " -"updated to the correct media post." -msgstr "" - -#: ../includes/ot-cleanup-api.php:142 -msgid "" -"This could take a while to fully process depending on how many records you " -"have in your database, so please be patient and wait for the script to " -"finish." -msgstr "" - -#: ../includes/ot-cleanup-api.php:144 -#, php-format -msgid "" -"%s Your server is running in safe mode. Which means this page will " -"automatically reload after deleting %s posts, you can filter this number " -"using %s if your server is having trouble processing that many at one time." -msgstr "" - -#: ../includes/ot-cleanup-api.php:146 -msgid "Consolidate Posts" -msgstr "" - -#: ../includes/ot-cleanup-api.php:174 -msgid "Reloading..." -msgstr "" - -#: ../includes/ot-cleanup-api.php:210 -msgid "Clean up script has completed, the page will now reload..." -msgstr "" - -#: ../includes/ot-cleanup-api.php:230 -msgid "Outdated Table" -msgstr "" - -#: ../includes/ot-cleanup-api.php:232 -#, php-format -msgid "" -"If you have upgraded from an old 1.x version of OptionTree at some point, " -"you have an extra %s table in your database that can be removed. It's not " -"hurting anything, but does not need to be there. If you want to remove it. " -"Click the button below." -msgstr "" - -#: ../includes/ot-cleanup-api.php:234 -msgid "Drop Table" -msgstr "" - -#: ../includes/ot-cleanup-api.php:238 -#, php-format -msgid "Deleting the outdated and unused %s table..." -msgstr "" - -#: ../includes/ot-cleanup-api.php:244 -#, php-format -msgid "The %s table has been successfully deleted. The page will now reload..." -msgstr "" - -#: ../includes/ot-cleanup-api.php:256 -#, php-format -msgid "Something went wrong. The %s table was not deleted." -msgstr "" - -#: ../includes/ot-functions-admin.php:50 ../includes/ot-functions-admin.php:51 -#: ../includes/ot-functions-admin.php:169 -#: ../includes/ot-functions-admin.php:193 ../includes/ot-functions.php:388 -msgid "Theme Options" -msgstr "" - -#: ../includes/ot-functions-admin.php:56 -#: ../includes/ot-functions-admin.php:126 -#: ../includes/ot-functions-admin.php:220 -msgid "Theme Options updated." -msgstr "" - -#: ../includes/ot-functions-admin.php:57 -#: ../includes/ot-functions-admin.php:127 -#: ../includes/ot-functions-admin.php:221 -msgid "Theme Options reset." -msgstr "" - -#: ../includes/ot-functions-admin.php:58 -#: ../includes/ot-functions-settings-page.php:94 -#: ../includes/ot-functions-settings-page.php:133 -msgid "Save Changes" -msgstr "" - -#: ../includes/ot-functions-admin.php:97 -msgid "" -"The Theme Options UI Builder is being overridden by a custom file in your " -"theme. Any changes you make via the UI Builder will not be saved." -msgstr "" - -#: ../includes/ot-functions-admin.php:109 -#: ../includes/ot-functions-admin.php:110 -#: ../includes/ot-functions-docs-page.php:821 -msgid "OptionTree" -msgstr "" - -#: ../includes/ot-functions-admin.php:120 -#: ../includes/ot-functions-admin.php:121 -#: ../includes/ot-functions-admin.php:163 -#: ../includes/ot-functions-admin.php:187 -#: ../includes/ot-functions-docs-page.php:49 -msgid "Settings" -msgstr "" - -#: ../includes/ot-functions-admin.php:128 -#: ../includes/ot-functions-admin.php:222 -msgid "Save Settings" -msgstr "" - -#: ../includes/ot-functions-admin.php:133 -msgid "Theme Options UI" -msgstr "" - -#: ../includes/ot-functions-admin.php:137 -msgid "Import" -msgstr "" - -#: ../includes/ot-functions-admin.php:141 -msgid "Export" -msgstr "" - -#: ../includes/ot-functions-admin.php:145 -#: ../includes/ot-functions-admin.php:175 -#: ../includes/ot-functions-admin.php:199 -msgid "Layouts" -msgstr "" - -#: ../includes/ot-functions-admin.php:151 -msgid "Theme Options UI Builder" -msgstr "" - -#: ../includes/ot-functions-admin.php:157 -msgid "Settings XML" -msgstr "" - -#: ../includes/ot-functions-admin.php:181 -msgid "Settings PHP File" -msgstr "" - -#: ../includes/ot-functions-admin.php:205 -msgid "Layout Management" -msgstr "" - -#: ../includes/ot-functions-admin.php:214 -#: ../includes/ot-functions-admin.php:215 -msgid "Documentation" -msgstr "" - -#: ../includes/ot-functions-admin.php:227 -msgid "Creating Options" -msgstr "" - -#: ../includes/ot-functions-admin.php:231 -msgid "Option Types" -msgstr "" - -#: ../includes/ot-functions-admin.php:235 -msgid "Function References" -msgstr "" - -#: ../includes/ot-functions-admin.php:239 -#: ../includes/ot-functions-admin.php:281 -#: ../includes/ot-functions-settings-page.php:366 -msgid "Theme Mode" -msgstr "" - -#: ../includes/ot-functions-admin.php:243 -#: ../includes/ot-functions-admin.php:287 -msgid "Meta Boxes" -msgstr "" - -#: ../includes/ot-functions-admin.php:247 -msgid "Code Examples" -msgstr "" - -#: ../includes/ot-functions-admin.php:251 -msgid "Layouts Overview" -msgstr "" - -#: ../includes/ot-functions-admin.php:257 -msgid "Overview of available Theme Option fields." -msgstr "" - -#: ../includes/ot-functions-admin.php:263 -msgid "Option types in alphabetical order & hooks to filter them." -msgstr "" - -#: ../includes/ot-functions-admin.php:269 -msgid "Function Reference:ot_get_option()" -msgstr "" - -#: ../includes/ot-functions-admin.php:275 -msgid "Function Reference:get_option_tree()" -msgstr "" - -#: ../includes/ot-functions-admin.php:293 -msgid "Code examples for front-end development." -msgstr "" - -#: ../includes/ot-functions-admin.php:299 -msgid "What's a layout anyhow?" -msgstr "" - -#: ../includes/ot-functions-admin.php:502 -#: ../includes/ot-functions-admin.php:604 -#: ../includes/ot-functions-admin.php:673 -#, php-format -msgid "The %s input field for %s only allows numeric values." -msgstr "" - -#: ../includes/ot-functions-admin.php:563 -#, php-format -msgid "The %s Colorpicker only allows valid hexadecimal or rgba values." -msgstr "" - -#: ../includes/ot-functions-admin.php:847 -#: ../includes/ot-functions-docs-page.php:398 -#: ../includes/ot-functions-settings-page.php:170 ../ot-loader.php:785 -msgid "Send to OptionTree" -msgstr "" - -#: ../includes/ot-functions-admin.php:848 -#: ../includes/ot-functions-option-types.php:257 -#: ../includes/ot-functions-option-types.php:3218 -msgid "Remove Media" -msgstr "" - -#: ../includes/ot-functions-admin.php:849 -msgid "Are you sure you want to reset back to the defaults?" -msgstr "" - -#: ../includes/ot-functions-admin.php:850 -msgid "You can't remove this! But you can edit the values." -msgstr "" - -#: ../includes/ot-functions-admin.php:851 -msgid "Are you sure you want to remove this?" -msgstr "" - -#: ../includes/ot-functions-admin.php:852 -msgid "Are you sure you want to activate this layout?" -msgstr "" - -#: ../includes/ot-functions-admin.php:853 -msgid "Sorry, you can't have settings three levels deep." -msgstr "" - -#: ../includes/ot-functions-admin.php:854 -#: ../includes/ot-functions-option-types.php:1159 -msgid "Delete Gallery" -msgstr "" - -#: ../includes/ot-functions-admin.php:855 -#: ../includes/ot-functions-option-types.php:1160 -msgid "Edit Gallery" -msgstr "" - -#: ../includes/ot-functions-admin.php:856 -#: ../includes/ot-functions-option-types.php:1167 -msgid "Create Gallery" -msgstr "" - -#: ../includes/ot-functions-admin.php:857 -msgid "Are you sure you want to delete this Gallery?" -msgstr "" - -#: ../includes/ot-functions-admin.php:858 -msgid "Today" -msgstr "" - -#: ../includes/ot-functions-admin.php:859 -msgid "Now" -msgstr "" - -#: ../includes/ot-functions-admin.php:860 -msgid "Close" -msgstr "" - -#: ../includes/ot-functions-admin.php:861 -msgid "Featured Image" -msgstr "" - -#: ../includes/ot-functions-admin.php:862 -#: ../includes/ot-functions-admin.php:3251 -#: ../includes/ot-functions-admin.php:3312 -msgid "Image" -msgstr "" - -#: ../includes/ot-functions-admin.php:930 -msgid "Option Tree" -msgstr "" - -#: ../includes/ot-functions-admin.php:1068 -msgid "General" -msgstr "" - -#: ../includes/ot-functions-admin.php:1074 -msgid "Sample Text Field Label" -msgstr "" - -#: ../includes/ot-functions-admin.php:1075 -msgid "Description for the sample text field." -msgstr "" - -#: ../includes/ot-functions-admin.php:2317 -msgid "Settings updated." -msgstr "" - -#: ../includes/ot-functions-admin.php:2321 -msgid "Settings could not be saved." -msgstr "" - -#: ../includes/ot-functions-admin.php:2329 -msgid "Settings Imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2333 -msgid "Settings could not be imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2340 -msgid "Data Imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2344 -msgid "Data could not be imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2352 -msgid "Layouts Imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2356 -msgid "Layouts could not be imported." -msgstr "" - -#: ../includes/ot-functions-admin.php:2364 -msgid "Layouts Updated." -msgstr "" - -#: ../includes/ot-functions-admin.php:2368 -msgid "Layouts could not be updated." -msgstr "" - -#: ../includes/ot-functions-admin.php:2372 -msgid "Layouts have been deleted." -msgstr "" - -#: ../includes/ot-functions-admin.php:2378 -msgid "Layout activated." -msgstr "" - -#: ../includes/ot-functions-admin.php:2417 -#: ../includes/ot-functions-docs-page.php:110 -msgid "Background" -msgstr "" - -#: ../includes/ot-functions-admin.php:2418 -#: ../includes/ot-functions-docs-page.php:113 -msgid "Border" -msgstr "" - -#: ../includes/ot-functions-admin.php:2419 -#: ../includes/ot-functions-docs-page.php:116 -msgid "Box Shadow" -msgstr "" - -#: ../includes/ot-functions-admin.php:2420 -#: ../includes/ot-functions-docs-page.php:119 -msgid "Category Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2421 -#: ../includes/ot-functions-docs-page.php:122 -msgid "Category Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2422 -#: ../includes/ot-functions-docs-page.php:125 -msgid "Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2423 -#: ../includes/ot-functions-docs-page.php:128 -msgid "Colorpicker" -msgstr "" - -#: ../includes/ot-functions-admin.php:2424 -#: ../includes/ot-functions-docs-page.php:131 -msgid "Colorpicker Opacity" -msgstr "" - -#: ../includes/ot-functions-admin.php:2425 -#: ../includes/ot-functions-docs-page.php:134 -msgid "CSS" -msgstr "" - -#: ../includes/ot-functions-admin.php:2426 -#: ../includes/ot-functions-docs-page.php:153 -msgid "Custom Post Type Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2427 -#: ../includes/ot-functions-docs-page.php:156 -msgid "Custom Post Type Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2428 -#: ../includes/ot-functions-docs-page.php:159 -msgid "Date Picker" -msgstr "" - -#: ../includes/ot-functions-admin.php:2429 -#: ../includes/ot-functions-docs-page.php:162 -msgid "Date Time Picker" -msgstr "" - -#: ../includes/ot-functions-admin.php:2430 -#: ../includes/ot-functions-docs-page.php:165 -msgid "Dimension" -msgstr "" - -#: ../includes/ot-functions-admin.php:2431 -#: ../includes/ot-functions-admin.php:5466 -#: ../includes/ot-functions-docs-page.php:168 -msgid "Gallery" -msgstr "" - -#: ../includes/ot-functions-admin.php:2432 -#: ../includes/ot-functions-docs-page.php:171 -msgid "Google Fonts" -msgstr "" - -#: ../includes/ot-functions-admin.php:2433 -#: ../includes/ot-functions-docs-page.php:174 -msgid "JavaScript" -msgstr "" - -#: ../includes/ot-functions-admin.php:2434 -#: ../includes/ot-functions-docs-page.php:177 -msgid "Link Color" -msgstr "" - -#: ../includes/ot-functions-admin.php:2435 -#: ../includes/ot-functions-docs-page.php:180 -msgid "List Item" -msgstr "" - -#: ../includes/ot-functions-admin.php:2436 -#: ../includes/ot-functions-docs-page.php:183 -msgid "Measurement" -msgstr "" - -#: ../includes/ot-functions-admin.php:2437 -#: ../includes/ot-functions-docs-page.php:214 -msgid "Numeric Slider" -msgstr "" - -#: ../includes/ot-functions-admin.php:2438 -#: ../includes/ot-functions-docs-page.php:217 -msgid "On/Off" -msgstr "" - -#: ../includes/ot-functions-admin.php:2439 -#: ../includes/ot-functions-docs-page.php:220 -msgid "Page Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2440 -#: ../includes/ot-functions-docs-page.php:223 -msgid "Page Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2441 -#: ../includes/ot-functions-docs-page.php:226 -msgid "Post Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2442 -#: ../includes/ot-functions-docs-page.php:229 -msgid "Post Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2443 -#: ../includes/ot-functions-docs-page.php:232 -msgid "Radio" -msgstr "" - -#: ../includes/ot-functions-admin.php:2444 -#: ../includes/ot-functions-docs-page.php:235 -msgid "Radio Image" -msgstr "" - -#: ../includes/ot-functions-admin.php:2445 -#: ../includes/ot-functions-docs-page.php:262 -msgid "Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2446 -#: ../includes/ot-functions-docs-page.php:265 -msgid "Sidebar Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2447 -#: ../includes/ot-functions-docs-page.php:269 -msgid "Slider" -msgstr "" - -#: ../includes/ot-functions-admin.php:2448 -#: ../includes/ot-functions-docs-page.php:272 -msgid "Social Links" -msgstr "" - -#: ../includes/ot-functions-admin.php:2449 -#: ../includes/ot-functions-docs-page.php:275 -msgid "Spacing" -msgstr "" - -#: ../includes/ot-functions-admin.php:2450 -#: ../includes/ot-functions-docs-page.php:278 -msgid "Tab" -msgstr "" - -#: ../includes/ot-functions-admin.php:2451 -#: ../includes/ot-functions-docs-page.php:281 -msgid "Tag Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2452 -#: ../includes/ot-functions-docs-page.php:284 -msgid "Tag Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2453 -#: ../includes/ot-functions-docs-page.php:287 -msgid "Taxonomy Checkbox" -msgstr "" - -#: ../includes/ot-functions-admin.php:2454 -#: ../includes/ot-functions-docs-page.php:290 -msgid "Taxonomy Select" -msgstr "" - -#: ../includes/ot-functions-admin.php:2455 -#: ../includes/ot-functions-docs-page.php:293 -msgid "Text" -msgstr "" - -#: ../includes/ot-functions-admin.php:2456 -#: ../includes/ot-functions-docs-page.php:296 -msgid "Textarea" -msgstr "" - -#: ../includes/ot-functions-admin.php:2457 -#: ../includes/ot-functions-docs-page.php:355 -msgid "Textarea Simple" -msgstr "" - -#: ../includes/ot-functions-admin.php:2458 -#: ../includes/ot-functions-docs-page.php:371 -msgid "Textblock" -msgstr "" - -#: ../includes/ot-functions-admin.php:2459 -#: ../includes/ot-functions-docs-page.php:374 -msgid "Textblock Titled" -msgstr "" - -#: ../includes/ot-functions-admin.php:2460 -#: ../includes/ot-functions-docs-page.php:377 -msgid "Typography" -msgstr "" - -#: ../includes/ot-functions-admin.php:2461 -#: ../includes/ot-functions-docs-page.php:397 -msgid "Upload" -msgstr "" - -#: ../includes/ot-functions-admin.php:3196 -msgid "Left Sidebar" -msgstr "" - -#: ../includes/ot-functions-admin.php:3201 -msgid "Right Sidebar" -msgstr "" - -#: ../includes/ot-functions-admin.php:3206 -msgid "Full Width (no sidebar)" -msgstr "" - -#: ../includes/ot-functions-admin.php:3211 -msgid "Dual Sidebar" -msgstr "" - -#: ../includes/ot-functions-admin.php:3216 -msgid "Left Dual Sidebar" -msgstr "" - -#: ../includes/ot-functions-admin.php:3221 -msgid "Right Dual Sidebar" -msgstr "" - -#: ../includes/ot-functions-admin.php:3262 -#: ../includes/ot-functions-admin.php:3318 -#: ../includes/ot-functions-admin.php:5506 -msgid "Link" -msgstr "" - -#: ../includes/ot-functions-admin.php:3273 -#: ../includes/ot-functions-admin.php:3324 -#: ../includes/ot-functions-docs-page.php:43 -#: ../includes/ot-functions-docs-page.php:428 -#: ../includes/ot-functions-docs-page.php:478 -msgid "Description" -msgstr "" - -#: ../includes/ot-functions-admin.php:3388 -msgid "Name" -msgstr "" - -#: ../includes/ot-functions-admin.php:3389 -msgid "Enter the name of the social website." -msgstr "" - -#: ../includes/ot-functions-admin.php:3397 -msgid "Enter the text shown in the title attribute of the link." -msgstr "" - -#: ../includes/ot-functions-admin.php:3403 -#, php-format -msgid "" -"Enter a link to the profile or page on the social website. Remember to add " -"the %s part to the front of the link." -msgstr "" - -#: ../includes/ot-functions-admin.php:3756 -#, php-format -msgid "Unable to write to file %s." -msgstr "" - -#: ../includes/ot-functions-admin.php:4026 -msgid "edit" -msgstr "" - -#: ../includes/ot-functions-admin.php:4027 -#: ../includes/ot-functions-admin.php:4095 -#: ../includes/ot-functions-admin.php:4096 -#: ../includes/ot-functions-admin.php:4258 -#: ../includes/ot-functions-admin.php:4259 -#: ../includes/ot-functions-admin.php:4324 -#: ../includes/ot-functions-admin.php:4325 -#: ../includes/ot-functions-admin.php:4452 -#: ../includes/ot-functions-admin.php:4453 -#: ../includes/ot-functions-admin.php:4605 -#: ../includes/ot-functions-admin.php:4606 -msgid "Edit" -msgstr "" - -#: ../includes/ot-functions-admin.php:4029 -#: ../includes/ot-functions-admin.php:4030 -#: ../includes/ot-functions-admin.php:4098 -#: ../includes/ot-functions-admin.php:4099 -#: ../includes/ot-functions-admin.php:4261 -#: ../includes/ot-functions-admin.php:4262 -#: ../includes/ot-functions-admin.php:4327 -#: ../includes/ot-functions-admin.php:4328 -#: ../includes/ot-functions-admin.php:4386 -#: ../includes/ot-functions-admin.php:4387 -#: ../includes/ot-functions-admin.php:4455 -#: ../includes/ot-functions-admin.php:4456 -#: ../includes/ot-functions-admin.php:4608 -#: ../includes/ot-functions-admin.php:4609 -msgid "Delete" -msgstr "" - -#: ../includes/ot-functions-admin.php:4036 -msgid "" -"Section Title: Displayed as a menu item on the Theme " -"Options page." -msgstr "" - -#: ../includes/ot-functions-admin.php:4044 -msgid "" -"Section ID: A unique lower case alphanumeric string, " -"underscores allowed." -msgstr "" - -#: ../includes/ot-functions-admin.php:4105 -msgid "" -"Label: Displayed as the label of a form element on the " -"Theme Options page." -msgstr "" - -#: ../includes/ot-functions-admin.php:4113 -#: ../includes/ot-functions-admin.php:4342 -msgid "" -"ID: A unique lower case alphanumeric string, underscores " -"allowed." -msgstr "" - -#: ../includes/ot-functions-admin.php:4121 -msgid "" -"Type: Choose one of the available option types from the " -"dropdown." -msgstr "" - -#: ../includes/ot-functions-admin.php:4132 -msgid "" -"Description: Enter a detailed description for the users to " -"read on the Theme Options page, HTML is allowed. This is also where you " -"enter content for both the Textblock & Textblock Titled option types." -msgstr "" - -#: ../includes/ot-functions-admin.php:4140 -msgid "" -"Choices: This will only affect the following option types: " -"Checkbox, Radio, Select & Select Image." -msgstr "" - -#: ../includes/ot-functions-admin.php:4145 -msgid "Add Choice" -msgstr "" - -#: ../includes/ot-functions-admin.php:4151 -msgid "" -"Settings: This will only affect the List Item option type." -msgstr "" - -#: ../includes/ot-functions-admin.php:4156 -#: ../includes/ot-functions-settings-page.php:93 -msgid "Add Setting" -msgstr "" - -#: ../includes/ot-functions-admin.php:4162 -msgid "" -"Standard: Setting the standard value for your option only " -"works for some option types. Read the OptionTree->Documentation " -"for more information on which ones." -msgstr "" - -#: ../includes/ot-functions-admin.php:4170 -msgid "" -"Rows: Enter a numeric value for the number of rows in your " -"textarea. This will only affect the following option types: CSS, Textarea, & " -"Textarea Simple." -msgstr "" - -#: ../includes/ot-functions-admin.php:4178 -msgid "" -"Post Type: Add a comma separated list of post type like " -"'post,page'. This will only affect the following option types: Custom Post " -"Type Checkbox, & Custom Post Type Select." -msgstr "" - -#: ../includes/ot-functions-admin.php:4186 -msgid "" -"Taxonomy: Add a comma separated list of any registered " -"taxonomy like 'category,post_tag'. This will only affect the following " -"option types: Taxonomy Checkbox, & Taxonomy Select." -msgstr "" - -#: ../includes/ot-functions-admin.php:4194 -msgid "" -"Min, Max, & Step: Add a comma separated list of options in " -"the following format 0,100,1 (slide from 0-100 in " -"intervals of 1). The three values represent the minimum, " -"maximum, and step options and will only affect the Numeric Slider option " -"type." -msgstr "" - -#: ../includes/ot-functions-admin.php:4202 -msgid "CSS Class: Add and optional class to this option type." -msgstr "" - -#: ../includes/ot-functions-admin.php:4210 -#, php-format -msgid "" -"Condition: Add a comma separated list (no spaces) of " -"conditions in which the field will be visible, leave this setting empty to " -"always show the field. In these examples, value is a " -"placeholder for your condition, which can be in the form of %s." -msgstr "" - -#: ../includes/ot-functions-admin.php:4218 -msgid "" -"Operator: Choose the logical operator to compute the result " -"of the conditions." -msgstr "" - -#: ../includes/ot-functions-admin.php:4221 -#: ../includes/ot-functions-docs-page.php:111 -#: ../includes/ot-functions-docs-page.php:378 -msgid "and" -msgstr "" - -#: ../includes/ot-functions-admin.php:4222 -msgid "or" -msgstr "" - -#: ../includes/ot-functions-admin.php:4268 -#: ../includes/ot-functions-docs-page.php:29 -msgid "Label" -msgstr "" - -#: ../includes/ot-functions-admin.php:4278 -msgid "Value" -msgstr "" - -#: ../includes/ot-functions-admin.php:4288 -msgid "Image Source (Radio Image only)" -msgstr "" - -#: ../includes/ot-functions-admin.php:4334 -msgid "" -"Title: Displayed as a contextual help menu item on the " -"Theme Options page." -msgstr "" - -#: ../includes/ot-functions-admin.php:4350 -msgid "" -"Content: Enter the HTML content about this contextual help " -"item displayed on the Theme Option page for end users to read." -msgstr "" - -#: ../includes/ot-functions-admin.php:4381 -msgid "Layout" -msgstr "" - -#: ../includes/ot-functions-admin.php:4383 -#: ../includes/ot-functions-admin.php:4384 -msgid "Activate" -msgstr "" - -#: ../includes/ot-functions-admin.php:4420 ../includes/ot-meta-box-api.php:231 -#: ../includes/ot-settings-api.php:610 -msgid "Title" -msgstr "" - -#: ../includes/ot-functions-admin.php:4760 -msgid "New Layout" -msgstr "" - -#: ../includes/ot-functions-admin.php:5515 -msgid "Link URL" -msgstr "" - -#: ../includes/ot-functions-admin.php:5522 -msgid "Link Title" -msgstr "" - -#: ../includes/ot-functions-admin.php:5552 -msgid "Quote" -msgstr "" - -#: ../includes/ot-functions-admin.php:5561 -msgid "Source Name (ex. author, singer, actor)" -msgstr "" - -#: ../includes/ot-functions-admin.php:5568 -msgid "Source URL" -msgstr "" - -#: ../includes/ot-functions-admin.php:5575 -msgid "Source Title (ex. book, song, movie)" -msgstr "" - -#: ../includes/ot-functions-admin.php:5582 -msgid "Source Date" -msgstr "" - -#: ../includes/ot-functions-admin.php:5612 -msgid "Video" -msgstr "" - -#: ../includes/ot-functions-admin.php:5621 -#, php-format -msgid "" -"Embed video from services like Youtube, Vimeo, or Hulu. You can find a list " -"of supported oEmbed sites in the %1$s. Alternatively, you could use the " -"built-in %2$s shortcode." -msgstr "" - -#: ../includes/ot-functions-admin.php:5621 -#: ../includes/ot-functions-admin.php:5660 -msgid "Wordpress Codex" -msgstr "" - -#: ../includes/ot-functions-admin.php:5651 -msgid "Audio" -msgstr "" - -#: ../includes/ot-functions-admin.php:5660 -#, php-format -msgid "" -"Embed audio from services like SoundCloud and Rdio. You can find a list of " -"supported oEmbed sites in the %1$s. Alternatively, you could use the built-" -"in %2$s shortcode." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:30 -msgid "" -"The Label field should be a short but descriptive block of text 100 " -"characters or less with no HTML." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:32 -msgid "ID" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:33 -msgid "" -"The ID field is a unique alphanumeric key used to differentiate each theme " -"option (underscores are acceptable). Also, the plugin will change all text " -"you write in this field to lowercase and replace spaces and special " -"characters with an underscore automatically." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:35 -msgid "Type" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:36 -msgid "" -"You are required to choose one of the supported option types when creating a " -"new option. Here is a list of the available option types. For more " -"information about each type click the Option Types tab to the " -"left." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:44 -msgid "" -"Enter a detailed description for the users to read on the Theme Options " -"page, HTML is allowed. This is also where you enter content for both the " -"Textblock & Textblock Titled option types." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:46 -msgid "Choices" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:47 -msgid "" -"Click the \"Add Choice\" button to add an item to the choices array. This " -"will only affect the following option types: Checkbox, Radio, Select & " -"Select Image." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:50 -msgid "" -"Click the \"Add Setting\" button found inside a newly created setting to add " -"an item to the settings array. This will only affect the List Item type." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:52 -msgid "Standard" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:53 -msgid "" -"Setting the standard value for your option only works for some option types. " -"Those types are one that have a single string value saved to them and not an " -"array of values." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:55 -msgid "Rows" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:56 -msgid "" -"Enter a numeric value for the number of rows in your textarea. This will " -"only affect the following option types: CSS, Textarea, & Textarea Simple." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:58 -msgid "Post Type" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:59 -msgid "" -"Add a comma separated list of post type like post,page. This " -"will only affect the following option types: Custom Post Type Checkbox, & " -"Custom Post Type Select. Below are the default post types available with " -"WordPress and that are also compatible with OptionTree. You can also add " -"your own custom post_type. At this time any does " -"not seem to return results properly and is something I plan on looking into." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:67 -msgid "Taxonomy" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:68 -msgid "" -"Add a comma separated list of any registered taxonomy like category," -"post_tag. This will only affect the following option types: Taxonomy " -"Checkbox, & Taxonomy Select." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:70 -msgid "Min, Max, & Step" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:71 -msgid "" -"Add a comma separated list of options in the following format 0,100,1 (slide from 0-100 in intervals of 1). The " -"three values represent the minimum, maximum, and step options and will only " -"affect the Numeric Slider option type." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:73 -msgid "CSS Class" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:74 -msgid "Add and optional class to any option type." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:76 -msgid "Condition" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:77 -#, php-format -msgid "" -"Add a comma separated list (no spaces) of conditions in which the field will " -"be visible, leave this setting empty to always show the field. In these " -"examples, %s is a placeholder for your condition, which can be in the form " -"of %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:79 -msgid "Operator" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:80 -#, php-format -msgid "" -"Choose the logical operator to compute the result of the conditions. Your " -"options are %s and %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:111 -#, php-format -msgid "" -"The Background option type is for adding background styles to your theme " -"either dynamically via the CSS option type below or manually with %s. The " -"Background option type has filters that allow you to remove fields or change " -"the defaults. For example, you can filter %s to remove unwanted fields from " -"all Background options or an individual one. You can also filter %s. These " -"filters allow you to fine tune the select lists for your specific needs." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:114 -#, php-format -msgid "" -"The Border option type is used to set width, unit, style, and color values. " -"The text input excepts a numerical value and the unit select lets you choose " -"the unit of measurement to add to that value. Currently the default units " -"are %s, %s, %s, and %s. However, you can change them with the %s filter. The " -"style select lets you choose the border style. The default styles are %s, " -"%s, %s, %s, %s, %s, %s, and %s. However, you can change them with the %s " -"filter. The colorpicker saves a hexadecimal color code." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:117 -#, php-format -msgid "" -"The Box Shadow option type is used to set %s, %s, %s, %s, %s, and %s values." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:120 -msgid "" -"The Category Checkbox option type displays a list of category IDs. It allows " -"the user to check multiple category IDs and will return that value as an " -"array for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:123 -msgid "" -"The Category Select option type displays a list of category IDs. It allows " -"the user to select only one category ID and will return that value for use " -"in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:126 -msgid "" -"The Checkbox option type displays a group of choices. It allows the user to " -"check multiple choices and will return that value as an array for use in a " -"custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:129 -msgid "" -"The Colorpicker option type saves a hexadecimal color code for use in CSS. " -"Use it to modify the color of something in your theme." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:132 -#, php-format -msgid "" -"The Colorpicker Opacity option type saves a hexadecimal color code with an " -"opacity value from %s to %s in increments of %s. Though the value is saved " -"as hexadecimal, if used within the CSS option type the color and opacity " -"values will be converted into a valid RGBA CSS value." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:135 -#, php-format -msgid "" -"The CSS option type is a textarea that when used properly can add dynamic " -"CSS to your theme from within OptionTree. Unfortunately, due server " -"limitations you will need to create a file named %s at the root level of " -"your theme and change permissions using %s so the server can write to the " -"file. I have had the most success setting this single file to %s but feel " -"free to play around with permissions until everything is working. A good " -"starting point is %s. When the server can save to the file, CSS will " -"automatically be updated when you save your Theme Options." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:137 -#, php-format -msgid "" -"This example assumes you have an option with the ID of %1$s. Which means " -"this option will automatically insert the value of %1$s into the %2$s when " -"the Theme Options are saved." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:139 -msgid "Input" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:145 -msgid "Output" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:154 -#, php-format -msgid "" -"The Custom Post Type Select option type displays a list of IDs from any " -"available WordPress post type or custom post type. It allows the user to " -"check multiple post IDs for use in a custom function or loop. Requires at " -"least one valid %1$s in the %1$s field." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:157 -#, php-format -msgid "" -"The Custom Post Type Select option type displays a list of IDs from any " -"available WordPress post type or custom post type. It will return a single " -"post ID for use in a custom function or loop. Requires at least one valid " -"%1$s in the %1$s field." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:160 -msgid "" -"The Date Picker option type is tied to a standard form input field which " -"displays a calendar pop-up that allow the user to pick any date when focus " -"is given to the input field. The returned value is a date formatted string." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:163 -msgid "" -"The Date Time Picker option type is tied to a standard form input field " -"which displays a calendar pop-up that allow the user to pick any date and " -"time when focus is given to the input field. The returned value is a date " -"and time formatted string." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:166 -#, php-format -msgid "" -"The Dimension option type is used to set width and height values. The text " -"inputs except numerical values and the select lets you choose the unit of " -"measurement to add to that value. Currently the default units are %s, %s, " -"%s, and %s. However, you can change them with the %s filter." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:169 -msgid "" -"The Gallery option type saves a comma separated list of image attachment " -"IDs. You will need to create a front-end function to display the images in " -"your theme." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:172 -#, php-format -msgid "" -"The Google Fonts option type will dynamically enqueue any number of Google " -"Web Fonts into the document %1$s. As well, once the option has been saved " -"each font family will automatically be inserted into the %2$s array for the " -"Typography option type. You can further modify the font stack by using the " -"%3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s " -"parameter is being passed from %7$s, so it will be the ID of a Typography " -"option type. This will allow you to add additional web safe fonts to " -"individual font families on an as-need basis." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:175 -#, php-format -msgid "" -"The JavaScript option type is a textarea that uses the %s code editor to " -"highlight your JavaScript and display errors as you type." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:178 -msgid "The Link Color option type is used to set all link color states." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:181 -msgid "" -"The List Item option type replaced the Slider option type and allows for a " -"great deal of customization. You can add settings to the List Item and those " -"settings will be displayed to the user when they add a new List Item. " -"Typical use is for creating sliding content or blocks of code for custom " -"layouts." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:184 -#, php-format -msgid "" -"The Measurement option type is a mix of input and select fields. The text " -"input excepts a value and the select lets you choose the unit of measurement " -"to add to that value. Currently the default units are %s, %s, %s, and %s. " -"However, you can change them with the %s filter." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:186 -#, php-format -msgid "" -"Example filter to add new units to the Measurement option type. Added to %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:199 -msgid "" -"Example filter to completely change the units in the Measurement option " -"type. Added to functions.php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:215 -msgid "" -"The Numeric Slider option type displays a jQuery UI slider. It will return a " -"single numerical value for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:218 -#, php-format -msgid "" -"The On/Off option type displays a simple switch that can be used to turn " -"things on or off. The saved return value is either %s or %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:221 -msgid "" -"The Page Checkbox option type displays a list of page IDs. It allows the " -"user to check multiple page IDs for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:224 -msgid "" -"The Page Select option type displays a list of page IDs. It will return a " -"single page ID for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:227 -msgid "" -"The Post Checkbox option type displays a list of post IDs. It allows the " -"user to check multiple post IDs for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:230 -msgid "" -"The Post Select option type displays a list of post IDs. It will return a " -"single post ID for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:233 -msgid "" -"The Radio option type displays a group of choices. It allows the user to " -"choose one and will return that value as a string for use in a custom " -"function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:236 -#, php-format -msgid "" -"the Radio Images option type is primarily used for layouts. However, you can " -"filter the image list using %s. As well, you can add your own custom images " -"using the choices array." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:238 -msgid "" -"This example executes the ot_radio_images filter on layout " -"images attached to the my_radio_images field. Added to " -"functions.php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:263 -msgid "" -"The Select option type is used to list anything you want that would be " -"chosen from a select list." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:266 -#, php-format -msgid "" -"This option type makes it possible for users to select a WordPress " -"registered sidebar to use on a specific area. By using the two provided " -"filters, %s, and %s we can be selective about which sidebars are available " -"on a specific content area." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:267 -#, php-format -msgid "" -"For example, if we create a WordPress theme that provides the ability to " -"change the Blog Sidebar and we don't want to have the footer sidebars " -"available on this area, we can unset those sidebars either manually or by " -"using a regular expression if we have a common name like %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:270 -msgid "" -"The Slider option type is technically deprecated. Use the List Item option " -"type instead, as it's infinitely more customizable. Typical use is for " -"creating sliding image content." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:273 -#, php-format -msgid "" -"The Social Links option type utilizes a drag & drop interface to create a " -"list of social links. There are a few filters that make extending this " -"option type easy. You can set the %s filter to %s and turn off loading " -"default values. Use the %s filter to change the default values that are " -"loaded. To filter the settings array use the %s filter." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:276 -#, php-format -msgid "" -"The Spacing option type is used to set spacing values such as padding or " -"margin in the form of top, right, bottom, and left. The text inputs except " -"numerical values and the select lets you choose the unit of measurement to " -"add to that value. Currently the default units are %s, %s, %s, and %s. " -"However, you can change them with the %s filter." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:279 -msgid "" -"The Tab option type will break a section or metabox into tabbed content." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:282 -msgid "" -"The Tag Checkbox option type displays a list of tag IDs. It allows the user " -"to check multiple tag IDs and will return that value as an array for use in " -"a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:285 -msgid "" -"The Tag Select option type displays a list of tag IDs. It allows the user to " -"select only one tag ID and will return that value for use in a custom " -"function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:288 -msgid "" -"The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows " -"the user to check multiple taxonomy IDs and will return that value as an " -"array for use in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:291 -msgid "" -"The Taxonomy Select option type displays a list of taxonomy IDs. It allows " -"the user to select only one taxonomy ID and will return that value for use " -"in a custom function or loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:294 -msgid "" -"The Text option type is used to save string values. For example, any " -"optional or required text that is of reasonably short character length." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:297 -#, php-format -msgid "" -"The Textarea option type is a large string value used for custom code or " -"text in the theme and has a WYSIWYG editor that can be filtered to change " -"the how it is displayed. For example, you can filter %s, %s, %s, and %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:299 -msgid "" -"Example filters to alter the Textarea option type. Added to functions." -"php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:301 -msgid "" -"This example keeps WordPress from executing the wpautop filter " -"on the line breaks. The default is true which means it wraps " -"line breaks with an HTML p tag." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:314 -msgid "" -"This example keeps WordPress from executing the media_buttons " -"filter on the textarea WYSIWYG. The default is true which means " -"show the buttons." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:327 -msgid "" -"This example keeps WordPress from executing the tinymce filter " -"on the textarea WYSIWYG. The default is true which means show " -"the tinymce." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:340 -msgid "" -"This example alters the quicktags filter on the textarea " -"WYSIWYG. The default is array( 'buttons' => 'strong,em,link,block,del," -"ins,img,ul,ol,li,code,spell,close' ) which means show those " -"quicktags. It also means you can filter in your own custom quicktags." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:356 -msgid "" -"The Textarea Simple option type is a large string value used for custom code " -"or text in the theme. The Textarea Simple does not have a WYSIWYG editor." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:358 -#, php-format -msgid "" -"This example tells WordPress to execute the %s filter on the line breaks. " -"The default is %s which means it does not wraps line breaks with an HTML %s " -"tag. Added to %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:372 -msgid "" -"The Textblock option type is used only on the Theme Option page. It will " -"allow you to create & display HTML, but has no title above the text block. " -"You can then use the Textblock to add a more detailed set of instruction on " -"how the options are used in your theme. You would never use this in your " -"themes template files as it does not save a value." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:375 -msgid "" -"The Textblock Titled option type is used only on the Theme Option page. It " -"will allow you to create & display HTML, and has a title above the text " -"block. You can then use the Textblock Titled to add a more detailed set of " -"instruction on how the options are used in your theme. You would never use " -"this in your themes template files as it does not save a value." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:378 -#, php-format -msgid "" -"The Typography option type is for adding typography styles to your theme " -"either dynamically via the CSS option type above or manually with %s. The " -"Typography option type has filters that allow you to remove fields or change " -"the defaults. For example, you can filter %s to remove unwanted fields from " -"all Background options or an individual one. You can also filter %s. These " -"filters allow you to fine tune the select lists for your specific needs." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:380 -msgid "" -"This example would filter ot_recognized_font_families to build " -"your own font stack. Added to functions.php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:398 -#, php-format -msgid "" -"The Upload option type is used to upload any WordPress supported media. " -"After uploading, users are required to press the \"%s\" button in order to " -"populate the input with the URI of that media. There is one caveat of this " -"feature. If you import the theme options and have uploaded media on one site " -"the old URI will not reflect the URI of your new site. You will have to re-" -"upload or %s any media to your new server and change the URIs if necessary." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:430 -msgid "" -"This function returns a value from the \"option_tree\" array of saved values " -"or the default value supplied. The returned value would be mixed. Meaning it " -"could be a string, integer, boolean, or array." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:432 -#: ../includes/ot-functions-docs-page.php:482 -msgid "Usage" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:436 -#: ../includes/ot-functions-docs-page.php:486 -msgid "Parameters" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:490 -msgid "string" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:490 -msgid "required" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:440 -msgid "Enter the options unique identifier." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:490 -msgid "Default:" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:440 -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:490 -#: ../includes/ot-functions-docs-page.php:494 -msgid "None" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:494 -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -#: ../includes/ot-functions-docs-page.php:506 -msgid "optional" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:444 -msgid "" -"Enter a default return value. This is just incase the request returns null." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:444 -#: ../includes/ot-functions-docs-page.php:494 -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -#: ../includes/ot-functions-docs-page.php:506 -msgid "Default" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:474 -msgid "" -"This function has been deprecated. That means it has been replaced by a new " -"function or is no longer supported, and may be removed from future versions. " -"All code that uses this function should be converted to use its replacement." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:476 -msgid "Use" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:476 -msgid "instead" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:480 -msgid "" -"This function returns, or echos if asked, a value from the \"option_tree\" " -"array of saved values." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:490 -msgid "Enter a unique Option Key to get a returned value or array." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:494 -msgid "array" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:494 -msgid "Used to cut down on database queries in template files." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:498 -#: ../includes/ot-functions-docs-page.php:502 -msgid "boolean" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:498 -msgid "Echo the output." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:502 -msgid "Used to indicate the $item_id is an array of values." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:506 -msgid "integer" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:506 -msgid "" -"Numeric offset key for the $item_id array, -1 will return all values (an " -"array starts at 0)." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:534 -msgid "" -"If you're using the plugin version of OptionTree it is highly recommended to " -"include a function_exists check in your code, as described in " -"the examples below. If you've integrated OptionTree directly into your " -"themes root directory, you will not need to wrap your code " -"with function_exists, as you're guaranteed to have the " -"ot_get_option() function available." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:536 -msgid "String Examples" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:538 -msgid "Returns the value of test_input." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:544 -msgid "" -"Returns the value of test_input, but also has a default value " -"if it returns empty." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:550 -msgid "Array Examples" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:552 -msgid "" -"Assigns the value of navigation_ids to the variable $ids. It then echos an unordered list of links (navigation) using " -"wp_list_pages()." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:572 -msgid "" -"The next two examples demonstrate how to use the Measurement option type. The Measurement option type is an array with two key/" -"value pairs. The first is the value of measurement and the second is the " -"unit of measurement." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:598 -msgid "This example displays a very basic slider loop." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:643 -msgid "It's Super Simple" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:645 -msgid "" -"Layouts make your theme awesome! With theme options data that you can save/" -"import/export you can package themes with different color variations, or " -"make it easy to do A/B testing on text and so much more. Basically, you save " -"a snapshot of your data as a layout." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:647 -msgid "" -"Once you have created all your different layouts, or theme variations, you " -"can save them to a separate text file for repackaging with your theme. " -"Alternatively, you could just make different variations for yourself and " -"change your theme with the click of a button, all without deleting your " -"previous options data." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:649 -msgid "" -" Adding a layout is ridiculously easy, follow these steps and you'll be on " -"your way to having a WordPress super theme." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:651 -msgid "For Developers" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:653 -#: ../includes/ot-functions-docs-page.php:682 -msgid "Creating a Layout" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:655 -#: ../includes/ot-functions-docs-page.php:662 -#: ../includes/ot-functions-docs-page.php:668 -msgid "Go to the OptionTre->Settings->Layouts tab." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:656 -msgid "" -"Enter a name for your layout in the text field and hit \"Save Layouts\", " -"you've created your first layout." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:657 -#: ../includes/ot-functions-docs-page.php:686 -msgid "Adding a new layout is as easy as repeating the steps above." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:660 -#: ../includes/ot-functions-docs-page.php:689 -msgid "Activating a Layout" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:663 -msgid "Click on the activate layout button in the actions list." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:666 -#: ../includes/ot-functions-docs-page.php:695 -msgid "Deleting a Layout" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:669 -msgid "Click on the delete layout button in the actions list." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:672 -#: ../includes/ot-functions-docs-page.php:700 -msgid "Edit Layout Data" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:674 -#: ../includes/ot-functions-docs-page.php:684 -#: ../includes/ot-functions-docs-page.php:691 -msgid "Go to the Appearance->Theme Options page." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:675 -#: ../includes/ot-functions-docs-page.php:703 -msgid "" -"Modify and save your theme options and the layout will be updated " -"automatically." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:676 -#: ../includes/ot-functions-docs-page.php:704 -msgid "" -"Saving theme options data will update the currently active layout, so before " -"you start saving make sure you want to modify the current layout." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:677 -msgid "" -"If you want to edit a new layout, first create it then save your theme " -"options." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:680 -msgid "End-Users Mode" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:685 -msgid "" -"Enter a name for your layout in the text field and hit \"New Layout\", " -"you've created your first layout." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:692 -msgid "" -"Choose a layout from the select list and click the \"Activate Layout\" " -"button." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:697 -msgid "End-Users mode does not allow deleting layouts." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:702 -msgid "Go to the Appearance->Theme Options tab." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:733 -#: ../includes/ot-functions-docs-page.php:815 -msgid "How-to-guide" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:735 -msgid "" -"There are a few simple steps you need to take in order to use OptionTree's " -"built in Meta Box API. In the code below I'll show you a basic demo of how " -"to create your very own custom meta box using any number of the option types " -"you have at your disposal. If you would like to see some demo code, there is " -"a directory named theme-mode inside the assets " -"directory that contains a file named demo-meta-boxes.php you " -"can reference." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:737 -msgid "" -"It's important to note that Meta Boxes do not support WYSIWYG editors at " -"this time and if you set one of your options to Textarea it will " -"automatically revert to a Textarea Simple until a valid solution is found. " -"WordPress released this statement regarding the wp_editor() function:" -msgstr "" - -#: ../includes/ot-functions-docs-page.php:739 -msgid "" -"Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. " -"What this means in practical terms, is that you cannot put it in meta-boxes " -"that can be dragged and placed elsewhere on the page." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:741 -msgid "Create and include your custom meta boxes file." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:743 -msgid "" -"Create a file and name it anything you want, maybe meta-boxes.php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:744 -msgid "" -"As well, you'll probably want to create a directory named includes to put your meta-boxes.php into which will help keep you " -"file structure nice and tidy." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:745 -#: ../includes/ot-functions-docs-page.php:845 -msgid "Add the following code to your functions.php." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:755 -msgid "" -"Add a variation of the following code to your meta-boxes.php. " -"You'll obviously need to fill it in with all your custom array values. It's " -"important to note here that we use the admin_init filter " -"because if you were to call the ot_register_meta_box function " -"before OptionTree was loaded the sky would fall on your head." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:817 -msgid "" -"There are a few simple steps you need to take in order to use OptionTree as " -"a theme included module. In the code below I'll show you a basic demo of how " -"to include the entire plugin as a module, which will allow you to have the " -"most up-to-date version of OptionTree without ever needing to hack the core " -"of the plugin. If you would like to see some demo code, there is a directory " -"named theme-mode inside the assets directory that " -"contains a file named demo-theme-options.php you can reference." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:819 -msgid "Step 1: Include the plugin & turn on theme mode." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:821 -#, php-format -msgid "Download the latest version of %s and unarchive the %s directory." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:822 -#, php-format -msgid "" -"Put the %s directory in the root of your theme. For example, the server path " -"would be %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:823 -#, php-format -msgid "Add the following code to the beginning of your %s." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:837 -#, php-format -msgid "" -"For a list of all the OptionTree UI display filters refer to the %s file " -"found in the %s directory of this plugin. This file is the starting point " -"for developing themes with Theme Mode." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:839 -msgid "" -"You now have OptionTree built into your theme and anytime an update is " -"available replace the old version with the new one." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:841 -msgid "Step 2: Create Theme Options without using the UI Builder." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:843 -msgid "" -"Create a file and name it anything you want, maybe theme-options.php, or use the built in file export to create it for you. Remember, you " -"should always check the file for errors before including it in your theme." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:844 -msgid "" -"As well, you'll probably want to create a directory named includes to put your theme-options.php into which will help keep " -"you file structure nice and tidy." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:855 -msgid "" -"Add a variation of the following code to your theme-options.php. You'll obviously need to fill it in with all your custom array values " -"for contextual help (optional), sections (required), and settings (required)." -msgstr "" - -#: ../includes/ot-functions-docs-page.php:858 -msgid "" -"The code below is a boilerplate to get your started. For a full list of the " -"available option types click the \"Option Types\" tab above. Also a quick " -"note, you don't need to put OptionTree in theme mode to manually create " -"options but you will want to hide the docs and settings as each time you " -"load the admin area the settings be written over with the code below if " -"they've changed in any way. However, this ensures your settings do not get " -"tampered with by the end-user." -msgstr "" - -#: ../includes/ot-functions-option-types.php:46 -msgid "Sorry, this function does not exist" -msgstr "" - -#: ../includes/ot-functions-option-types.php:134 -msgid "background-repeat" -msgstr "" - -#: ../includes/ot-functions-option-types.php:152 -msgid "background-attachment" -msgstr "" - -#: ../includes/ot-functions-option-types.php:171 -msgid "background-position" -msgstr "" - -#: ../includes/ot-functions-option-types.php:224 -msgid "background-size" -msgstr "" - -#: ../includes/ot-functions-option-types.php:238 -msgid "background-image" -msgstr "" - -#: ../includes/ot-functions-option-types.php:241 -#: ../includes/ot-functions-option-types.php:3202 -msgid "Add Media" -msgstr "" - -#: ../includes/ot-functions-option-types.php:316 -#: ../includes/ot-functions-option-types.php:1045 -msgid "width" -msgstr "" - -#: ../includes/ot-functions-option-types.php:327 -#: ../includes/ot-functions-option-types.php:1065 -#: ../includes/ot-functions-option-types.php:1550 -#: ../includes/ot-functions-option-types.php:2506 -msgid "unit" -msgstr "" - -#: ../includes/ot-functions-option-types.php:346 -msgid "style" -msgstr "" - -#: ../includes/ot-functions-option-types.php:439 -msgid "offset-x" -msgstr "" - -#: ../includes/ot-functions-option-types.php:448 -msgid "offset-y" -msgstr "" - -#: ../includes/ot-functions-option-types.php:457 -msgid "blur-radius" -msgstr "" - -#: ../includes/ot-functions-option-types.php:466 -msgid "spread-radius" -msgstr "" - -#: ../includes/ot-functions-option-types.php:538 -#: ../includes/ot-functions-option-types.php:592 -msgid "No Categories Found" -msgstr "" - -#: ../includes/ot-functions-option-types.php:587 -#: ../includes/ot-functions-option-types.php:870 -#: ../includes/ot-functions-option-types.php:1819 -#: ../includes/ot-functions-option-types.php:1930 -#: ../includes/ot-functions-option-types.php:2646 -#: ../includes/ot-functions-option-types.php:2761 -msgid "Choose One" -msgstr "" - -#: ../includes/ot-functions-option-types.php:818 -#: ../includes/ot-functions-option-types.php:876 -#: ../includes/ot-functions-option-types.php:1881 -#: ../includes/ot-functions-option-types.php:1936 -msgid "No Posts Found" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1054 -msgid "height" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1232 -#: ../includes/ot-functions-option-types.php:1275 -msgid "Remove Google Font" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1234 -#: ../includes/ot-functions-option-types.php:1277 -msgid "-- Choose One --" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1298 -msgid "Add Google Font" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1384 -msgctxt "color picker" -msgid "Standard" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1385 -msgctxt "color picker" -msgid "Hover" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1386 -msgctxt "color picker" -msgid "Active" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1387 -msgctxt "color picker" -msgid "Visited" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1388 -msgctxt "color picker" -msgid "Focus" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1497 -#: ../includes/ot-functions-option-types.php:2246 -#: ../includes/ot-functions-option-types.php:2411 -msgid "Add New" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1500 -#: ../includes/ot-functions-option-types.php:2249 -#: ../includes/ot-functions-option-types.php:2414 -msgid "You can re-order with drag & drop, the order will update after saving." -msgstr "" - -#: ../includes/ot-functions-option-types.php:1670 -msgid "On" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1692 -msgid "Off" -msgstr "" - -#: ../includes/ot-functions-option-types.php:1770 -#: ../includes/ot-functions-option-types.php:1825 -msgid "No Pages Found" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2169 -msgid "Choose Sidebar" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2174 -msgid "No Sidebars" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2282 -msgid "Facebook" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2287 -msgid "Twitter" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2292 -msgid "Google+" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2297 -msgid "LinkedIn" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2302 -msgid "Pinterest" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2307 -msgid "Youtube" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2312 -msgid "Dribbble" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2317 -msgid "Github" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2322 -msgid "Forrst" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2327 -msgid "Digg" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2332 -msgid "Delicious" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2337 -msgid "Tumblr" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2342 -msgid "Skype" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2347 -msgid "SoundCloud" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2352 -msgid "Vimeo" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2357 -msgid "Flickr" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2362 -msgid "VK.com" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2468 -msgid "top" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2477 -msgid "right" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2486 -msgid "bottom" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2495 -msgid "left" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2597 -#: ../includes/ot-functions-option-types.php:2651 -msgid "No Tags Found" -msgstr "" - -#: ../includes/ot-functions-option-types.php:2709 -#: ../includes/ot-functions-option-types.php:2766 -msgid "No Taxonomies Found" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:35 -msgid "Warning!" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:36 -#, php-format -msgid "" -"Go to the %s page if you want to save data, this page is for adding settings." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:37 -#, php-format -msgid "" -"If you're unsure or not completely positive that you should be editing these " -"settings, you should read the %s first." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:38 -msgid "" -"Things could break or be improperly displayed to the end-user if you do one " -"of the following:" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:39 -msgid "" -"Give two sections the same ID, give two settings the same ID, give two " -"contextual help content areas the same ID, don't create any settings, or " -"have a section at the end of the settings list." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:40 -msgid "" -"You can create as many settings as your project requires and use them how " -"you see fit. When you add a setting here, it will be available on the Theme " -"Options page for use in your theme. To separate your settings into sections, " -"click the \"Add Section\" button, fill in the input fields, and a new " -"navigation menu item will be created." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:41 -msgid "" -"All of the settings can be sorted and rearranged to your liking with Drag & " -"Drop. Don't worry about the order in which you create your settings, you can " -"always reorder them." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:92 -msgid "Add Section" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:99 -msgid "Contextual Help" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:103 -msgid "Contextual Help Sidebar" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:103 -msgid "" -"If you decide to add contextual help to the Theme Option page, enter the " -"optional \"Sidebar\" HTML here. This would be an extremely useful place to " -"add links to your themes documentation or support forum. Only after you've " -"added some content below will this display to the user." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:132 -msgid "Add Contextual Help Content" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:168 -msgid "" -"This import method has been deprecated. That means it has been replaced by a " -"new method and is no longer supported, and may be removed from future " -"versions. All themes that use this import method should be converted to use " -"its replacement below." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:170 -#, php-format -msgid "" -"If you were given a Theme Options XML file with a premium or free theme, " -"locate it on your hard drive and upload that file by clicking the upload " -"button. A popup window will appear, upload the XML file and click \"%s\". " -"The file URL should be in the upload input, if it is click \"Import XML\"." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:173 -msgid "Import XML" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:189 -msgid "Add XML" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:226 -msgid "" -"To import your Settings copy and paste what appears to be a random string of " -"alpha numeric characters into this textarea and press the \"Import Settings" -"\" button." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:229 -msgid "Import Settings" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:271 -msgid "" -"Only after you've imported the Settings should you try and update your Theme " -"Options." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:273 -msgid "" -"To import your Theme Options copy and paste what appears to be a random " -"string of alpha numeric characters into this textarea and press the \"Import " -"Theme Options\" button." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:276 -msgid "Import Theme Options" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:318 -msgid "" -"Only after you've imported the Settings should you try and update your " -"Layouts." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:320 -msgid "" -"To import your Layouts copy and paste what appears to be a random string of " -"alpha numeric characters into this textarea and press the \"Import Layouts\" " -"button. Keep in mind that when you import your layouts, the active layout's " -"saved data will write over the current data set for your Theme Options." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:323 -msgid "Import Layouts" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:366 -#, php-format -msgid "" -"Export your Settings into a fully functional %s file. If you want to add " -"your own custom %s text domain to the file, enter it into the text field " -"before exporting. For more information on how to use this file read the " -"documentation on %s. Remember, you should always check the file for errors " -"before including it in your theme." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:375 -msgid "Export Settings File" -msgstr "" - -#: ../includes/ot-functions-settings-page.php:405 -msgid "" -"Export your Settings by highlighting this text and doing a copy/paste into a " -"blank .txt file. Then save the file for importing into another install of " -"WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Settings textarea " -"on another web site." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:441 -msgid "" -"Export your Theme Options data by highlighting this text and doing a copy/" -"paste into a blank .txt file. Then save the file for importing into another " -"install of WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Theme Options " -"textarea on another web site." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:477 -msgid "" -"Export your Layouts by highlighting this text and doing a copy/paste into a " -"blank .txt file. Then save the file for importing into another install of " -"WordPress later. Alternatively, you could just paste it into the " -"OptionTree->Settings->Import Layouts textarea " -"on another web site." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:519 -msgid "" -"To add a new layout enter a unique lower case alphanumeric string (dashes " -"allowed) in the text field and click \"Save Layouts\"." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:520 -msgid "" -"As well, you can activate, remove, and drag & drop the order; all situations " -"require you to click \"Save Layouts\" for the changes to be applied." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:521 -msgid "" -"When you create a new layout it will become active and any changes made to " -"the Theme Options will be applied to it. If you switch back to a different " -"layout immediately after creating a new layout that new layout will have a " -"snapshot of the current Theme Options data attached to it." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:522 -msgid "" -"Visit OptionTree->Documentation->Layouts Overview to see a more " -"in-depth description of what layouts are and how to use them." -msgstr "" - -#: ../includes/ot-functions-settings-page.php:559 -msgid "Save Layouts" -msgstr "" - -#: ../includes/ot-settings-api.php:364 -msgid "Reset Options" -msgstr "" - -#: ../ot-loader.php:22 -msgid "" -"OptionTree is installed as a plugin and also embedded in your current theme. " -"Please deactivate the plugin to load the theme dependent version of " -"OptionTree, and remove this warning." -msgstr "" diff --git a/ot-loader.php b/ot-loader.php index 02d9b3f..6635ef3 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -46,76 +46,14 @@ class OT_Loader { */ public function __construct() { - // Load languages. - $this->load_languages(); - // Load OptionTree. add_action( 'after_setup_theme', array( $this, 'load_option_tree' ), 1 ); } /** - * Load the languages before everything else. - * - * @access private - * @since 2.1.3 - */ - private function load_languages() { - - /** - * A quick check to see if we're in plugin mode. - * - * @since 2.1.3 - */ - define( 'OT_PLUGIN_MODE', strpos( dirname( __FILE__ ), 'plugins' . DIRECTORY_SEPARATOR . basename( dirname( __FILE__ ) ) ) !== false ? true : false ); - - /** - * Path to the languages directory. - * - * This path will be relative in plugin mode and absolute in theme mode. - * - * @since 2.0.10 - * @updated 2.4.1 - */ - if ( OT_PLUGIN_MODE ) { - define( 'OT_LANG_DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) . trailingslashit( 'languages' ) ); - } else { - if ( true === apply_filters( 'ot_child_theme_mode', false ) ) { - $path = @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); - $path = ltrim( end( $path ), '/' ); - define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); - } else { - $path = @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); - $path = ltrim( end( $path ), '/' ); - define( 'OT_LANG_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) . trailingslashit( 'languages' ) . 'theme-mode' ); - } - } - - // Load the text domain. - if ( OT_PLUGIN_MODE ) { - add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) ); - } else { - add_action( 'after_setup_theme', array( $this, 'load_textdomain' ) ); - } - } - - /** - * Load the text domain. + * OptionTree loads on the 'after_setup_theme' action. * - * @access private - * @since 2.0 - */ - public function load_textdomain() { - - if ( OT_PLUGIN_MODE ) { - load_plugin_textdomain( 'option-tree', false, OT_LANG_DIR ); - } else { - load_theme_textdomain( 'option-tree', OT_LANG_DIR ); - } - } - - /** - * Load OptionTree on the 'after_setup_theme' action. Then filters will - * be available to the theme, and not only when in Theme Mode. + * @todo Load immediately. * * @access public * @since 2.1.2 @@ -290,11 +228,11 @@ private function constants() { define( 'OT_URL', plugin_dir_url( __FILE__ ) ); } else { if ( true === OT_CHILD_THEME_MODE ) { - $path = ltrim( end( @explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + $path = ltrim( end( explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) ); define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) ); } else { - $path = ltrim( end( @explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + $path = ltrim( end( explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) ); define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) ); } @@ -518,15 +456,15 @@ private function load_file( $file ) { * Adds CSS for the menu icon. */ public function global_admin_css() { - echo ' + ?> '; + + = $post_id && function_exists( 'ot_get_media_post_ID' ) ) { $post_id = ot_get_media_post_ID(); } @@ -664,12 +653,14 @@ public function shortcode( $settings, $post ) { * @since 2.2.0 */ public function ajax_gallery_update() { + check_ajax_referer( 'option_tree', 'nonce' ); - if ( ! empty( $_POST['ids'] ) ) { + if ( ! empty( $_POST['ids'] ) && is_array( $_POST['ids'] ) ) { $html = ''; + $ids = array_filter( $_POST['ids'], 'absint' ); // phpcs:ignore - foreach ( $_POST['ids'] as $id ) { + foreach ( $ids as $id ) { $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); @@ -677,8 +668,9 @@ public function ajax_gallery_update() { } echo $html; // phpcs:ignore - exit(); } + + wp_die(); } /** @@ -688,19 +680,25 @@ public function ajax_gallery_update() { * @since 2.5.0 */ public function retrieve_google_font() { + check_ajax_referer( 'option_tree', 'nonce' ); if ( isset( $_POST['field_id'], $_POST['family'] ) ) { ot_fetch_google_fonts(); - echo wp_json_encode( + $field_id = isset( $_POST['field_id'] ) ? sanitize_text_field( wp_unslash( $_POST['field_id'] ) ) : ''; + $family = isset( $_POST['family'] ) ? sanitize_text_field( wp_unslash( $_POST['family'] ) ) : ''; + $html = wp_json_encode( array( - 'variants' => ot_recognized_google_font_variants( $_POST['field_id'], $_POST['family'] ), - 'subsets' => ot_recognized_google_font_subsets( $_POST['field_id'], $_POST['family'] ), + 'variants' => ot_recognized_google_font_variants( $field_id, $family ), + 'subsets' => ot_recognized_google_font_subsets( $field_id, $family ), ) ); - exit(); + + echo $html; // phpcs:ignore } + + wp_die(); } /** From 361d2aa2a33033c33f4698d4653aa066e2e0a5d5 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 04:53:01 -0800 Subject: [PATCH 05/67] Ignore snake case --- .jscsrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jscsrc b/.jscsrc index d583b26..911b391 100644 --- a/.jscsrc +++ b/.jscsrc @@ -6,5 +6,5 @@ "**/node_modules/**", "**/vendor/**" ], - "requireCamelCaseOrUpperCaseIdentifiers": true + "requireCamelCaseOrUpperCaseIdentifiers": false } From 9c018be1d6f52bb459cf0ac821455e48f10f3911 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 05:52:36 -0800 Subject: [PATCH 06/67] Fix phpcs issues --- includes/class-ot-cleanup.php | 297 ++++++++++++++++++++++++++++++++++ includes/ot-cleanup-api.php | 295 --------------------------------- 2 files changed, 297 insertions(+), 295 deletions(-) create mode 100755 includes/class-ot-cleanup.php delete mode 100755 includes/ot-cleanup-api.php diff --git a/includes/class-ot-cleanup.php b/includes/class-ot-cleanup.php new file mode 100755 index 0000000..d636991 --- /dev/null +++ b/includes/class-ot-cleanup.php @@ -0,0 +1,297 @@ +#toplevel_page_ot-cleanup{display:none;}'; + } + + /** + * Check if OptionTree needs to be cleaned up from a previous install. + * + * @access public + * @since 2.4.6 + */ + public function maybe_cleanup() { + global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table; + + $table_name = $wpdb->prefix . 'option_tree'; + $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore + $ot_maybe_cleanup_posts = count( $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree' LIMIT 2" ) ) > 1; // phpcs:ignore + $ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) == $table_name; // phpcs:ignore + + if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && 'ot-cleanup' === $page ) { + wp_safe_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ); + exit; + } + + if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) { + + if ( 'ot-cleanup' !== $page ) { + add_action( 'admin_notices', array( $this, 'cleanup_notice' ) ); + } + + $theme_check_bs = 'add_menu_' . 'page'; // phpcs:ignore + + $theme_check_bs( apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ), 'edit_theme_options', 'ot-cleanup', array( $this, 'options_page' ) ); + } + } + + /** + * Adds an admin nag. + * + * @access public + * @since 2.4.6 + */ + public function cleanup_notice() { + + if ( 'appearance_page_ot-cleanup' !== get_current_screen()->id ) { + $link = sprintf( '%s', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) ); + + /* translators: %s: internal admin page URL */ + echo '

        ' . sprintf( esc_html__( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), $link ) . '
        '; // phpcs:ignore + } + } + + /** + * Adds a Tools sub page to clean up the database with. + * + * @access public + * @since 2.4.6 + */ + public function options_page() { + global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table; + + // Option ID. + $option_id = 'ot_media_post_ID'; + + // Get the media post ID. + $post_ID = get_option( $option_id, false ); + + // Zero loop count. + $count = 0; + + // Check for safe mode. + $safe_mode = ini_get( 'safe_mode' ); // phpcs:ignore + + echo '
        '; + + echo '

        ' . apply_filters( 'ot_cleanup_page_title', esc_html__( 'OptionTree Cleanup', 'option-tree' ) ) . '

        '; // phpcs:ignore + + if ( $ot_maybe_cleanup_posts ) { + + $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree'" ); // phpcs:ignore + + echo '

        ' . esc_html__( 'Multiple Media Posts', 'option-tree' ) . '

        '; + + /* translators: %1$s: number of media posts, %2$s: media post type, %3$s: table name */ + $string = esc_html__( 'There are currently %1$s OptionTree media posts in your database. At some point in the past, a version of OptionTree added multiple %2$s media post objects cluttering up your %3$s table. There is no associated risk or harm that these posts have caused other than to add size to your overall database. Thankfully, there is a way to remove all these orphaned media posts and get your database cleaned up.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . number_format( count( $posts ) ) . '', 'option-tree', '' . $wpdb->posts . '' ) . '

        '; // phpcs:ignore + + /* translators: %s: number of media posts being deleted */ + echo '

        ' . sprintf( esc_html__( 'By clicking the button below, OptionTree will delete %s records and consolidate them into one single OptionTree media post for uploading attachments to. Additionally, the attachments will have their parent ID updated to the correct media post.', 'option-tree' ), '' . number_format( count( $posts ) - 1 ) . '' ) . '

        '; + + echo '

        ' . esc_html__( 'This could take a while to fully process depending on how many records you have in your database, so please be patient and wait for the script to finish.', 'option-tree' ) . '

        '; + + /* translators: %1$s: the word Note wrapped in a strong attribute, %2$s: number of posts being deleted */ + $string = __( '%1$s: Your server is running in safe mode. Which means this page will automatically reload after deleting %2$s posts, you can filter this number using %3$s if your server is having trouble processing that many at one time.', 'option-tree' ); + echo $safe_mode ? '

        ' . sprintf( $string, '' . esc_html__( 'Note', 'option-tree' ) . ':', apply_filters( 'ot_consolidate_posts_reload', 500 ), 'ot_consolidate_posts_reload' ) . '

        ' : ''; // phpcs:ignore + + echo '

        ' . esc_html__( 'Consolidate Posts', 'option-tree' ) . '

        '; // phpcs:ignore + + if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'consolidate-posts' ) ) { // phpcs:ignore + + if ( false === $post_ID || empty( $post_ID ) ) { + $post_ID = isset( $posts[0]->ID ) ? $posts[0]->ID : null; + + // Add to the DB. + if ( null !== $post_ID ) { + update_option( $option_id, $post_ID ); + } + } + + // Do pre consolidation action to increase timeout. + do_action( 'ot_pre_consolidate_posts' ); + + // Loop over posts. + foreach ( $posts as $post ) { + + // Don't destroy the correct post. + if ( $post_ID === $post->ID ) { + continue; + } + + // Update count. + $count++; + + // Reload script in safe mode. + if ( $safe_mode && $count > absint( apply_filters( 'ot_consolidate_posts_reload', 500 ) ) ) { + echo '
        ' . esc_html__( 'Reloading...', 'option-tree' ); + echo ' + '; + break; + } + + // Get the attachments. + $attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID ); + + // Update the attachments parent ID. + if ( ! empty( $attachments ) ) { + + /* translators: %1$s: the post type, %2$s: the post ID */ + $string = esc_html__( 'Updating Attachments parent ID for %1$s post %2$s.', 'option-tree' ); + echo sprintf( $string . '
        ', 'option-tree', '#' . $post->ID . '' ); // phpcs:ignore + + foreach ( $attachments as $attachment_id => $attachment ) { + wp_update_post( + array( + 'ID' => $attachment_id, + 'post_parent' => $post_ID, + ) + ); + } + } + + /* translators: %1$s: the post type, %2$s: the post ID */ + $string = esc_html__( 'Deleting %1$s post %2$s.', 'option-tree' ); + + // Delete post. + echo sprintf( $string . '
        ', 'option-tree', '#' . $post->ID . '' ); // phpcs:ignore + wp_delete_post( $post->ID, true ); + + } + + echo '
        ' . esc_html__( 'Clean up script has completed, the page will now reload...', 'option-tree' ); + + echo ' + '; + + } + } + + if ( $ot_maybe_cleanup_table ) { + + $table_name = $wpdb->prefix . 'option_tree'; + + echo $ot_maybe_cleanup_posts ? '
        ' : ''; + + echo '

        ' . esc_html__( 'Outdated Table', 'option-tree' ) . '

        '; + + /* translators: %s: table name */ + $string = esc_html__( 'If you have upgraded from an old 1.x version of OptionTree at some point, you have an extra %s table in your database that can be removed. It\'s not hurting anything, but does not need to be there. If you want to remove it. Click the button below.', 'option-tree' ); + + echo '

        ' . sprintf( $string, '' . $table_name . '' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Drop Table', 'option-tree' ) . '

        '; + + if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'drop-table' ) ) { // phpcs:ignore + + /* translators: %s: table name */ + $string = esc_html__( 'Deleting the outdated and unused %s table...', 'option-tree' ); + + echo '

        ' . sprintf( $string, '' . $table_name . '' ) . '

        '; // phpcs:ignore + + $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); // phpcs:ignore + + if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ) != $table_name ) { // phpcs:ignore + + /* translators: %s: table name */ + $string = esc_html__( 'The %s table has been successfully deleted. The page will now reload...', 'option-tree' ); + + echo '

        ' . sprintf( $string, '' . $table_name . '' ) . '

        '; // phpcs:ignore + + echo ' + '; + + } else { + + /* translators: %s: table name */ + $string = esc_html__( 'Something went wrong. The %s table was not deleted.', 'option-tree' ); + + echo '

        ' . sprintf( $string, '' . $table_name . '' ) . '

        '; // phpcs:ignore + } + } + } + + echo '
        '; + } + + /** + * Increase PHP timeout. + * + * This is to prevent bulk operations from timing out + * + * @access public + * @since 2.4.6 + */ + public function increase_timeout() { + if ( ! ini_get( 'safe_mode' ) ) { // phpcs:ignore + @set_time_limit( 0 ); // phpcs:ignore + } + } + } +} + +new OT_Cleanup(); diff --git a/includes/ot-cleanup-api.php b/includes/ot-cleanup-api.php deleted file mode 100755 index eb734aa..0000000 --- a/includes/ot-cleanup-api.php +++ /dev/null @@ -1,295 +0,0 @@ - - * @copyright Copyright (c) 2014, Derek Herman - */ -if ( ! class_exists( 'OT_Cleanup' ) ) { - - class OT_Cleanup { - - /** - * PHP5 constructor method. - * - * This method adds other methods of the class to specific hooks within WordPress. - * - * @uses add_action() - * - * @return void - * - * @access public - * @since 2.4.6 - */ - function __construct() { - if ( ! is_admin() ) - return; - - // Load styles - add_action( 'admin_head', array( $this, 'styles' ), 1 ); - - // Maybe Clean up OptionTree - add_action( 'admin_menu', array( $this, 'maybe_cleanup' ), 100 ); - - // Increase timeout if allowed - add_action( 'ot_pre_consolidate_posts', array( $this, 'increase_timeout' ) ); - - } - - /** - * Adds the cleanup styles to the admin head - * - * @return string - * - * @access public - * @since 2.5.0 - */ - function styles() { - - echo ''; - - } - - /** - * Check if OptionTree needs to be cleaned up from a previous install. - * - * @return void - * - * @access public - * @since 2.4.6 - */ - public function maybe_cleanup() { - global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table; - - $table_name = $wpdb->prefix . 'option_tree'; - $page = isset( $_GET['page'] ) ? $_GET['page'] : ''; - $ot_maybe_cleanup_posts = count( $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree' LIMIT 2" ) ) > 1; - $ot_maybe_cleanup_table = $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name; - - if ( ! $ot_maybe_cleanup_posts && ! $ot_maybe_cleanup_table && $page == 'ot-cleanup' ) { - wp_redirect( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ); - exit; - } - - if ( $ot_maybe_cleanup_posts || $ot_maybe_cleanup_table ) { - - if ( $page != 'ot-cleanup' ) - add_action( 'admin_notices', array( $this, 'cleanup_notice' ) ); - - $theme_check_bs = 'add_menu_' . 'page'; - - $theme_check_bs( apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ), 'edit_theme_options', 'ot-cleanup', array( $this, 'options_page' ) ); - - } - - } - - /** - * Adds an admin nag. - * - * @return string - * - * @access public - * @since 2.4.6 - */ - public function cleanup_notice() { - - if ( get_current_screen()->id != 'appearance_page_ot-cleanup' ) - echo '
        ' . sprintf( __( 'OptionTree has outdated data that should be removed. Please go to %s for more information.', 'option-tree' ), sprintf( '%s', admin_url( 'themes.php?page=ot-cleanup' ), apply_filters( 'ot_cleanup_menu_title', __( 'OptionTree Cleanup', 'option-tree' ) ) ) ) . '
        '; - - } - - /** - * Adds a Tools sub page to clean up the database with. - * - * @return string - * - * @access public - * @since 2.4.6 - */ - public function options_page() { - global $wpdb, $ot_maybe_cleanup_posts, $ot_maybe_cleanup_table; - - // Option ID - $option_id = 'ot_media_post_ID'; - - // Get the media post ID - $post_ID = get_option( $option_id, false ); - - // Zero loop count - $count = 0; - - // Check for safe mode - $safe_mode = ini_get( 'safe_mode' ); - - echo '
        '; - - echo '

        ' . apply_filters( 'ot_cleanup_page_title', __( 'OptionTree Cleanup', 'option-tree' ) ) . '

        '; - - if ( $ot_maybe_cleanup_posts ) { - - $posts = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'option-tree'" ); - - echo '

        ' . __( 'Multiple Media Posts', 'option-tree' ) . '

        '; - - echo '

        ' . sprintf( __( 'There are currently %s OptionTree media posts in your database. At some point in the past, a version of OptionTree added multiple %s media post objects cluttering up your %s table. There is no associated risk or harm that these posts have caused other than to add size to your overall database. Thankfully, there is a way to remove all these orphaned media posts and get your database cleaned up.', 'option-tree' ), '' . number_format( count( $posts ) ) . '', 'option-tree', '' . $wpdb->posts . '' ) . '

        '; - - echo '

        ' . sprintf( __( 'By clicking the button below, OptionTree will delete %s records and consolidate them into one single OptionTree media post for uploading attachments to. Additionally, the attachments will have their parent ID updated to the correct media post.', 'option-tree' ), '' . number_format( count( $posts ) - 1 ) . '' ) . '

        '; - - echo '

        ' . __( 'This could take a while to fully process depending on how many records you have in your database, so please be patient and wait for the script to finish.', 'option-tree' ) . '

        '; - - echo $safe_mode ? '

        ' . sprintf( __( '%s Your server is running in safe mode. Which means this page will automatically reload after deleting %s posts, you can filter this number using %s if your server is having trouble processing that many at one time.', 'option-tree' ), 'Note:', apply_filters( 'ot_consolidate_posts_reload', 500 ), 'ot_consolidate_posts_reload' ) . '

        ' : ''; - - echo '

        ' . __( 'Consolidate Posts', 'option-tree' ) . '

        '; - - if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'consolidate-posts' ) ) { - - if ( $post_ID === false || empty( $post_ID ) ) { - $post_ID = isset( $posts[0]->ID ) ? $posts[0]->ID : null; - - // Add to the DB - if ( $post_ID !== null ) - update_option( $option_id, $post_ID ); - - } - - // Do pre consolidation action to increase timeout. - do_action( 'ot_pre_consolidate_posts' ); - - // Loop over posts - foreach( $posts as $post ) { - - // Don't destroy the correct post. - if ( $post_ID == $post->ID ) - continue; - - // Update count - $count++; - - // Reload script in safe mode - if ( $safe_mode && $count > apply_filters( 'ot_consolidate_posts_reload', 500 ) ) { - echo '
        ' . __( 'Reloading...', 'option-tree' ); - echo ' - '; - break; - } - - // Get the attachements - $attachments = get_children( 'post_type=attachment&post_parent=' . $post->ID ); - - // Update the attachments parent ID - if ( ! empty( $attachments ) ) { - - echo 'Updating Attachments parent ID for option-tree post #' . $post->ID . '.
        '; - - foreach( $attachments as $attachment_id => $attachment ) { - wp_update_post( - array( - 'ID' => $attachment_id, - 'post_parent' => $post_ID - ) - ); - } - - } - - // Delete post - echo 'Deleting option-tree post #' . $post->ID . '
        '; - wp_delete_post( $post->ID, true ); - - } - - echo '
        ' . __( 'Clean up script has completed, the page will now reload...', 'option-tree' ); - - echo ' - '; - - } - - } - - if ( $ot_maybe_cleanup_table ) { - - $table_name = $wpdb->prefix . 'option_tree'; - - echo $ot_maybe_cleanup_posts ? '
        ' : ''; - - echo '

        ' . __( 'Outdated Table', 'option-tree' ) . '

        '; - - echo '

        ' . sprintf( __( 'If you have upgraded from an old 1.x version of OptionTree at some point, you have an extra %s table in your database that can be removed. It\'s not hurting anything, but does not need to be there. If you want to remove it. Click the button below.', 'option-tree' ), '' . $table_name . '' ) . '

        '; - - echo '

        ' . __( 'Drop Table', 'option-tree' ) . '

        '; - - if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'drop-table' ) ) { - - echo '

        ' . sprintf( __( 'Deleting the outdated and unused %s table...', 'option-tree' ), '' . $table_name . '' ) . '

        '; - - $wpdb->query( "DROP TABLE IF EXISTS $table_name" ); - - if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) != $table_name ) { - - echo '

        ' . sprintf( __( 'The %s table has been successfully deleted. The page will now reload...', 'option-tree' ), '' . $table_name . '' ) . '

        '; - - echo ' - '; - - } else { - - echo '

        ' . sprintf( __( 'Something went wrong. The %s table was not deleted.', 'option-tree' ), '' . $table_name . '' ) . '

        '; - - } - - } - - } - - echo '
        '; - - } - - /** - * Increase PHP timeout. - * - * This is to prevent bulk operations from timing out - * - * @return void - * - * @access public - * @since 2.4.6 - */ - public function increase_timeout() { - - if ( ! ini_get( 'safe_mode' ) ) { - - @set_time_limit( 0 ); - - } - - } - - } - -} - -new OT_Cleanup(); - -/* End of file ot-cleanup-api.php */ -/* Location: ./includes/ot-cleanup-api.php */ \ No newline at end of file From fac77cd1046acb0b8bc5aa540efef96720441212 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 05:53:45 -0800 Subject: [PATCH 07/67] Fix docblock --- ot-loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ot-loader.php b/ot-loader.php index 6635ef3..d68ed21 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -37,7 +37,7 @@ function ot_conflict_notice() { class OT_Loader { /** - * Constructor. + * Class constructor. * * This method loads other methods of the class. * @@ -290,7 +290,7 @@ private function admin_includes() { } // Include the cleanup api. - $files[] = 'ot-cleanup-api'; + $files[] = 'class-ot-cleanup'; // Require the files. foreach ( $files as $file ) { From 0cd10dbec940b634d98ab6b1eecc336f35ed1d2a Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 06:17:00 -0800 Subject: [PATCH 08/67] Fix phpcs issues --- includes/class-ot-post-formats.php | 122 +++++++++++++++++++++++++++ includes/ot-post-formats-api.php | 131 ----------------------------- ot-loader.php | 2 +- 3 files changed, 123 insertions(+), 132 deletions(-) create mode 100755 includes/class-ot-post-formats.php delete mode 100755 includes/ot-post-formats-api.php diff --git a/includes/class-ot-post-formats.php b/includes/class-ot-post-formats.php new file mode 100755 index 0000000..47f7759 --- /dev/null +++ b/includes/class-ot-post-formats.php @@ -0,0 +1,122 @@ +setup_actions(); + } + + /** + * Setup the default filters and actions. + * + * @uses add_action() To add various actions. + * @uses add_filter() To add various filters. + * + * @access private + * @since 2.3.0 + */ + private function setup_actions() { + + // Initialize the meta boxes. + add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 ); + + // Setup pings for the link & quote URLs. + add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 ); + } + + /** + * Builds the default Meta Boxes. + * + * @access private + * @since 2.3.0 + */ + public function meta_boxes() { + + // Exit if called outside of WP admin. + if ( ! is_admin() ) { + return false; + } + + /** + * Filter the post formats meta boxes. + * + * @since 2.6.0 + * + * @param array $meta_boxes The meta boxes being registered. + * @return array + */ + $meta_boxes = apply_filters( + 'ot_recognized_post_format_meta_boxes', + array( + ot_meta_box_post_format_gallery(), + ot_meta_box_post_format_link(), + ot_meta_box_post_format_quote(), + ot_meta_box_post_format_video(), + ot_meta_box_post_format_audio(), + ) + ); + + /** + * Register our meta boxes using the + * ot_register_meta_box() function. + */ + foreach ( $meta_boxes as $meta_box ) { + ot_register_meta_box( $meta_box ); + } + } + + /** + * Setup pings for the link & quote URLs + * + * @access public + * @since 2.3.0 + * + * @param array $post_links The URLs to ping. + * @param array $pung Pinged URLs. + * @param int $post_id Post ID. + */ + public function pre_ping_post_links( $post_links, $pung, $post_id = null ) { + + $_link = get_post_meta( $post_id, '_format_link_url', true ); + if ( ! empty( $_link ) && ! in_array( $_link, $pung, true ) && ! in_array( $_link, $post_links, true ) ) { + $post_links[] = $_link; + } + + $_quote = get_post_meta( $post_id, '_format_quote_source_url', true ); + if ( ! empty( $_quote ) && ! in_array( $_quote, $pung, true ) && ! in_array( $_quote, $post_links, true ) ) { + $post_links[] = $_quote; + } + } + } +} + +/** + * Instantiate The Class. + * + * @since 1.0 + */ +if ( function_exists( 'ot_register_meta_box' ) ) { + new OT_Post_Formats(); +} diff --git a/includes/ot-post-formats-api.php b/includes/ot-post-formats-api.php deleted file mode 100755 index 70b3fe9..0000000 --- a/includes/ot-post-formats-api.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Copyright (c) 2014, Derek Herman - */ -if ( ! class_exists( 'OT_Post_Formats' ) ) { - - class OT_Post_Formats { - - /** - * Class Constructor - * - * @return void - * - * @access public - * @since 2.3.0 - */ - public function __construct() { - - $this->setup_actions(); - - } - - /** - * Setup the default filters and actions - * - * @uses add_action() To add various actions - * @uses add_filter() To add various filters - * - * @return void - * - * @access private - * @since 2.3.0 - */ - private function setup_actions() { - - // Initialize the meta boxes - add_action( 'admin_init', array( $this, 'meta_boxes' ), 2 ); - - // Setup pings for the link & quote URLs - add_filter( 'pre_ping', array( $this, 'pre_ping_post_links' ), 10, 3 ); - - } - - /** - * Builds the default Meta Boxes. - * - * @return void - * - * @access private - * @since 2.3.0 - */ - public function meta_boxes() { - - // Exit if called outside of WP admin - if ( ! is_admin() ) - return false; - - /** - * Filter the post formats meta boxes. - * - * @since 2.6.0 - * - * @param array $meta_boxes The meta boxes being registered. - * @return array - */ - $meta_boxes = apply_filters( 'ot_recognized_post_format_meta_boxes', array( - ot_meta_box_post_format_gallery(), - ot_meta_box_post_format_link(), - ot_meta_box_post_format_quote(), - ot_meta_box_post_format_video(), - ot_meta_box_post_format_audio(), - ) ); - - /** - * Register our meta boxes using the - * ot_register_meta_box() function. - */ - foreach( $meta_boxes as $meta_box ) { - - ot_register_meta_box( $meta_box ); - - } - - } - - /** - * Setup pings for the link & quote URLs - * - * @param array $post_links The URLs to ping - * @param array $pung Pinged URLs - * @param int $post_id Post ID - * @return array - * - * @access public - * @since 2.3.0 - */ - public function pre_ping_post_links( $post_links, $pung, $post_id = null ) { - - $_link = get_post_meta( $post_id, '_format_link_url', true ); - if ( ! empty( $_link ) && ! in_array( $_link, $pung ) && ! in_array( $_link, $post_links ) ) - $post_links[] = $_link; - - $_quote = get_post_meta( $post_id, '_format_quote_source_url', true ); - if ( ! empty( $_quote ) && ! in_array( $_quote, $pung ) && ! in_array( $_quote, $post_links ) ) - $post_links[] = $_quote; - - } - - } - -} - -/** - * Instantiate The Class - * - * @since 1.0 - */ -if ( function_exists( 'ot_register_meta_box' ) ) { - - new OT_Post_Formats(); - -} - -/* End of file ot-post-formats-api.php */ -/* Location: ./includes/ot-post-formats-api.php */ \ No newline at end of file diff --git a/ot-loader.php b/ot-loader.php index d68ed21..035d6c3 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -280,7 +280,7 @@ private function admin_includes() { // Include the post formats api. if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) { - $files[] = 'ot-post-formats-api'; + $files[] = 'class-ot-post-formats'; } // Include the settings & docs pages. From 5ab76561e8043848fc1729fea2d930941502948f Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 22:40:40 -0800 Subject: [PATCH 09/67] Fix phpcs issue --- includes/class-ot-meta-box.php | 377 +++++++++++++++++++++++++++++++++ includes/ot-meta-box-api.php | 363 ------------------------------- 2 files changed, 377 insertions(+), 363 deletions(-) create mode 100755 includes/class-ot-meta-box.php delete mode 100755 includes/ot-meta-box-api.php diff --git a/includes/class-ot-meta-box.php b/includes/class-ot-meta-box.php new file mode 100755 index 0000000..84bfec8 --- /dev/null +++ b/includes/class-ot-meta-box.php @@ -0,0 +1,377 @@ +meta_box = $meta_box; + + add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); + + add_action( 'save_post', array( $this, 'save_meta_box' ), 1, 2 ); + } + + /** + * Adds meta box to any post type + * + * @uses add_meta_box() + * + * @access public + * @since 1.0 + */ + public function add_meta_boxes() { + foreach ( (array) $this->meta_box['pages'] as $page ) { + add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( $this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] ); + } + } + + /** + * Meta box view. + * + * @access public + * @since 1.0 + * + * @param object $post The WP_Post object. + * @param array $fields The meta box fields. + */ + public function build_meta_box( $post, $fields ) { + unset( $fields ); // @todo Check if the loop can use this param. + + echo '
        '; + + // Use nonce for verification. + echo ''; + + // Meta box description. + echo isset( $this->meta_box['desc'] ) && ! empty( $this->meta_box['desc'] ) ? '
        ' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '
        ' : ''; // phpcs:ignore + + // Loop through meta box fields. + foreach ( $this->meta_box['fields'] as $field ) { + + // Get current post meta data. + $field_value = get_post_meta( $post->ID, $field['id'], true ); + + // Set standard value. + if ( isset( $field['std'] ) ) { + $field_value = ot_filter_std_value( $field_value, $field['std'] ); + } + + // Build the arguments array. + $_args = array( + 'type' => $field['type'], + 'field_id' => $field['id'], + 'field_name' => $field['id'], + 'field_value' => $field_value, + 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', + 'field_std' => isset( $field['std'] ) ? $field['std'] : '', + 'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10, + 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', + 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', + 'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', + 'field_class' => isset( $field['class'] ) ? $field['class'] : '', + 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', + 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', + 'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(), + 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), + 'post_id' => $post->ID, + 'meta' => true, + ); + + $conditions = ''; + + // Setup the conditions. + if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { + $conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"'; + $conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : ''; + } + + // Only allow simple textarea due to DOM issues with wp_editor(). + if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) { + $_args['type'] = 'textarea-simple'; + } + + // Build the setting CSS class. + if ( ! empty( $_args['field_class'] ) ) { + + $classes = explode( ' ', $_args['field_class'] ); + + foreach ( $classes as $key => $value ) { + + $classes[ $key ] = $value . '-wrap'; + + } + + $class = 'format-settings ' . implode( ' ', $classes ); + } else { + + $class = 'format-settings'; + } + + // Option label. + echo '
        '; // phpcs:ignore + + echo '
        '; + + // Don't show title with textblocks. + if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) { + echo '
        '; + echo ''; + echo '
        '; + } + + // Get the option HTML. + echo ot_display_by_type( $_args ); // phpcs:ignore + + echo '
        '; + + echo '
        '; + + } + + echo '
        '; + + echo '
        '; + } + + /** + * Saves the meta box values + * + * @access public + * @since 1.0 + * + * @param int $post_id The post ID. + * @param object $post_object The WP_Post object. + * @return int|void + */ + public function save_meta_box( $post_id, $post_object ) { + global $pagenow; + + // Verify nonce. + if ( isset( $_POST[ $this->meta_box['id'] . '_nonce' ] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce' ], $this->meta_box['id'] ) ) { // phpcs:ignore + return $post_id; + } + + // Store the post global for use later. + $post_global = $_POST; + + // Don't save if $_POST is empty. + if ( empty( $post_global ) || ( isset( $post_global['vc_inline'] ) && true === $post_global['vc_inline'] ) ) { + return $post_id; + } + + // Don't save during quick edit. + if ( 'admin-ajax.php' === $pagenow ) { + return $post_id; + } + + // Don't save during autosave. + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { + return $post_id; + } + + // Don't save if viewing a revision. + if ( 'revision' === $post_object->post_type || 'revision.php' === $pagenow ) { + return $post_id; + } + + // Check permissions. + if ( isset( $post_global['post_type'] ) && 'page' === $post_global['post_type'] ) { + if ( ! current_user_can( 'edit_page', $post_id ) ) { + return $post_id; + } + } else { + if ( ! current_user_can( 'edit_post', $post_id ) ) { + return $post_id; + } + } + + foreach ( $this->meta_box['fields'] as $field ) { + + $old = get_post_meta( $post_id, $field['id'], true ); + $new = ''; + + // There is data to validate. + if ( isset( $post_global[ $field['id'] ] ) ) { + + // Slider and list item. + if ( in_array( $field['type'], array( 'list-item', 'slider' ), true ) ) { + + // Required title setting. + $required_setting = array( + array( + 'id' => 'title', + 'label' => __( 'Title', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'text', + 'rows' => '', + 'class' => 'option-tree-setting-title', + 'post_type' => '', + 'choices' => array(), + ), + ); + + $decoded = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } + + // Convert the settings to an array. + $settings = maybe_unserialize( $decoded ); + + // Settings are empty for some odd ass reason get the defaults. + if ( empty( $settings ) ) { + $settings = ( 'slider' === $field['type'] ) ? ot_slider_settings( $field['id'] ) : ot_list_item_settings( $field['id'] ); + } + + // Merge the two settings array. + $settings = array_merge( $required_setting, $settings ); + + foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) { + + foreach ( $settings as $sub_setting ) { + + // Verify sub setting has a type & value. + if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) { + + $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] ); + } + } + } + + // Set up new data with validated data. + $new = $post_global[ $field['id'] ]; + + } elseif ( 'social-links' === $field['type'] ) { + + $decoded = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } + + // Convert the settings to an array. + $settings = maybe_unserialize( $decoded ); + + // Settings are empty get the defaults. + if ( empty( $settings ) ) { + $settings = ot_social_links_settings( $field['id'] ); + } + + foreach ( $post_global[ $field['id'] ] as $k => $setting_array ) { + + foreach ( $settings as $sub_setting ) { + + // Verify sub setting has a type & value. + if ( isset( $sub_setting['type'] ) && isset( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] ) ) { + $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $post_global[ $field['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'] ); + } + } + } + + // Set up new data with validated data. + $new = $post_global[ $field['id'] ]; + } else { + + // Run through validation. + $new = ot_validate_setting( $post_global[ $field['id'] ], $field['type'], $field['id'] ); + } + + // Insert CSS. + if ( 'css' === $field['type'] ) { + + if ( '' !== $new ) { + + // insert CSS into dynamic.css. + ot_insert_css_with_markers( $field['id'], $new, true ); + } else { + + // Remove old CSS from dynamic.css. + ot_remove_old_css( $field['id'] ); + } + } + } + + if ( isset( $new ) && $new !== $old ) { + update_post_meta( $post_id, $field['id'], $new ); + } elseif ( '' === $new && $old ) { + delete_post_meta( $post_id, $field['id'], $old ); + } + } + } + + } + +} + +if ( ! function_exists( 'ot_register_meta_box' ) ) { + + /** + * This method instantiates the meta box class & builds the UI. + * + * @uses OT_Meta_Box() + * + * @param array $args Meta box arguments. + * + * @access public + * @since 2.0 + */ + function ot_register_meta_box( $args ) { + if ( ! $args ) { + return; + } + + new OT_Meta_Box( $args ); + } +} diff --git a/includes/ot-meta-box-api.php b/includes/ot-meta-box-api.php deleted file mode 100755 index 2dc957f..0000000 --- a/includes/ot-meta-box-api.php +++ /dev/null @@ -1,363 +0,0 @@ - - * @copyright Copyright (c) 2013, Derek Herman - */ -if ( ! class_exists( 'OT_Meta_Box' ) ) { - - class OT_Meta_Box { - - /* variable to store the meta box array */ - private $meta_box; - - /** - * PHP5 constructor method. - * - * This method adds other methods of the class to specific hooks within WordPress. - * - * @uses add_action() - * - * @return void - * - * @access public - * @since 1.0 - */ - function __construct( $meta_box ) { - if ( ! is_admin() ) - return; - - global $ot_meta_boxes; - - if ( ! isset( $ot_meta_boxes ) ) { - $ot_meta_boxes = array(); - } - - $ot_meta_boxes[] = $meta_box; - - $this->meta_box = $meta_box; - - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); - - add_action( 'save_post', array( $this, 'save_meta_box' ), 1, 2 ); - - } - - /** - * Adds meta box to any post type - * - * @uses add_meta_box() - * - * @return void - * - * @access public - * @since 1.0 - */ - function add_meta_boxes() { - foreach ( (array) $this->meta_box['pages'] as $page ) { - add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( $this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] ); - } - } - - /** - * Meta box view - * - * @return string - * - * @access public - * @since 1.0 - */ - function build_meta_box( $post, $metabox ) { - - echo '
        '; - - /* Use nonce for verification */ - echo ''; - - /* meta box description */ - echo isset( $this->meta_box['desc'] ) && ! empty( $this->meta_box['desc'] ) ? '
        ' . htmlspecialchars_decode( $this->meta_box['desc'] ) . '
        ' : ''; - - /* loop through meta box fields */ - foreach ( $this->meta_box['fields'] as $field ) { - - /* get current post meta data */ - $field_value = get_post_meta( $post->ID, $field['id'], true ); - - /* set standard value */ - if ( isset( $field['std'] ) ) { - $field_value = ot_filter_std_value( $field_value, $field['std'] ); - } - - /* build the arguments array */ - $_args = array( - 'type' => $field['type'], - 'field_id' => $field['id'], - 'field_name' => $field['id'], - 'field_value' => $field_value, - 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', - 'field_std' => isset( $field['std'] ) ? $field['std'] : '', - 'field_rows' => isset( $field['rows'] ) && ! empty( $field['rows'] ) ? $field['rows'] : 10, - 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', - 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', - 'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', - 'field_class' => isset( $field['class'] ) ? $field['class'] : '', - 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', - 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', - 'field_choices' => isset( $field['choices'] ) ? $field['choices'] : array(), - 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), - 'post_id' => $post->ID, - 'meta' => true - ); - - $conditions = ''; - - /* setup the conditions */ - if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { - - $conditions = ' data-condition="' . $field['condition'] . '"'; - $conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : ''; - - } - - /* only allow simple textarea due to DOM issues with wp_editor() */ - if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' ) - $_args['type'] = 'textarea-simple'; - - // Build the setting CSS class - if ( ! empty( $_args['field_class'] ) ) { - - $classes = explode( ' ', $_args['field_class'] ); - - foreach( $classes as $key => $value ) { - - $classes[$key] = $value . '-wrap'; - - } - - $class = 'format-settings ' . implode( ' ', $classes ); - - } else { - - $class = 'format-settings'; - - } - - /* option label */ - echo '
        '; - - echo '
        '; - - /* don't show title with textblocks */ - if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) { - echo '
        '; - echo ''; - echo '
        '; - } - - /* get the option HTML */ - echo ot_display_by_type( $_args ); - - echo '
        '; - - echo '
        '; - - } - - echo '
        '; - - echo '
        '; - - } - - /** - * Saves the meta box values - * - * @return void - * - * @access public - * @since 1.0 - */ - function save_meta_box( $post_id, $post_object ) { - global $pagenow; - - /* don't save if $_POST is empty */ - if ( empty( $_POST ) || ( isset( $_POST['vc_inline'] ) && $_POST['vc_inline'] == true ) ) - return $post_id; - - /* don't save during quick edit */ - if ( $pagenow == 'admin-ajax.php' ) - return $post_id; - - /* don't save during autosave */ - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) - return $post_id; - - /* don't save if viewing a revision */ - if ( $post_object->post_type == 'revision' || $pagenow == 'revision.php' ) - return $post_id; - - /* verify nonce */ - if ( isset( $_POST[ $this->meta_box['id'] . '_nonce'] ) && ! wp_verify_nonce( $_POST[ $this->meta_box['id'] . '_nonce'], $this->meta_box['id'] ) ) - return $post_id; - - /* check permissions */ - if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { - if ( ! current_user_can( 'edit_page', $post_id ) ) - return $post_id; - } else { - if ( ! current_user_can( 'edit_post', $post_id ) ) - return $post_id; - } - - foreach ( $this->meta_box['fields'] as $field ) { - - $old = get_post_meta( $post_id, $field['id'], true ); - $new = ''; - - /* there is data to validate */ - if ( isset( $_POST[$field['id']] ) ) { - - /* slider and list item */ - if ( in_array( $field['type'], array( 'list-item', 'slider' ) ) ) { - - /* required title setting */ - $required_setting = array( - array( - 'id' => 'title', - 'label' => __( 'Title', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'text', - 'rows' => '', - 'class' => 'option-tree-setting-title', - 'post_type' => '', - 'choices' => array() - ) - ); - - /* get the settings array */ - $settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array(); - - /* settings are empty for some odd ass reason get the defaults */ - if ( empty( $settings ) ) { - $settings = 'slider' == $field['type'] ? - ot_slider_settings( $field['id'] ) : - ot_list_item_settings( $field['id'] ); - } - - /* merge the two settings array */ - $settings = array_merge( $required_setting, $settings ); - - foreach( $_POST[$field['id']] as $k => $setting_array ) { - - foreach( $settings as $sub_setting ) { - - /* verify sub setting has a type & value */ - if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) { - - $_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] ); - - } - - } - - } - - /* set up new data with validated data */ - $new = $_POST[$field['id']]; - - } else if ( $field['type'] == 'social-links' ) { - - /* get the settings array */ - $settings = isset( $_POST[$field['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$field['id'] . '_settings_array'] ) ) : array(); - - /* settings are empty get the defaults */ - if ( empty( $settings ) ) { - $settings = ot_social_links_settings( $field['id'] ); - } - - foreach( $_POST[$field['id']] as $k => $setting_array ) { - - foreach( $settings as $sub_setting ) { - - /* verify sub setting has a type & value */ - if ( isset( $sub_setting['type'] ) && isset( $_POST[$field['id']][$k][$sub_setting['id']] ) ) { - - $_POST[$field['id']][$k][$sub_setting['id']] = ot_validate_setting( $_POST[$field['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'] ); - - } - - } - - } - - /* set up new data with validated data */ - $new = $_POST[$field['id']]; - - } else { - - /* run through validattion */ - $new = ot_validate_setting( $_POST[$field['id']], $field['type'], $field['id'] ); - - } - - /* insert CSS */ - if ( $field['type'] == 'css' ) { - - /* insert CSS into dynamic.css */ - if ( '' !== $new ) { - - ot_insert_css_with_markers( $field['id'], $new, true ); - - /* remove old CSS from dynamic.css */ - } else { - - ot_remove_old_css( $field['id'] ); - - } - - } - - } - - if ( isset( $new ) && $new !== $old ) { - update_post_meta( $post_id, $field['id'], $new ); - } else if ( '' == $new && $old ) { - delete_post_meta( $post_id, $field['id'], $old ); - } - } - - } - - } - -} - -/** - * This method instantiates the meta box class & builds the UI. - * - * @uses OT_Meta_Box() - * - * @param array Array of arguments to create a meta box - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_register_meta_box' ) ) { - - function ot_register_meta_box( $args ) { - if ( ! $args ) - return; - - $ot_meta_box = new OT_Meta_Box( $args ); - } - -} - -/* End of file ot-meta-box-api.php */ -/* Location: ./includes/ot-meta-box-api.php */ \ No newline at end of file From 23bf26152b0981d6bd01684941f82915a96fd119 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 22:41:36 -0800 Subject: [PATCH 10/67] Fix typo --- includes/class-ot-cleanup.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-ot-cleanup.php b/includes/class-ot-cleanup.php index d636991..0e888b2 100755 --- a/includes/class-ot-cleanup.php +++ b/includes/class-ot-cleanup.php @@ -1,6 +1,6 @@ Date: Sat, 2 Mar 2019 22:43:44 -0800 Subject: [PATCH 11/67] Prevent object injection --- ot-loader.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/ot-loader.php b/ot-loader.php index 035d6c3..702efe4 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -275,7 +275,7 @@ private function admin_includes() { // Include the meta box api. if ( true === OT_META_BOXES ) { - $files[] = 'ot-meta-box-api'; + $files[] = 'class-ot-meta-box'; } // Include the post formats api. @@ -581,9 +581,18 @@ public function add_list_item() { $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0; $get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : ''; $type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : ''; - $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'a:0:{}'; + $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'YTowOnt9'; // Fallback is an empty encoded array. + $decoded = ot_decode( $settings ); - ot_list_item_view( $name, $count, array(), $post_id, $get_option, unserialize( ot_decode( $settings ) ), $type ); // phpcs:ignore + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + echo esc_html__( 'Settings are invalid.', 'option-tree' ); + wp_die(); + } + + ot_list_item_view( $name, $count, array(), $post_id, $get_option, maybe_unserialize( $decoded ), $type ); wp_die(); } @@ -598,9 +607,18 @@ public function add_social_links() { $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0; $get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : ''; $type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : ''; - $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'a:0:{}'; + $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'YTowOnt9'; // Fallback is an empty encoded array. + $decoded = ot_decode( $settings ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + echo esc_html__( 'Settings are invalid.', 'option-tree' ); + wp_die(); + } - ot_social_links_view( $name, $count, array(), $post_id, $get_option, unserialize( ot_decode( $settings ) ), $type ); // phpcs:ignore + ot_social_links_view( $name, $count, array(), $post_id, $get_option, maybe_unserialize( $decoded ), $type ); wp_die(); } From 5e3e5bfa3270b273952186c941ec1e6180ce5ee0 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sat, 2 Mar 2019 23:00:27 -0800 Subject: [PATCH 12/67] Fix phpcs issues --- includes/ot-functions.php | 650 ++++++++++++++++++-------------------- 1 file changed, 308 insertions(+), 342 deletions(-) diff --git a/includes/ot-functions.php b/includes/ot-functions.php index 2f4812f..953af4f 100755 --- a/includes/ot-functions.php +++ b/includes/ot-functions.php @@ -1,397 +1,363 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Theme Options ID - * - * @return string - * - * @access public - * @since 2.3.0 - */ +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + if ( ! function_exists( 'ot_options_id' ) ) { - function ot_options_id() { - - return apply_filters( 'ot_options_id', 'option_tree' ); - - } - + /** + * Theme Options ID + * + * @return string + * + * @access public + * @since 2.3.0 + */ + function ot_options_id() { + + return apply_filters( 'ot_options_id', 'option_tree' ); + + } } -/** - * Theme Settings ID - * - * @return string - * - * @access public - * @since 2.3.0 - */ if ( ! function_exists( 'ot_settings_id' ) ) { - function ot_settings_id() { - - return apply_filters( 'ot_settings_id', 'option_tree_settings' ); - - } - + /** + * Theme Settings ID + * + * @return string + * + * @access public + * @since 2.3.0 + */ + function ot_settings_id() { + + return apply_filters( 'ot_settings_id', 'option_tree_settings' ); + + } } -/** - * Theme Layouts ID - * - * @return string - * - * @access public - * @since 2.3.0 - */ if ( ! function_exists( 'ot_layouts_id' ) ) { - function ot_layouts_id() { - - return apply_filters( 'ot_layouts_id', 'option_tree_layouts' ); - - } - + /** + * Theme Layouts ID + * + * @return string + * + * @access public + * @since 2.3.0 + */ + function ot_layouts_id() { + + return apply_filters( 'ot_layouts_id', 'option_tree_layouts' ); + + } } -/** - * Get Option. - * - * Helper function to return the option value. - * If no value has been saved, it returns $default. - * - * @param string The option ID. - * @param string The default option value. - * @return mixed - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_get_option' ) ) { - function ot_get_option( $option_id, $default = '' ) { - - /* get the saved options */ - $options = get_option( ot_options_id() ); - - /* look for the saved value */ - if ( isset( $options[$option_id] ) && '' != $options[$option_id] ) { - - return ot_wpml_filter( $options, $option_id ); - - } - - return $default; - - } - + /** + * Get Option. + * + * Helper function to return the option value. + * If no value has been saved, it returns $default. + * + * @param string $option_id The option ID. + * @param string $default The default option value. + * @return mixed + * + * @access public + * @since 2.0 + */ + function ot_get_option( $option_id, $default = '' ) { + + // Get the saved options. + $options = get_option( ot_options_id() ); + + // Look for the saved value. + if ( isset( $options[ $option_id ] ) && '' !== $options[ $option_id ] ) { + + return ot_wpml_filter( $options, $option_id ); + + } + + return $default; + + } } -/** - * Echo Option. - * - * Helper function to echo the option value. - * If no value has been saved, it echos $default. - * - * @param string The option ID. - * @param string The default option value. - * @return mixed - * - * @access public - * @since 2.2.0 - */ if ( ! function_exists( 'ot_echo_option' ) ) { - - function ot_echo_option( $option_id, $default = '' ) { - - echo ot_get_option( $option_id, $default ); - - } - + + /** + * Echo Option. + * + * Helper function to echo the option value. + * If no value has been saved, it echos $default. + * + * @param string $option_id The option ID. + * @param string $default The default option value. + * @return mixed + * + * @access public + * @since 2.2.0 + */ + function ot_echo_option( $option_id, $default = '' ) { + + echo ot_get_option( $option_id, $default ); // phpcs:ignore + + } } -/** - * Filter the return values through WPML - * - * @param array $options The current options - * @param string $option_id The option ID - * @return mixed - * - * @access public - * @since 2.1 - */ if ( ! function_exists( 'ot_wpml_filter' ) ) { - function ot_wpml_filter( $options, $option_id ) { - - // Return translated strings using WMPL - if ( function_exists('icl_t') ) { - - $settings = get_option( ot_settings_id() ); - - if ( isset( $settings['settings'] ) ) { - - foreach( $settings['settings'] as $setting ) { - - // List Item & Slider - if ( $option_id == $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) { - - foreach( $options[$option_id] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - $id = $option_id . '_' . $ckey . '_' . $key; - $_string = icl_t( 'Theme Options', $id, $cvalue ); - - if ( ! empty( $_string ) ) { - - $options[$option_id][$key][$ckey] = $_string; - - } - - } - - } - - // List Item & Slider - } else if ( $option_id == $setting['id'] && $setting['type'] == 'social-links' ) { - - foreach( $options[$option_id] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - $id = $option_id . '_' . $ckey . '_' . $key; - $_string = icl_t( 'Theme Options', $id, $cvalue ); - - if ( ! empty( $_string ) ) { - - $options[$option_id][$key][$ckey] = $_string; - - } - - } - - } - - // All other acceptable option types - } else if ( $option_id == $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ) ) ) { - - $_string = icl_t( 'Theme Options', $option_id, $options[$option_id] ); - - if ( ! empty( $_string ) ) { - - $options[$option_id] = $_string; - - } - - } - - } - - } - - } - - return $options[$option_id]; - - } + /** + * Filter the return values through WPML + * + * @param array $options The current options. + * @param string $option_id The option ID. + * @return mixed + * + * @access public + * @since 2.1 + */ + function ot_wpml_filter( $options, $option_id ) { -} + // Return translated strings using WMPL. + if ( function_exists( 'icl_t' ) ) { -/** - * Enqueue the dynamic CSS. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_load_dynamic_css' ) ) { + $settings = get_option( ot_settings_id() ); - function ot_load_dynamic_css() { - - /* don't load in the admin */ - if ( is_admin() ) { - return; - } - - /** - * Filter whether or not to enqueue a `dynamic.css` file at the theme level. - * - * By filtering this to `false` OptionTree will not attempt to enqueue any CSS files. - * - * Example: add_filter( 'ot_load_dynamic_css', '__return_false' ); - * - * @since 2.5.5 - * - * @param bool $load_dynamic_css Default is `true`. - * @return bool - */ - if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) { - return; - } - - /* grab a copy of the paths */ - $ot_css_file_paths = get_option( 'ot_css_file_paths', array() ); - if ( is_multisite() ) { - $ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); - } - - if ( ! empty( $ot_css_file_paths ) ) { - - $last_css = ''; - - /* loop through paths */ - foreach( $ot_css_file_paths as $key => $path ) { - - if ( '' != $path && file_exists( $path ) ) { - - $parts = explode( '/wp-content', $path ); - - if ( isset( $parts[1] ) ) { - - $sub_parts = explode( '/', $parts[1] ); - - if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) { - if ( $sub_parts[1] == 'themes' && $sub_parts[2] != get_stylesheet() ) { - continue; - } - } - - $css = set_url_scheme( WP_CONTENT_URL ) . $parts[1]; - - if ( $last_css !== $css ) { - - /* enqueue filtered file */ - wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION ); - - $last_css = $css; - - } - - } - - } - - } - - } - - } - -} + if ( isset( $settings['settings'] ) ) { -/** - * Enqueue the Google Fonts CSS. - * - * @return void - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_load_google_fonts_css' ) ) { + foreach ( $settings['settings'] as $setting ) { - function ot_load_google_fonts_css() { + // List Item & Slider. + if ( $option_id === $setting['id'] && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) { - /* don't load in the admin */ - if ( is_admin() ) - return; + foreach ( $options[ $option_id ] as $key => $value ) { - $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); - $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); - $families = array(); - $subsets = array(); - $append = ''; + foreach ( $value as $ckey => $cvalue ) { - if ( ! empty( $ot_set_google_fonts ) ) { + $id = $option_id . '_' . $ckey . '_' . $key; + $_string = icl_t( 'Theme Options', $id, $cvalue ); - foreach( $ot_set_google_fonts as $id => $fonts ) { + if ( ! empty( $_string ) ) { - foreach( $fonts as $font ) { + $options[ $option_id ][ $key ][ $ckey ] = $_string; + } + } + } - // Can't find the font, bail! - if ( ! isset( $ot_google_fonts[$font['family']]['family'] ) ) { - continue; - } + // List Item & Slider. + } elseif ( $option_id === $setting['id'] && 'social-links' === $setting['type'] ) { - // Set variants & subsets - if ( ! empty( $font['variants'] ) && is_array( $font['variants'] ) ) { + foreach ( $options[ $option_id ] as $key => $value ) { - // Variants string - $variants = ':' . implode( ',', $font['variants'] ); + foreach ( $value as $ckey => $cvalue ) { - // Add subsets to array - if ( ! empty( $font['subsets'] ) && is_array( $font['subsets'] ) ) { - foreach( $font['subsets'] as $subset ) { - $subsets[] = $subset; - } - } + $id = $option_id . '_' . $ckey . '_' . $key; + $_string = icl_t( 'Theme Options', $id, $cvalue ); - } + if ( ! empty( $_string ) ) { - // Add family & variants to array - if ( isset( $variants ) ) { - $families[] = str_replace( ' ', '+', $ot_google_fonts[$font['family']]['family'] ) . $variants; - } + $options[ $option_id ][ $key ][ $ckey ] = $_string; + } + } + } - } + // All other acceptable option types. + } elseif ( $option_id === $setting['id'] && in_array( $setting['type'], apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ), true ) ) { - } + $_string = icl_t( 'Theme Options', $option_id, $options[ $option_id ] ); - } + if ( ! empty( $_string ) ) { - if ( ! empty( $families ) ) { + $options[ $option_id ] = $_string; + } + } + } + } + } - $families = array_unique( $families ); + return $options[ $option_id ]; + } +} - // Append all subsets to the path, unless the only subset is latin. - if ( ! empty( $subsets ) ) { - $subsets = implode( ',', array_unique( $subsets ) ); - if ( $subsets != 'latin' ) { - $append = '&subset=' . $subsets; - } - } +if ( ! function_exists( 'ot_load_dynamic_css' ) ) { - wp_enqueue_style( 'ot-google-fonts', esc_url( '//fonts.googleapis.com/css?family=' . implode( '%7C', $families ) ) . $append, false, null ); - } + /** + * Enqueue the dynamic CSS. + * + * @access public + * @since 2.0 + */ + function ot_load_dynamic_css() { + + // Don't load in the admin. + if ( is_admin() ) { + return; + } + + /** + * Filter whether or not to enqueue a `dynamic.css` file at the theme level. + * + * By filtering this to `false` OptionTree will not attempt to enqueue any CSS files. + * + * Example: add_filter( 'ot_load_dynamic_css', '__return_false' ); + * + * @since 2.5.5 + * + * @param bool $load_dynamic_css Default is `true`. + * @return bool + */ + if ( false === (bool) apply_filters( 'ot_load_dynamic_css', true ) ) { + return; + } + + // Grab a copy of the paths. + $ot_css_file_paths = get_option( 'ot_css_file_paths', array() ); + if ( is_multisite() ) { + $ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); + } + + if ( ! empty( $ot_css_file_paths ) ) { + + $last_css = ''; + + // Loop through paths. + foreach ( $ot_css_file_paths as $key => $path ) { + + if ( '' !== $path && file_exists( $path ) ) { + + $parts = explode( '/wp-content', $path ); + + if ( isset( $parts[1] ) ) { + + $sub_parts = explode( '/', $parts[1] ); + + if ( isset( $sub_parts[1] ) && isset( $sub_parts[2] ) ) { + if ( 'themes' !== $sub_parts[1] && get_stylesheet() !== $sub_parts[2] ) { + continue; + } + } + + $css = set_url_scheme( WP_CONTENT_URL ) . $parts[1]; + + if ( $last_css !== $css ) { + + // Enqueue filtered file. + wp_enqueue_style( 'ot-dynamic-' . $key, $css, false, OT_VERSION ); + + $last_css = $css; + } + } + } + } + } + + } +} - } +if ( ! function_exists( 'ot_load_google_fonts_css' ) ) { + /** + * Enqueue the Google Fonts CSS. + * + * @access public + * @since 2.5.0 + */ + function ot_load_google_fonts_css() { + + /* don't load in the admin */ + if ( is_admin() ) { + return; + } + + $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); + $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + $families = array(); + $subsets = array(); + $append = ''; + + if ( ! empty( $ot_set_google_fonts ) ) { + + foreach ( $ot_set_google_fonts as $id => $fonts ) { + + foreach ( $fonts as $font ) { + + // Can't find the font, bail! + if ( ! isset( $ot_google_fonts[ $font['family'] ]['family'] ) ) { + continue; + } + + // Set variants & subsets. + if ( ! empty( $font['variants'] ) && is_array( $font['variants'] ) ) { + + // Variants string. + $variants = ':' . implode( ',', $font['variants'] ); + + // Add subsets to array. + if ( ! empty( $font['subsets'] ) && is_array( $font['subsets'] ) ) { + foreach ( $font['subsets'] as $subset ) { + $subsets[] = $subset; + } + } + } + + // Add family & variants to array. + if ( isset( $variants ) ) { + $families[] = str_replace( ' ', '+', $ot_google_fonts[ $font['family'] ]['family'] ) . $variants; + } + } + } + } + + if ( ! empty( $families ) ) { + + $families = array_unique( $families ); + + // Append all subsets to the path, unless the only subset is latin. + if ( ! empty( $subsets ) ) { + $subsets = implode( ',', array_unique( $subsets ) ); + if ( 'latin' !== $subsets ) { + $append = '&subset=' . $subsets; + } + } + + wp_enqueue_style( 'ot-google-fonts', esc_url( '//fonts.googleapis.com/css?family=' . implode( '%7C', $families ) ) . $append, false, null ); // phpcs:ignore + } + } } -/** - * Registers the Theme Option page link for the admin bar. - * - * @return void - * - * @access public - * @since 2.1 - */ if ( ! function_exists( 'ot_register_theme_options_admin_bar_menu' ) ) { - function ot_register_theme_options_admin_bar_menu( $wp_admin_bar ) { - - if ( ! current_user_can( apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ) ) || ! is_admin_bar_showing() ) - return; - - $wp_admin_bar->add_node( array( - 'parent' => 'appearance', - 'id' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ), - 'title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ), - 'href' => admin_url( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) - ) ); - - } - + /** + * Registers the Theme Option page link for the admin bar. + * + * @access public + * @since 2.1 + * + * @param object $wp_admin_bar The WP_Admin_Bar object. + */ + function ot_register_theme_options_admin_bar_menu( $wp_admin_bar ) { + + if ( ! current_user_can( apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ) ) || ! is_admin_bar_showing() ) { + return; + } + + $wp_admin_bar->add_node( + array( + 'parent' => 'appearance', + 'id' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ), + 'title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ), + 'href' => admin_url( apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ) . '?page=' . apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ), + ) + ); + } } - -/* End of file ot-functions.php */ -/* Location: ./includes/ot-functions.php */ \ No newline at end of file From e5da3f899154f483a11590dba54df9fcc0688878 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 00:39:45 -0800 Subject: [PATCH 13/67] Fix phpcs issues --- includes/ot-functions-deprecated.php | 169 +++++++++++++-------------- 1 file changed, 82 insertions(+), 87 deletions(-) diff --git a/includes/ot-functions-deprecated.php b/includes/ot-functions-deprecated.php index ac1d97d..98b30c5 100755 --- a/includes/ot-functions-deprecated.php +++ b/includes/ot-functions-deprecated.php @@ -1,99 +1,94 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Displays or returns a value from the 'option_tree' array. - * - * @param string $item_id - * @param array $options - * @param bool $echo - * @param bool $is_array - * @param int $offset - * @return mixed array or comma seperated lists of values - * - * @access public - * @since 1.0.0 - * @updated 2.0 - * @deprecated 2.0 - */ +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + if ( ! function_exists( 'get_option_tree' ) ) { - function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) { - /* load saved options */ - if ( ! $options ) - $options = get_option( ot_options_id() ); - - /* no value return */ - if ( ! isset( $options[$item_id] ) || empty( $options[$item_id] ) ) - return; - - /* set content value & strip slashes */ - $content = option_tree_stripslashes( $options[$item_id] ); - - /* is an array */ - if ( $is_array == true ) { - /* saved as a comma seperated lists of values, explode into an array */ - if ( !is_array( $content ) ) - $content = explode( ',', $content ); - - /* get an array value using an offset */ - if ( is_numeric( $offset ) && $offset >= 0 ) { - $content = $content[$offset]; - } else if ( ! is_numeric( $offset ) && isset( $content[$offset] ) ) { - $content = $content[$offset]; - } - - /* not an array */ - } else if ( $is_array == false ) { - /* saved as array, implode and return a comma seperated lists of values */ - if ( is_array( $content ) ) - $content = implode( ',', $content ); /* This is fucked */ - } - - /* echo content */ - if ( $echo ) - echo $content; - - return $content; - } + /** + * Displays or returns a value from the 'option_tree' array. + * + * @param string $item_id The item ID. + * @param array $options Options array. + * @param bool $echo Whether to echo or return value. + * @param bool $is_array Whether the value option is an array or string. + * @param int $offset The array key. + * @return mixed Array or comma separated lists of values. + * + * @access public + * @since 1.0.0 + * @updated 2.0 + * @deprecated 2.0 + */ + function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) { -} + // Load saved options. + if ( ! $options ) { + $options = get_option( ot_options_id() ); + } -/** - * Custom stripslashes from single value or array. - * - * @param mixed $input - * @return mixed - * - * @access public - * @since 1.1.3 - * @deprecated 2.0 - */ -if ( ! function_exists( 'option_tree_stripslashes' ) ) { + // No value return. + if ( ! isset( $options[ $item_id ] ) || empty( $options[ $item_id ] ) ) { + return; + } + + // Set content value & strip slashes. + $content = option_tree_stripslashes( $options[ $item_id ] ); + + if ( true === $is_array ) { + if ( ! is_array( $content ) ) { + $content = explode( ',', $content ); + } - function option_tree_stripslashes( $input ) { - if ( is_array( $input ) ) { - foreach( $input as &$val ) { - if ( is_array( $val ) ) { - $val = option_tree_stripslashes( $val ); - } else { - $val = stripslashes( $val ); - } - } - } else { - $input = stripslashes( $input ); - } - return $input; - } + if ( is_numeric( $offset ) && 0 <= $offset ) { + $content = $content[ $offset ]; + } elseif ( ! is_numeric( $offset ) && isset( $content[ $offset ] ) ) { + $content = $content[ $offset ]; + } + } else { + if ( is_array( $content ) ) { + $content = implode( ',', $content ); + } + } + if ( $echo ) { + echo $content; // phpcs:ignore + } + + return $content; + } } -/* End of file ot-functions-deprecated.php */ -/* Location: ./includes/ot-functions-deprecated.php */ \ No newline at end of file +if ( ! function_exists( 'option_tree_stripslashes' ) ) { + + /** + * Custom stripslashes from single value or array. + * + * @param mixed $input Input string or array. + * @return mixed + * + * @access public + * @since 1.1.3 + * @deprecated 2.0 + */ + function option_tree_stripslashes( $input ) { + if ( is_array( $input ) ) { + foreach ( $input as &$val ) { + if ( is_array( $val ) ) { + $val = option_tree_stripslashes( $val ); + } else { + $val = stripslashes( $val ); + } + } + } else { + $input = stripslashes( $input ); + } + return $input; + } +} From da0fff96981f85a59875b86a069eb0d4e6240927 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 00:41:00 -0800 Subject: [PATCH 14/67] Fix param type --- includes/ot-functions-deprecated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ot-functions-deprecated.php b/includes/ot-functions-deprecated.php index 98b30c5..3f4cc7a 100755 --- a/includes/ot-functions-deprecated.php +++ b/includes/ot-functions-deprecated.php @@ -26,7 +26,7 @@ * @updated 2.0 * @deprecated 2.0 */ - function get_option_tree( $item_id = '', $options = '', $echo = false, $is_array = false, $offset = -1 ) { + function get_option_tree( $item_id = '', $options = array(), $echo = false, $is_array = false, $offset = -1 ) { // Load saved options. if ( ! $options ) { From 7ce6eff6d42987a4b7f873e9f20aa248e98a3871 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 01:13:43 -0800 Subject: [PATCH 15/67] Fix phpcs issues --- includes/ot-functions-compat.php | 671 ++++++++++++++++--------------- 1 file changed, 350 insertions(+), 321 deletions(-) diff --git a/includes/ot-functions-compat.php b/includes/ot-functions-compat.php index 48e9a4b..81b1494 100755 --- a/includes/ot-functions-compat.php +++ b/includes/ot-functions-compat.php @@ -1,364 +1,393 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/* run the actions & filters */ -add_action( 'admin_init', 'compat_ot_import_from_files', 1 ); -add_filter( 'ot_option_types_array', 'compat_ot_option_types_array', 10, 1 ); -add_filter( 'ot_recognized_font_styles', 'compat_ot_recognized_font_styles', 10, 2 ); -add_filter( 'ot_recognized_font_weights', 'compat_ot_recognized_font_weights', 10, 2 ); -add_filter( 'ot_recognized_font_variants', 'compat_ot_recognized_font_variants', 10, 2 ); -add_filter( 'ot_recognized_font_families', 'compat_ot_recognized_font_families', 10, 2 ); -add_filter( 'ot_recognized_background_repeat', 'compat_ot_recognized_background_repeat', 10, 2 ); -add_filter( 'ot_recognized_background_position', 'compat_ot_recognized_background_position', 10, 2 ); -add_filter( 'ot_measurement_unit_types', 'compat_ot_measurement_unit_types', 10, 2 ); +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + +// Run the actions & filters. +add_action( 'admin_init', 'compat_ot_import_from_files', 1 ); +add_filter( 'ot_option_types_array', 'compat_ot_option_types_array', 10, 1 ); +add_filter( 'ot_recognized_font_styles', 'compat_ot_recognized_font_styles', 10, 2 ); +add_filter( 'ot_recognized_font_weights', 'compat_ot_recognized_font_weights', 10, 2 ); +add_filter( 'ot_recognized_font_variants', 'compat_ot_recognized_font_variants', 10, 2 ); +add_filter( 'ot_recognized_font_families', 'compat_ot_recognized_font_families', 10, 2 ); +add_filter( 'ot_recognized_background_repeat', 'compat_ot_recognized_background_repeat', 10, 2 ); +add_filter( 'ot_recognized_background_position', 'compat_ot_recognized_background_position', 10, 2 ); +add_filter( 'ot_measurement_unit_types', 'compat_ot_measurement_unit_types', 10, 2 ); -/** - * Import from the old 1.x files for backwards compatibility. - * - * @return void - * - * @access private - * @since 2.0.8 - */ if ( ! function_exists( 'compat_ot_import_from_files' ) ) { - function compat_ot_import_from_files() { - - /* file path & name without extention */ - $ot_xml = '/option-tree/theme-options.xml'; - $ot_data = '/option-tree/theme-options.txt'; - $ot_layout = '/option-tree/layouts.txt'; - - /* XML file path - child theme first then parent */ - if ( is_readable( get_stylesheet_directory() . $ot_xml ) ) { - - $xml_file = get_stylesheet_directory_uri() . $ot_xml; - - } else if ( is_readable( get_template_directory() . $ot_xml ) ) { - - $xml_file = get_template_directory_uri() . $ot_xml; - - } - - /* Data file path - child theme first then parent */ - if ( is_readable( get_stylesheet_directory() . $ot_data ) ) { - - $data_file = get_stylesheet_directory_uri() . $ot_data; - - } else if ( is_readable( get_template_directory() . $ot_data ) ) { - - $data_file = get_template_directory_uri() . $ot_data; - - } - - /* Layout file path - child theme first then parent */ - if ( is_readable( get_stylesheet_directory() . $ot_layout ) ) { - - $layout_file = get_stylesheet_directory_uri() . $ot_layout; - - } else if ( is_readable( get_template_directory() . $ot_layout ) ) { - - $layout_file = get_template_directory_uri() . $ot_layout; - - } - - /* check for files */ - $has_xml = isset( $xml_file ) ? true : false; - $has_data = isset( $data_file ) ? true : false; - $has_layout = isset( $layout_file ) ? true : false; - - /* auto import XML file */ - if ( $has_xml == true && ! get_option( ot_settings_id() ) && class_exists( 'SimpleXMLElement' ) ) { - - $settings = ot_import_xml( $xml_file ); - - if ( isset( $settings ) && ! empty( $settings ) ) { - - update_option( ot_settings_id(), $settings ); - - } - - } - - /* auto import Data file */ - if ( $has_data == true && ! get_option( ot_options_id() ) ) { - - $get_data = wp_remote_get( $data_file ); - - if ( is_wp_error( $get_data ) ) - return false; - - $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; - $options = unserialize( ot_decode( $rawdata ) ); - - /* get settings array */ - $settings = get_option( ot_settings_id() ); - - /* has options */ - if ( is_array( $options ) ) { - - /* validate options */ - if ( is_array( $settings ) ) { - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $options[$setting['id']] ) ) { - - $content = ot_stripslashes( $options[$setting['id']] ); - - $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - - } - - } - - } - - /* update the option tree array */ - update_option( ot_options_id(), $options ); - - } - - } - - /* auto import Layout file */ - if ( $has_layout == true && ! get_option( ot_layouts_id() ) ) { - - $get_data = wp_remote_get( $layout_file ); - - if ( is_wp_error( $get_data ) ) - return false; - - $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; - $layouts = unserialize( ot_decode( $rawdata ) ); - - /* get settings array */ - $settings = get_option( ot_settings_id() ); - - /* has layouts */ - if ( is_array( $layouts ) ) { - - /* validate options */ - if ( is_array( $settings ) ) { - - foreach( $layouts as $key => $value ) { - - if ( $key == 'active_layout' ) - continue; - - $options = unserialize( ot_decode( $value ) ); - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $options[$setting['id']] ) ) { - - $content = ot_stripslashes( $options[$setting['id']] ); - - $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - - } - - } - - $layouts[$key] = ot_encode( serialize( $options ) ); - - } - - } - - /* update the option tree array */ - if ( isset( $layouts['active_layout'] ) ) { - - update_option( ot_options_id(), unserialize( ot_decode( $layouts[$layouts['active_layout']] ) ) ); - - } - - /* update the option tree layouts array */ - update_option( ot_layouts_id(), $layouts ); - - } - - } - - } + /** + * Import from the old 1.x files for backwards compatibility. + * + * @access private + * @since 2.0.8 + */ + function compat_ot_import_from_files() { + + // File path & name. + $ot_xml = '/option-tree/theme-options.xml'; + $ot_data = '/option-tree/theme-options.txt'; + $ot_layout = '/option-tree/layouts.txt'; + + // XML file path - child theme first then parent. + if ( is_readable( get_stylesheet_directory() . $ot_xml ) ) { + + $xml_file = get_stylesheet_directory_uri() . $ot_xml; + + } elseif ( is_readable( get_template_directory() . $ot_xml ) ) { + + $xml_file = get_template_directory_uri() . $ot_xml; + + } + + // Data file path - child theme first then parent. + if ( is_readable( get_stylesheet_directory() . $ot_data ) ) { + + $data_file = get_stylesheet_directory_uri() . $ot_data; + + } elseif ( is_readable( get_template_directory() . $ot_data ) ) { + + $data_file = get_template_directory_uri() . $ot_data; + + } + + // Layout file path - child theme first then parent. + if ( is_readable( get_stylesheet_directory() . $ot_layout ) ) { + + $layout_file = get_stylesheet_directory_uri() . $ot_layout; + + } elseif ( is_readable( get_template_directory() . $ot_layout ) ) { + + $layout_file = get_template_directory_uri() . $ot_layout; + + } + + // Check for files. + $has_xml = isset( $xml_file ) ? true : false; + $has_data = isset( $data_file ) ? true : false; + $has_layout = isset( $layout_file ) ? true : false; + + // Auto import XML file. + if ( true === $has_xml && ! get_option( ot_settings_id() ) && class_exists( 'SimpleXMLElement' ) ) { + + $settings = ot_import_xml( $xml_file ); + + if ( isset( $settings ) && ! empty( $settings ) ) { + + update_option( ot_settings_id(), $settings ); + + } + } + + // Auto import Data file. + if ( true === $has_data && ! get_option( ot_options_id() ) ) { + + $get_data = wp_remote_get( $data_file ); + + if ( is_wp_error( $get_data ) ) { + return false; + } + + $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; + $options = ot_decode( $rawdata ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $options, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + return; + } + + $options = maybe_unserialize( $options ); + + // Get settings array. + $settings = get_option( ot_settings_id() ); + + // Has options. + if ( is_array( $options ) ) { + + // Validate options. + if ( is_array( $settings ) ) { + + foreach ( $settings['settings'] as $setting ) { + + if ( isset( $options[ $setting['id'] ] ) ) { + + $content = ot_stripslashes( $options[ $setting['id'] ] ); + + $options[ $setting['id'] ] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); + + } + } + } + + // Update the option tree array. + update_option( ot_options_id(), $options ); + } + } + + // Auto import Layout file. + if ( true === $has_layout && ! get_option( ot_layouts_id() ) ) { + + $get_data = wp_remote_get( $layout_file ); + + if ( is_wp_error( $get_data ) ) { + return false; + } + + $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; + $layouts = ot_decode( $rawdata ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $layouts, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + return; + } + + $layouts = maybe_unserialize( $layouts ); + + // Get settings array. + $settings = get_option( ot_settings_id() ); + + // Has layouts. + if ( is_array( $layouts ) ) { + + // Validate options. + if ( is_array( $settings ) ) { + + foreach ( $layouts as $key => $value ) { + + if ( 'active_layout' === $key ) { + continue; + } + + $decoded = ot_decode( $value ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } + + $options = maybe_unserialize( $decoded ); + + foreach ( $settings['settings'] as $setting ) { + + if ( isset( $options[ $setting['id'] ] ) ) { + + $content = ot_stripslashes( $options[ $setting['id'] ] ); + + $options[ $setting['id'] ] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); + } + } + + $layouts[ $key ] = ot_encode( serialize( $options ) ); // phpcs:ignore + } + } + + // Update the option tree array. + if ( isset( $layouts['active_layout'] ) ) { + + $decoded = ot_decode( $layouts[ $layouts['active_layout'] ] ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + return; + } + + update_option( ot_options_id(), maybe_unserialize( $decoded ) ); + + } + + // Update the option tree layouts array. + update_option( ot_layouts_id(), $layouts ); + } + } + } } -/** - * Filters the option types array. - * - * Allows the old 'option_tree_option_types' filter to - * change the new 'ot_option_types_array' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_option_types_array' ) ) { - function compat_ot_option_types_array( $array ) { - - return apply_filters( 'option_tree_option_types', $array ); - - } + /** + * Filters the option types array. + * + * Allows the old 'option_tree_option_types' filter to + * change the new 'ot_option_types_array' return value. + * + * @param array $array The option types in key:value format. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_option_types_array( $array ) { + + return apply_filters( 'option_tree_option_types', $array ); + } } -/** - * Filters the recognized font styles array. - * - * Allows the old 'recognized_font_styles' filter to - * change the new 'ot_recognized_font_styles' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_font_styles' ) ) { - function compat_ot_recognized_font_styles( $array, $id ) { - - return apply_filters( 'recognized_font_styles', $array, $id ); - - } - + /** + * Filters the recognized font styles array. + * + * Allows the old 'recognized_font_styles' filter to + * change the new 'ot_recognized_font_styles' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_font_styles( $array, $id ) { + + return apply_filters( 'recognized_font_styles', $array, $id ); + + } } -/** - * Filters the recognized font weights array. - * - * Allows the old 'recognized_font_weights' filter to - * change the new 'ot_recognized_font_weights' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_font_weights' ) ) { - function compat_ot_recognized_font_weights( $array, $id ) { - - return apply_filters( 'recognized_font_weights', $array, $id ); - - } - + /** + * Filters the recognized font weights array. + * + * Allows the old 'recognized_font_weights' filter to + * change the new 'ot_recognized_font_weights' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_font_weights( $array, $id ) { + + return apply_filters( 'recognized_font_weights', $array, $id ); + + } } -/** - * Filters the recognized font variants array. - * - * Allows the old 'recognized_font_variants' filter to - * change the new 'ot_recognized_font_variants' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_font_variants' ) ) { - function compat_ot_recognized_font_variants( $array, $id ) { - - return apply_filters( 'recognized_font_variants', $array, $id ); - - } - + /** + * Filters the recognized font variants array. + * + * Allows the old 'recognized_font_variants' filter to + * change the new 'ot_recognized_font_variants' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_font_variants( $array, $id ) { + + return apply_filters( 'recognized_font_variants', $array, $id ); + + } } -/** - * Filters the recognized font families array. - * - * Allows the old 'recognized_font_families' filter to - * change the new 'ot_recognized_font_families' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_font_families' ) ) { - function compat_ot_recognized_font_families( $array, $id ) { - - return apply_filters( 'recognized_font_families', $array, $id ); - - } - + /** + * Filters the recognized font families array. + * + * Allows the old 'recognized_font_families' filter to + * change the new 'ot_recognized_font_families' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_font_families( $array, $id ) { + + return apply_filters( 'recognized_font_families', $array, $id ); + + } } -/** - * Filters the recognized background repeat array. - * - * Allows the old 'recognized_background_repeat' filter to - * change the new 'ot_recognized_background_repeat' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_background_repeat' ) ) { - function compat_ot_recognized_background_repeat( $array, $id ) { - - return apply_filters( 'recognized_background_repeat', $array, $id ); - - } - + /** + * Filters the recognized background repeat array. + * + * Allows the old 'recognized_background_repeat' filter to + * change the new 'ot_recognized_background_repeat' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_background_repeat( $array, $id ) { + + return apply_filters( 'recognized_background_repeat', $array, $id ); + + } } -/** - * Filters the recognized background position array. - * - * Allows the old 'recognized_background_position' filter to - * change the new 'ot_recognized_background_position' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_recognized_background_position' ) ) { - function compat_ot_recognized_background_position( $array, $id ) { - - return apply_filters( 'recognized_background_position', $array, $id ); - - } - + /** + * Filters the recognized background position array. + * + * Allows the old 'recognized_background_position' filter to + * change the new 'ot_recognized_background_position' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_recognized_background_position( $array, $id ) { + + return apply_filters( 'recognized_background_position', $array, $id ); + + } } -/** - * Filters the measurement unit types array. - * - * Allows the old 'measurement_unit_types' filter to - * change the new 'ot_measurement_unit_types' return value. - * - * @return array - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'compat_ot_measurement_unit_types' ) ) { - function compat_ot_measurement_unit_types( $array, $id ) { - - return apply_filters( 'measurement_unit_types', $array, $id ); - - } - -} + /** + * Filters the measurement unit types array. + * + * Allows the old 'measurement_unit_types' filter to + * change the new 'ot_measurement_unit_types' return value. + * + * @param array $array The option types in key:value format. + * @param string $id The field ID. + * @return array + * + * @access public + * @since 2.0 + */ + function compat_ot_measurement_unit_types( $array, $id ) { + return apply_filters( 'measurement_unit_types', $array, $id ); -/* End of file ot-functions-compat.php */ -/* Location: ./includes/ot-functions-compat.php */ \ No newline at end of file + } +} From d09d3e8f0752323ad73e88f97d150c5e538683fb Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 02:13:55 -0800 Subject: [PATCH 16/67] Fix phpcs issues --- includes/ot-functions-settings-page.php | 1046 +++++++++++------------ 1 file changed, 508 insertions(+), 538 deletions(-) diff --git a/includes/ot-functions-settings-page.php b/includes/ot-functions-settings-page.php index 6f768ad..eccc414 100755 --- a/includes/ot-functions-settings-page.php +++ b/includes/ot-functions-settings-page.php @@ -1,572 +1,542 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Create option type. - * - * @return string - * - * @access public - * @since 2.0 - */ +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + if ( ! function_exists( 'ot_type_theme_options_ui' ) ) { - - function ot_type_theme_options_ui() { - global $blog_id; - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'Warning!', 'option-tree' ) . '

        '; - echo '

        ' . sprintf( __( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ), 'Appearance->Theme Options' ) . '

        '; - echo '

        ' . sprintf( __( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ), 'OptionTree->Documentation' ) . '

        '; - echo '

        '. __( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '

        '; - echo '

        ' . __( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '

        '; - echo '

        ' . __( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '

        '; - echo '

        ' . __( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '

        '; - - echo '
        '; - - /* get the saved settings */ - $settings = get_option( ot_settings_id() ); - - /* wrap settings array */ - echo '
        '; - - /* set count to zero */ - $count = 0; - - /* loop through each section and its settings */ - echo '
          '; - - if ( isset( $settings['sections'] ) ) { - - foreach( $settings['sections'] as $section ) { - - /* section */ - echo '
        • ' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '
        • '; - - /* increment item count */ - $count++; - - /* settings in this section */ - if ( isset( $settings['settings'] ) ) { - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $setting['section'] ) && $setting['section'] == $section['id'] ) { - - echo '
        • ' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '
        • '; - - /* increment item count */ - $count++; - - } - - } - - } - - } - - } - - echo '
        '; - - /* buttons */ - echo '' . __( 'Add Section', 'option-tree' ) . ''; - echo '' . __( 'Add Setting', 'option-tree' ) . ''; - echo ''; - - /* sidebar textarea */ - echo ' -
        -

        ' . __( 'Contextual Help', 'option-tree' ) . '

        -
        -
        -
        -
        ' . __( 'Contextual Help Sidebar', 'option-tree' ) . ': ' . __( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '
        -
        - -
        -
        -
        '; - - /* set count to zero */ - $count = 0; - - /* loop through each contextual_help content section */ - echo '
          '; - - if ( isset( $settings['contextual_help']['content'] ) ) { - - foreach( $settings['contextual_help']['content'] as $content ) { - - /* content */ - echo '
        • ' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '
        • '; - - /* increment content count */ - $count++; - - } - - } - - echo '
        '; - - echo '' . __( 'Add Contextual Help Content', 'option-tree' ) . ''; - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Create option type. + * + * @access public + * @since 2.0 + */ + function ot_type_theme_options_ui() { + global $blog_id; + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'option_tree_settings_form', 'option_tree_settings_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'Warning!', 'option-tree' ) . '

        '; + + /* translators: %s: link to theme options */ + $string = esc_html__( 'Go to the %s page if you want to save data, this page is for adding settings.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + /* translators: %s: link to documentation */ + $string = esc_html__( 'If you\'re unsure or not completely positive that you should be editing these settings, you should read the %s first.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Things could break or be improperly displayed to the end-user if you do one of the following:', 'option-tree' ) . '

        '; + echo '

        ' . esc_html__( 'Give two sections the same ID, give two settings the same ID, give two contextual help content areas the same ID, don\'t create any settings, or have a section at the end of the settings list.', 'option-tree' ) . '

        '; + echo '

        ' . esc_html__( 'You can create as many settings as your project requires and use them how you see fit. When you add a setting here, it will be available on the Theme Options page for use in your theme. To separate your settings into sections, click the "Add Section" button, fill in the input fields, and a new navigation menu item will be created.', 'option-tree' ) . '

        '; + echo '

        ' . esc_html__( 'All of the settings can be sorted and rearranged to your liking with Drag & Drop. Don\'t worry about the order in which you create your settings, you can always reorder them.', 'option-tree' ) . '

        '; + + echo '
        '; + + // Get the saved settings. + $settings = get_option( ot_settings_id() ); + + // Wrap settings array. + echo '
        '; + + // Set count to zero. + $count = 0; + + // Loop through each section and its settings. + echo '
          '; + + if ( isset( $settings['sections'] ) ) { + + foreach ( $settings['sections'] as $section ) { + + // Section. + echo '
        • ' . ot_sections_view( ot_settings_id() . '[sections]', $count, $section ) . '
        • '; // phpcs:ignore + + // Increment item count. + $count++; + + // Settings in this section. + if ( isset( $settings['settings'] ) ) { + + foreach ( $settings['settings'] as $setting ) { + + if ( isset( $setting['section'] ) && $setting['section'] === $section['id'] ) { + + echo '
        • ' . ot_settings_view( ot_settings_id() . '[settings]', $count, $setting ) . '
        • '; // phpcs:ignore + + // Increment item count. + $count++; + } + } + } + } + } + + echo '
        '; + + // Buttons. + echo '' . esc_html__( 'Add Section', 'option-tree' ) . ''; + echo '' . esc_html__( 'Add Setting', 'option-tree' ) . ''; + echo ''; + + // Sidebar textarea. + echo ' +
        +

        ' . esc_html__( 'Contextual Help', 'option-tree' ) . '

        +
        +
        +
        +
        ' . esc_html__( 'Contextual Help Sidebar', 'option-tree' ) . ': ' . esc_html__( 'If you decide to add contextual help to the Theme Option page, enter the optional "Sidebar" HTML here. This would be an extremely useful place to add links to your themes documentation or support forum. Only after you\'ve added some content below will this display to the user.', 'option-tree' ) . '
        +
        + +
        +
        +
        '; + + // Set count to zero. + $count = 0; + + // Loop through each contextual_help content section. + echo '
          '; + + if ( isset( $settings['contextual_help']['content'] ) ) { + + foreach ( $settings['contextual_help']['content'] as $content ) { + + // Content. + echo '
        • ' . ot_contextual_help_view( ot_settings_id() . '[contextual_help][content]', $count, $content ) . '
        • '; // phpcs:ignore + + // Increment content count. + $count++; + } + } + + echo '
        '; + + echo '' . esc_html__( 'Add Contextual Help Content', 'option-tree' ) . ''; + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Import XML option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_import_xml' ) ) { - - function ot_type_import_xml() { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'import_xml_form', 'import_xml_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '

        '; - - echo '

        ' . sprintf( __( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the upload button. A popup window will appear, upload the XML file and click "%s". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ) . '

        '; - - /* button */ - echo ''; - - echo '
        '; - - echo '
        '; - - /* build upload */ - echo '
        '; - - /* input */ - echo ''; - - /* get media post_id */ - $post_id = ( $id = ot_get_media_post_ID() ) ? (int) $id : 0; - - /* add xml button */ - echo '' . __( 'Add XML', 'option-tree' ) . ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Import XML option type. + * + * @access public + * @since 2.0 + */ + function ot_type_import_xml() { + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'import_xml_form', 'import_xml_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '

        '; + + /* translators: %s: button text */ + echo '

        ' . sprintf( esc_html__( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the upload button. A popup window will appear, upload the XML file and click "%s". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ), esc_html( apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ) ) . '

        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + // Build upload. + echo '
        '; + + // Input. + echo ''; + + // Get media post_id. + $id = ot_get_media_post_ID(); + $post_id = $id ? absint( $id ) : 0; + + // Add xml button. + echo '' . esc_html__( 'Add XML', 'option-tree' ) . ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Import Settings option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_import_settings' ) ) { - - function ot_type_import_settings() { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'import_settings_form', 'import_settings_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '

        '; - - /* button */ - echo ''; - - echo '
        '; - - /* textarea */ - echo '
        '; - - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Import Settings option type. + * + * @access public + * @since 2.0 + */ + function ot_type_import_settings() { + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'import_settings_form', 'import_settings_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'To import your Settings copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Settings" button.', 'option-tree' ) . '

        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + + } } -/** - * Import Data option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_import_data' ) ) { - - function ot_type_import_data() { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'import_data_form', 'import_data_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - if ( OT_SHOW_SETTINGS_IMPORT ) echo '

        ' . __( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '

        '; - - /* button */ - echo ''; - - echo '
        '; - - /* textarea */ - echo '
        '; - - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Import Data option type. + * + * @access public + * @since 2.0 + */ + function ot_type_import_data() { + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'import_data_form', 'import_data_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + if ( OT_SHOW_SETTINGS_IMPORT ) { + echo '

        ' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Theme Options.', 'option-tree' ) . '

        '; + } + + echo '

        ' . esc_html__( 'To import your Theme Options copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Theme Options" button.', 'option-tree' ) . '

        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Import Layouts option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_import_layouts' ) ) { - - function ot_type_import_layouts() { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - if ( OT_SHOW_SETTINGS_IMPORT ) echo '

        ' . __( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '

        '; - - /* button */ - echo ''; - - echo '
        '; - - /* textarea */ - echo '
        '; - - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Import Layouts option type. + * + * @access public + * @since 2.0 + */ + function ot_type_import_layouts() { + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'import_layouts_form', 'import_layouts_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + if ( OT_SHOW_SETTINGS_IMPORT ) { + echo '

        ' . esc_html__( 'Only after you\'ve imported the Settings should you try and update your Layouts.', 'option-tree' ) . '

        '; + } + + echo '

        ' . esc_html__( 'To import your Layouts copy and paste what appears to be a random string of alpha numeric characters into this textarea and press the "Import Layouts" button. Keep in mind that when you import your layouts, the active layout\'s saved data will write over the current data set for your Theme Options.', 'option-tree' ) . '

        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Export Settings File option type. - * - * @return string - * - * @access public - * @since 2.0.8 - */ if ( ! function_exists( 'ot_type_export_settings_file' ) ) { - - function ot_type_export_settings_file() { - global $blog_id; - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . sprintf( __( 'Export your Settings into a fully functional %s file. If you want to add your own custom %s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ), 'theme-options.php', 'I18n', '' . __( 'Theme Mode', 'option-tree' ) . '' ) . '

        '; - - echo '
        '; - - echo '
        '; - - echo ''; - - /* button */ - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Export Settings File option type. + * + * @access public + * @since 2.0.8 + */ + function ot_type_export_settings_file() { + global $blog_id; + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'export_settings_file_form', 'export_settings_file_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + /* translators: %1$s: file name, %2$s: link to I18n docs, %3$s: link to internal docs */ + $string = esc_html__( 'Export your Settings into a fully functional %1$s file. If you want to add your own custom %2$s text domain to the file, enter it into the text field before exporting. For more information on how to use this file read the documentation on %3$s. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'theme-options.php', 'I18n', '' . esc_html__( 'Theme Mode', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
        '; + + echo '
        '; + + echo ''; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Export Settings option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_export_settings' ) ) { - - function ot_type_export_settings() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the OptionTree->Settings->Import Settings textarea on another web site.', 'option-tree' ) . '

        '; - - echo '
        '; - - /* get theme options data */ - $settings = get_option( ot_settings_id() ); - $settings = ! empty( $settings ) ? ot_encode( serialize( $settings ) ) : ''; - - echo '
        '; - echo ''; - echo '
        '; - - echo '
        '; - - } - + + /** + * Export Settings option type. + * + * @access public + * @since 2.0 + */ + function ot_type_export_settings() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + /* translators: %1$s: visual path to import, %2$s: visual path to settings */ + $string = esc_html__( 'Export your Settings by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %1$s textarea on another web site.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '', '' . esc_html__( 'Settings', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
        '; + + // Get theme options data. + $settings = get_option( ot_settings_id() ); + $settings = ! empty( $settings ) ? ot_encode( maybe_serialize( $settings ) ) : ''; + + echo '
        '; + echo ''; // phpcs:ignore + echo '
        '; + + echo '
        '; + + } } -/** - * Export Data option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_export_data' ) ) { - - function ot_type_export_data() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the OptionTree->Settings->Import Theme Options textarea on another web site.', 'option-tree' ) . '

        '; - - echo '
        '; - - /* get theme options data */ - $data = get_option( ot_options_id() ); - $data = ! empty( $data ) ? ot_encode( serialize( $data ) ) : ''; - - echo '
        '; - echo ''; - echo '
        '; - - echo '
        '; - - } - + + /** + * Export Data option type. + * + * @access public + * @since 2.0 + */ + function ot_type_export_data() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + /* translators: %1$s: visual path to import, %2$s: visual path to theme options */ + $string = esc_html__( 'Export your Theme Options data by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '', '' . esc_html__( 'Theme Options', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
        '; + + // Get theme options data. + $data = get_option( ot_options_id() ); + $data = ! empty( $data ) ? ot_encode( maybe_serialize( $data ) ) : ''; + + echo '
        '; + echo ''; // phpcs:ignore + echo '
        '; + + echo '
        '; + + } } -/** - * Export Layouts option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_export_layouts' ) ) { - - function ot_type_export_layouts() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the OptionTree->Settings->Import Layouts textarea on another web site.', 'option-tree' ) . '

        '; - - - echo '
        '; - - /* get layout data */ - $layouts = get_option( ot_layouts_id() ); - $layouts = ! empty( $layouts ) ? ot_encode( serialize( $layouts ) ) : ''; - - echo '
        '; - echo ''; - echo '
        '; - - echo '
        '; - - } - + + /** + * Export Layouts option type. + * + * @access public + * @since 2.0 + */ + function ot_type_export_layouts() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + /* translators: %1$s: visual path to import, %2$s: visual path to layouts */ + $string = esc_html__( 'Export your Layouts by highlighting this text and doing a copy/paste into a blank .txt file. Then save the file for importing into another install of WordPress later. Alternatively, you could just paste it into the %1$s %2$s textarea on another web site.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Import', 'option-tree' ) . '', '' . esc_html__( 'Layouts', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
        '; + + // Get layout data. + $layouts = get_option( ot_layouts_id() ); + $layouts = ! empty( $layouts ) ? ot_encode( maybe_serialize( $layouts ) ) : ''; + + echo '
        '; + echo ''; // phpcs:ignore + echo '
        '; + + echo '
        '; + } } -/** - * Modify Layouts option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_modify_layouts' ) ) { - - function ot_type_modify_layouts() { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' ); - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '

        '; - echo '

        ' . __( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '

        '; - echo '

        ' . __( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '

        '; - if ( OT_SHOW_DOCS ) echo '

        ' . __( 'Visit OptionTree->Documentation->Layouts Overview to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ) . '

        '; - - echo '
        '; - - echo '
        '; - - /* get the saved layouts */ - $layouts = get_option( ot_layouts_id() ); - - /* set active layout */ - $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : ''; - - echo ''; - - /* add new layout */ - echo ''; - - /* loop through each layout */ - echo '
          '; - - if ( is_array( $layouts ) && ! empty( $layouts ) ) { - - foreach( $layouts as $key => $data ) { - - /* skip active layout array */ - if ( $key == 'active_layout' ) - continue; - - /* content */ - echo '
        • ' . ot_layout_view( $key, $data, $active_layout ) . '
        • '; - - } - - } - - echo '
        '; - - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - -} -/* End of file ot-functions-settings-page.php */ -/* Location: ./includes/ot-functions-settings-page.php */ \ No newline at end of file + /** + * Modify Layouts option type. + * + * @access public + * @since 2.0 + */ + function ot_type_modify_layouts() { + + echo '
        '; + + // Form nonce. + wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' ); + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'To add a new layout enter a unique lower case alphanumeric string (dashes allowed) in the text field and click "Save Layouts".', 'option-tree' ) . '

        '; + echo '

        ' . esc_html__( 'As well, you can activate, remove, and drag & drop the order; all situations require you to click "Save Layouts" for the changes to be applied.', 'option-tree' ) . '

        '; + echo '

        ' . esc_html__( 'When you create a new layout it will become active and any changes made to the Theme Options will be applied to it. If you switch back to a different layout immediately after creating a new layout that new layout will have a snapshot of the current Theme Options data attached to it.', 'option-tree' ) . '

        '; + + if ( OT_SHOW_DOCS ) { + /* translators: %s: visual path to layouts overview */ + $string = esc_html__( 'Visit %s to see a more in-depth description of what layouts are and how to use them.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'OptionTree->Documentation->Layouts Overview', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + } + + echo '
        '; + + echo '
        '; + + // Get the saved layouts. + $layouts = get_option( ot_layouts_id() ); + + // Set active layout. + $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : ''; + + echo ''; + + // Add new layout. + echo ''; + + // Loop through each layout. + echo '
          '; + + if ( is_array( $layouts ) && ! empty( $layouts ) ) { + + foreach ( $layouts as $key => $data ) { + + // Skip active layout array. + if ( 'active_layout' === $key ) { + continue; + } + + // Content. + echo '
        • ' . ot_layout_view( $key, $data, $active_layout ) . '
        • '; // phpcs:ignore + } + } + + echo '
        '; + + echo ''; + + echo '
        '; + + echo '
        '; + + echo '
        '; + } +} From 25ea494a660255ce3ebc893a963348f27ecf9cc6 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 05:12:06 -0800 Subject: [PATCH 17/67] Fix phpcs issues --- includes/ot-functions-docs-page.php | 1389 +++++++++++++++------------ 1 file changed, 768 insertions(+), 621 deletions(-) diff --git a/includes/ot-functions-docs-page.php b/includes/ot-functions-docs-page.php index 361b99f..cd555e4 100755 --- a/includes/ot-functions-docs-page.php +++ b/includes/ot-functions-docs-page.php @@ -1,190 +1,242 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Creating Options option type. - * - * @return string - * - * @access public - * @since 2.0 - */ +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + if ( ! function_exists( 'ot_type_creating_options' ) ) { - - function ot_type_creating_options() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'Label', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'ID', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The ID field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will change all text you write in this field to lowercase and replace spaces and special characters with an underscore automatically.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Type', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'You are required to choose one of the supported option types when creating a new option. Here is a list of the available option types. For more information about each type click the Option Types tab to the left.', 'option-tree' ) . '

        '; - - echo '
          '; - foreach( ot_option_types_array() as $key => $value ) - echo '
        • ' . $value . '
        • '; - echo '
        '; - - echo '

        '. __( 'Description', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Choices', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Click the "Add Choice" button to add an item to the choices array. This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Settings', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Click the "Add Setting" button found inside a newly created setting to add an item to the settings array. This will only affect the List Item type.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Standard', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Setting the standard value for your option only works for some option types. Those types are one that have a single string value saved to them and not an array of values.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Rows', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Post Type', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Add a comma separated list of post type like post,page. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select. Below are the default post types available with WordPress and that are also compatible with OptionTree. You can also add your own custom post_type. At this time any does not seem to return results properly and is something I plan on looking into.', 'option-tree' ) . '

        '; - - echo '
          '; - echo '
        • post
        • '; - echo '
        • page
        • '; - echo '
        • attachment
        • '; - echo '
        '; - - echo '

        '. __( 'Taxonomy', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Add a comma separated list of any registered taxonomy like category,post_tag. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Min, Max, & Step', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Add a comma separated list of options in the following format 0,100,1 (slide from 0-100 in intervals of 1). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'CSS Class', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'Add and optional class to any option type.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Condition', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %s is a placeholder for your condition, which can be in the form of %s.', 'option-tree' ), 'value', 'field_id:is(value), field_id:not(value), field_id:contains(value), field_id:less_than(value), field_id:less_than_or_equal_to(value), field_id:greater_than(value), or field_id:greater_than_or_equal_to(value)' ) . '

        '; - - echo '

        '. __( 'Operator', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'Choose the logical operator to compute the result of the conditions. Your options are %s and %s.', 'option-tree' ), 'and', 'or' ) . '

        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Creating Options option type. + * + * @access public + * @since 2.0 + */ + function ot_type_creating_options() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'Label', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Label field should be a short but descriptive block of text 100 characters or less with no HTML.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'ID', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The ID field is a unique alphanumeric key used to differentiate each theme option (underscores are acceptable). Also, the plugin will change all text you write in this field to lowercase and replace spaces and special characters with an underscore automatically.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Type', 'option-tree' ) . ':

        '; + + /* translators: %s: option type tab */ + $string = esc_html__( 'You are required to choose one of the supported option types when creating a new option. Here is a list of the available option types. For more information about each type click the %s tab to the left.', 'option-tree' ); + echo '

        ' . sprintf( $string, '' . esc_html__( 'Option Types', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
          '; + foreach ( ot_option_types_array() as $key => $value ) { + echo '
        • ' . $value . '
        • '; // phpcs:ignore + } + echo '
        '; + + echo '

        ' . esc_html__( 'Description', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Choices', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Click the "Add Choice" button to add an item to the choices array. This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Settings', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Click the "Add Setting" button found inside a newly created setting to add an item to the settings array. This will only affect the List Item type.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Standard', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Setting the standard value for your option only works for some option types. Those types are one that have a single string value saved to them and not an array of values.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Rows', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Post Type', 'option-tree' ) . ':

        '; + + /* translators: %1$s: example value, %2$s: post_type, %3$s: using any as a value */ + $string = esc_html__( 'Add a comma separated list of post type like %1$s. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select. Below are the default post types available with WordPress and that are also compatible with OptionTree. You can also add your own custom %2$s. At this time %3$s does not seem to return results properly and is something I plan on looking into.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'post,page', 'post_type', 'any' ) . '

        '; // phpcs:ignore + + echo '
          '; + echo '
        • post
        • '; + echo '
        • page
        • '; + echo '
        • attachment
        • '; + echo '
        '; + + echo '

        ' . esc_html__( 'Taxonomy', 'option-tree' ) . ':

        '; + + /* translators: %s: example value */ + $string = esc_html__( 'Add a comma separated list of any registered taxonomy like %s. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'category,post_tag' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Min, Max, & Step', 'option-tree' ) . ':

        '; + + /* translators: %1$s: format, %2$s: range, %3$s: interval minimum */ + $string = esc_html__( 'Add a comma separated list of options in the following format %1$s (slide from %2$s in intervals of %3$s). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ); + echo '

        ' . sprintf( $string, '0,100,1', '0-100', '1' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'CSS Class', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'Add and optional class to any option type.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Condition', 'option-tree' ) . ':

        '; + + /* translators: %1$s: example (value) placeholder, %2$s: list of condition examples */ + $string = esc_html__( 'Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %1$s is a placeholder for your condition, which can be in the form of %2$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'value', 'field_id:is(value), field_id:not(value), field_id:contains(value), field_id:less_than(value), field_id:less_than_or_equal_to(value), field_id:greater_than(value), or field_id:greater_than_or_equal_to(value)' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Operator', 'option-tree' ) . ':

        '; + + /* translators: %1$s: and value, %2$s: or value */ + $string = esc_html__( 'Choose the logical operator to compute the result of the conditions. Your options are %1$s and %2$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'and', 'or' ) . '

        '; // phpcs:ignore + + echo '
        '; + + echo '
        '; + } } -/** - * ot_get_option() option type. - * - * This is a callback function to display text about ot_get_option(). - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_option_types' ) ) { - - function ot_type_option_types() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'Background', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %s to remove unwanted fields from all Background options or an individual one. You can also filter %s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' ), 'ot_get_option()', 'ot_recognized_background_fields', 'ot_recognized_background_repeat, ot_recognized_background_attachment, ot_recognized_background_position, ' . __( 'and', 'option-tree' ) . ' ot_type_background_size_choices' ) . '

        '; - - echo '

        '. __( 'Border', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Border option type is used to set width, unit, style, and color values. The text input excepts a numerical value and the unit select lets you choose the unit of measurement to add to that value. Currently the default units are %s, %s, %s, and %s. However, you can change them with the %s filter. The style select lets you choose the border style. The default styles are %s, %s, %s, %s, %s, %s, %s, and %s. However, you can change them with the %s filter. The colorpicker saves a hexadecimal color code.', 'option-tree' ), 'px', '%', 'em', 'pt', 'ot_recognized_border_unit_types', 'hidden', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'ot_recognized_border_style_types' ) . '

        '; - - echo '

        '. __( 'Box Shadow', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Box Shadow option type is used to set %s, %s, %s, %s, %s, and %s values.', 'option-tree' ), 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color' ) . '

        '; - - echo '

        '. __( 'Category Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Category Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Colorpicker', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Colorpicker Opacity', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Colorpicker Opacity option type saves a hexadecimal color code with an opacity value from %s to %s in increments of %s. Though the value is saved as hexadecimal, if used within the CSS option type the color and opacity values will be converted into a valid RGBA CSS value.', 'option-tree' ), '0', '1', '0.01' ) . '

        '; - - echo '

        '. __( 'CSS', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %s at the root level of your theme and change permissions using %s so the server can write to the file. I have had the most success setting this single file to %s but feel free to play around with permissions until everything is working. A good starting point is %s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'option-tree' ), 'dynamic.css', 'chmod', '0777', '0666' ) . '

        '; - - echo '

        ' . sprintf( __( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'option-tree' ), 'demo_background', 'dynamic.css' ) . '

        '; - - echo '

        '. __( 'Input', 'option-tree' ) . ':

        '; - echo '
        body {
        +
        +	/**
        +	 * The ot_get_option() option type.
        +	 *
        +	 * This is a callback function to display text about ot_get_option().
        +	 *
        +	 * @access public
        +	 * @since  2.0
        +	 */
        +	function ot_type_option_types() {
        +
        +		// Format setting outer wrapper.
        +		echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'Background', 'option-tree' ) . ':

        '; + + /* translators: %1$s: function name, %2$s: filter name, %3$s: filter name list */ + $string = esc_html__( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %1$s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_get_option()', 'ot_recognized_background_fields', 'ot_recognized_background_repeat, ot_recognized_background_attachment, ot_recognized_background_position, ' . __( 'and', 'option-tree' ) . ' ot_type_background_size_choices' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Border', 'option-tree' ) . ':

        '; + + /* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name, %6$s: hidden, %7$s: dashed, %8$s: solid, %9$s: double, %10$s: groove, %11$s: ridge, %12$s: inset, %13$s: outset, %14$s: filter name */ + $string = esc_html__( 'The Border option type is used to set width, unit, style, and color values. The text input excepts a numerical value and the unit select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter. The style select lets you choose the border style. The default styles are %6$s, %7$s, %8$s, %9$s, %10$s, %11$s, %12$s, and %13$s. However, you can change them with the %14$s filter. The colorpicker saves a hexadecimal color code.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'px', '%', 'em', 'pt', 'ot_recognized_border_unit_types', 'hidden', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'ot_recognized_border_style_types' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Box Shadow', 'option-tree' ) . ':

        '; + + /* translators: %1$s: inset, %2$s: offset-x, %3$s: offset-y, %4$s: blur-radius, %5$s: spread-radius, %6$s: color */ + $string = esc_html__( 'The Box Shadow option type is used to set %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s values.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Category Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Category Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Colorpicker', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Colorpicker Opacity', 'option-tree' ) . ':

        '; + + /* translators: %1$s: range minimum, %2$s: range maximum, %3$s: minimum increment */ + $string = esc_html__( 'The Colorpicker Opacity option type saves a hexadecimal color code with an opacity value from %1$s to %2$s in increments of %3$s. Though the value is saved as hexadecimal, if used within the CSS option type the color and opacity values will be converted into a valid RGBA CSS value.', 'option-tree' ); + echo '

        ' . sprintf( $string, '0', '1', '0.01' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'CSS', 'option-tree' ) . ':

        '; + + /* translators: %1$s: file name, %2$s: command name, %3$s: permission mode, %4$s: permission mode */ + $string = esc_html__( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %1$s at the root level of your theme and change permissions using %2$s so the server can write to the file. I have had the most success setting this single file to %3$s but feel free to play around with permissions until everything is working. A good starting point is %4$s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'dynamic.css', 'chmod', '0777', '0666' ) . '

        '; // phpcs:ignore + + /* translators: option ID: pixel unit, %2$s: file name */ + $string = esc_html__( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'demo_background', 'dynamic.css' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Input', 'option-tree' ) . ':

        '; + echo '
        body {
           {{demo_background}}
           background-color: {{demo_background|background-color}};
         }
        '; - echo '

        '. __( 'Output', 'option-tree' ) . ':

        '; - echo '
        /* BEGIN demo_background */
        +		echo '

        ' . esc_html__( 'Output', 'option-tree' ) . ':

        '; + echo '
        /* BEGIN demo_background */
         body {
           background: color image repeat attachment position;
           background-color: color;
         }
         /* END demo_background */
        '; - - echo '

        '. __( 'Custom Post Type Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' ), 'post_type' ) . '

        '; - - echo '

        '. __( 'Custom Post Type Select', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' ), 'post_type' ) . '

        '; - - echo '

        '. __( 'Date Picker', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Date Time Picker', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Dimension', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Dimension option type is used to set width and height values. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %s, %s, %s, and %s. However, you can change them with the %s filter.', 'option-tree' ), 'px', '%', 'em', 'pt', 'ot_recognized_dimension_unit_types' ) . '

        '; - - echo '

        '. __( 'Gallery', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Google Fonts', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'option-tree' ), 'HEAD', 'font-family', 'ot_google_font_stack', '$font_stack', '$family', '$field_id', 'ot_recognized_font_families' ) . '

        '; - - echo '

        '. __( 'JavaScript', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'option-tree' ), 'ace.js' ) . '

        '; - - echo '

        '. __( 'Link Color', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Link Color option type is used to set all link color states.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'List Item', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The List Item option type replaced the Slider option type and allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Measurement', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %s, %s, %s, and %s. However, you can change them with the %s filter.', 'option-tree' ), 'px', '%', 'em', 'pt', 'ot_measurement_unit_types' ) . '

        '; - - echo '

        ' . sprintf( __( 'Example filter to add new units to the Measurement option type. Added to %s.', 'option-tree' ), 'functions.php' ) . '

        '; - echo '
        function filter_measurement_unit_types( $array, $field_id ) {
        +
        +		echo '

        ' . esc_html__( 'Custom Post Type Checkbox', 'option-tree' ) . ':

        '; + + /* translators: %1$s: post_type */ + $string = esc_html__( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'post_type' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Custom Post Type Select', 'option-tree' ) . ':

        '; + + /* translators: %s: post_type */ + $string = esc_html__( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'post_type' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Date Picker', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Date Time Picker', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Dimension', 'option-tree' ) . ':

        '; + + /* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */ + $string = esc_html__( 'The Dimension option type is used to set width and height values. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'px', '%', 'em', 'pt', 'ot_recognized_dimension_unit_types' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Gallery', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Google Fonts', 'option-tree' ) . ':

        '; + + /* translators: %1$s: HTML Document HEAD, %2$s: array key, %3$s: filter name, %4$s: parameter name, %5$s: parameter name, %6$s: parameter name, %7$s: function name*/ + $string = esc_html__( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'HEAD', 'font-family', 'ot_google_font_stack', '$font_stack', '$family', '$field_id', 'ot_recognized_font_families' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'JavaScript', 'option-tree' ) . ':

        '; + + /* translators: %s: file name */ + $string = esc_html__( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ace.js' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Link Color', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Link Color option type is used to set all link color states.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'List Item', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The List Item option type replaced the Slider option type and allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Measurement', 'option-tree' ) . ':

        '; + + /* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */ + $string = esc_html__( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'px', '%', 'em', 'pt', 'ot_measurement_unit_types' ) . '

        '; // phpcs:ignore + + /* translators: %s: file name */ + $string = esc_html__( 'Example filter to add new units to the Measurement option type. Added to %s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'functions.php' ) . '

        '; // phpcs:ignore + + echo '
        function filter_measurement_unit_types( $array, $field_id ) {
           
           /* only run the filter on measurement with a field ID of my_measurement */
           if ( $field_id == \'my_measurement\' ) {
        @@ -196,8 +248,11 @@ function ot_type_option_types() {
         }
         add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );
        '; - echo '

        ' . __( 'Example filter to completely change the units in the Measurement option type. Added to functions.php.', 'option-tree' ) . '

        '; - echo '
        function filter_measurement_unit_types( $array, $field_id ) {
        +		/* translators: %s: file name */
        +		$string = esc_html__( 'Example filter to completely change the units in the Measurement option type. Added to %s.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'functions.php' ) . '

        '; // phpcs:ignore + + echo '
        function filter_measurement_unit_types( $array, $field_id ) {
           
           /* only run the filter on measurement with a field ID of my_measurement */
           if ( $field_id == \'my_measurement\' ) {
        @@ -210,33 +265,42 @@ function ot_type_option_types() {
           return $array;
         }
         add_filter( \'ot_measurement_unit_types\', \'filter_measurement_unit_types\', 10, 2 );
        '; - - echo '

        '. __( 'Numeric Slider', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'On/Off', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %s or %s.', 'option-tree' ), 'on', 'off' ) . '

        '; - - echo '

        '. __( 'Page Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Page Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Post Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Post Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Radio', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Radio Image', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'option-tree' ), 'ot_radio_images' ) . '

        '; - - echo '

        ' . __( 'This example executes the ot_radio_images filter on layout images attached to the my_radio_images field. Added to functions.php.', 'option-tree' ) . '

        '; - echo '
        function filter_radio_images( $array, $field_id ) {
        +
        +		echo '

        ' . esc_html__( 'Numeric Slider', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'On/Off', 'option-tree' ) . ':

        '; + + /* translators: %1$s: on value, %2$s: off value */ + $string = esc_html__( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %1$s or %2$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'on', 'off' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Page Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Page Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Post Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Post Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Radio', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Radio Image', 'option-tree' ) . ':

        '; + + /* translators: %s: filter name */ + $string = esc_html__( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_radio_images' ) . '

        '; // phpcs:ignore + + /* translators: %1$s: filter name, %2$s: field name, %3$s: file name */ + $string = esc_html__( 'This example executes the %1$s filter on layout images attached to the %2$s field. Added to %3$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_radio_images', 'my_radio_images', 'functions.php' ) . '

        '; // phpcs:ignore + + echo '
        function filter_radio_images( $array, $field_id ) {
           
           /* only run the filter where the field ID is my_radio_images */
           if ( $field_id == \'my_radio_images\' ) {
        @@ -258,48 +322,68 @@ function ot_type_option_types() {
           
         }
         add_filter( \'ot_radio_images\', \'filter_radio_images\', 10, 2 );
        '; - - echo '

        '. __( 'Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Sidebar Select', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %s, and %s we can be selective about which sidebars are available on a specific content area.', 'option-tree' ), 'ot_recognized_sidebars', 'ot_recognized_sidebars_{$field_id}' ) . '

        '; - echo '

        ' . sprintf( __( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'option-tree' ), 'footer-sidebar-$i' ) . '

        '; - - echo '

        '. __( 'Slider', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Slider option type is technically deprecated. Use the List Item option type instead, as it\'s infinitely more customizable. Typical use is for creating sliding image content.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Social Links', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %s filter to %s and turn off loading default values. Use the %s filter to change the default values that are loaded. To filter the settings array use the %s filter.', 'option-tree' ), 'ot_type_social_links_load_defaults', 'false', 'ot_type_social_links_defaults', 'ot_social_links_settings' ) . '

        '; - - echo '

        '. __( 'Spacing', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %s, %s, %s, and %s. However, you can change them with the %s filter.', 'option-tree' ), 'px', '%', 'em', 'pt', 'ot_recognized_spacing_unit_types' ) . '

        '; - - echo '

        '. __( 'Tab', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Tab option type will break a section or metabox into tabbed content.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Tag Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Tag Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Taxonomy Checkbox', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Taxonomy Select', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Text', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Textarea', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %s, %s, %s, and %s.', 'option-tree' ), 'wpautop', 'media_buttons', 'tinymce', 'quicktags' ) . '

        '; - - echo '

        ' . __( 'Example filters to alter the Textarea option type. Added to functions.php.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'This example keeps WordPress from executing the wpautop filter on the line breaks. The default is true which means it wraps line breaks with an HTML p tag.', 'option-tree' ) . '

        '; - echo '
        function filter_textarea_wpautop( $content, $field_id ) {
        +
        +		echo '

        ' . esc_html__( 'Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Sidebar Select', 'option-tree' ) . ':

        '; + + /* translators: %1$s: filter name, %2$s: dynamic filter name with field_id */ + $string = esc_html__( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %1$s, and %2$s we can be selective about which sidebars are available on a specific content area.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_recognized_sidebars', 'ot_recognized_sidebars_{$field_id}' ) . '

        '; // phpcs:ignore + + /* translators: %s: dynamic sidebar name */ + $string = esc_html__( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'footer-sidebar-$i' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Slider', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Slider option type is technically deprecated. Use the List Item option type instead, as it\'s infinitely more customizable. Typical use is for creating sliding image content.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Social Links', 'option-tree' ) . ':

        '; + + /* translators: %1$s: filter name, %2$s: boolean value, %3$s: filter name, %4$s: filter name */ + $string = esc_html__( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %1$s filter to %2$s and turn off loading default values. Use the %3$s filter to change the default values that are loaded. To filter the settings array use the %4$s filter.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_type_social_links_load_defaults', 'false', 'ot_type_social_links_defaults', 'ot_social_links_settings' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Spacing', 'option-tree' ) . ':

        '; + + /* translators: %1$s: pixel unit, %2$s: percentage unit, %3$s: em unit, %4$s: point unit, %5$s: filter name */ + $string = esc_html__( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left. The text inputs except numerical values and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'px', '%', 'em', 'pt', 'ot_recognized_spacing_unit_types' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'Tab', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Tab option type will break a section or metabox into tabbed content.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Tag Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Tag Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Taxonomy Checkbox', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Taxonomy Select', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Text', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Textarea', 'option-tree' ) . ':

        '; + + /* translators: %1$s: filter name, %2$s: filter name, %3$s: filter name, %4$s: filter name */ + $string = esc_html__( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %1$s, %2$s, %3$s, and %4$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'wpautop', 'media_buttons', 'tinymce', 'quicktags' ) . '

        '; // phpcs:ignore + + /* translators: %s: file name */ + $string = esc_html__( 'Example filters to alter the Textarea option type. Added to %s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'functions.php' ) . '

        '; // phpcs:ignore + + /* translators: %1$s: filter name, %2$s: boolean value, %3$s: paragraph tag */ + $string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the line breaks. The default is %2$s which means it wraps line breaks with an HTML %3$s tag.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'wpautop', 'true', 'p' ) . '

        '; // phpcs:ignore + + echo '
        function filter_textarea_wpautop( $content, $field_id ) {
           
           /* only run the filter on the textarea with a field ID of my_textarea */
           if ( $field_id == \'my_textarea\' ) {
        @@ -311,8 +395,11 @@ function ot_type_option_types() {
         }
         add_filter( \'ot_wpautop\', \'filter_textarea_wpautop\', 10, 2 );
        '; - echo '

        ' . __( 'This example keeps WordPress from executing the media_buttons filter on the textarea WYSIWYG. The default is true which means show the buttons.', 'option-tree' ) . '

        '; - echo '
        function filter_textarea_media_buttons( $content, $field_id ) {
        +		/* translators: %1$s: filter name, %2$s: boolean value */
        +		$string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show the buttons.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'media_buttons', 'true' ) . '

        '; // phpcs:ignore + + echo '
        function filter_textarea_media_buttons( $content, $field_id ) {
           
           /* only run the filter on the textarea with a field ID of my_textarea */
           if ( $field_id == \'my_textarea\' ) {
        @@ -323,9 +410,12 @@ function ot_type_option_types() {
           
         }
         add_filter( \'ot_media_buttons\', \'filter_textarea_media_buttons\', 10, 2 );
        '; - - echo '

        ' . __( 'This example keeps WordPress from executing the tinymce filter on the textarea WYSIWYG. The default is true which means show the tinymce.', 'option-tree' ) . '

        '; - echo '
        function filter_textarea_tinymce( $content, $field_id ) {
        +
        +		/* translators: %1$s: filter name, %2$s: boolean value */
        +		$string = esc_html__( 'This example keeps WordPress from executing the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show the tinymce.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'tinymce', 'true' ) . '

        '; // phpcs:ignore + + echo '
        function filter_textarea_tinymce( $content, $field_id ) {
           
           /* only run the filter on the textarea with a field ID of my_textarea */
           if ( $field_id == \'my_textarea\' ) {
        @@ -337,8 +427,10 @@ function ot_type_option_types() {
         }
         add_filter( \'ot_tinymce\', \'filter_textarea_tinymce\', 10, 2 );
        '; - echo '

        ' . __( 'This example alters the quicktags filter on the textarea WYSIWYG. The default is array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close\' ) which means show those quicktags. It also means you can filter in your own custom quicktags.', 'option-tree' ) . '

        '; - echo '
        function filter_textarea_quicktags( $content, $field_id ) {
        +		/* translators: %1$s: filter name, %2$s: tags list */
        +		$string = esc_html__( 'This example alters the %1$s filter on the textarea WYSIWYG. The default is %2$s which means show those quicktags. It also means you can filter in your own custom quicktags.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'quicktags', 'array( \'buttons\' => \'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close\' )' ) . '

        '; // phpcs:ignore + echo '
        function filter_textarea_quicktags( $content, $field_id ) {
           
           /* only run the filter on the textarea with a field ID of my_textarea */
           if ( $field_id == \'my_textarea\' ) {
        @@ -352,11 +444,13 @@ function ot_type_option_types() {
         }
         add_filter( \'ot_quicktags\', \'filter_textarea_quicktags\', 10, 1 );
        '; - echo '

        '. __( 'Textarea Simple', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'option-tree' ) . '

        '; - - echo '

        ' . sprintf( __( 'This example tells WordPress to execute the %s filter on the line breaks. The default is %s which means it does not wraps line breaks with an HTML %s tag. Added to %s.', 'option-tree' ), 'wpautop', 'false', 'p', 'functions.php' ) . '

        '; - echo '
        function filter_textarea_simple_wpautop( $content, $field_id ) {
        +		echo '

        ' . esc_html__( 'Textarea Simple', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'option-tree' ) . '

        '; + + /* translators: %1$s: function name, %2$s: boolean value, %3$s: paragraph tag, %4$s: file name */ + $string = esc_html__( 'This example tells WordPress to execute the %1$s filter on the line breaks. The default is %2$s which means it does not wraps line breaks with an HTML %3$s tag. Added to %4$s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'wpautop', 'false', 'p', 'functions.php' ) . '

        '; // phpcs:ignore + echo '
        function filter_textarea_simple_wpautop( $content, $field_id ) {
           
           /* only run the filter on the textarea with a field ID of my_textarea */
           if ( $field_id == \'my_textarea\' ) {
        @@ -367,18 +461,21 @@ function ot_type_option_types() {
           
         }
         add_filter( \'ot_wpautop\', \'filter_textarea_simple_wpautop\', 10, 2 );
        '; - - echo '

        '. __( 'Textblock', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Textblock Titled', 'option-tree' ) . ':

        '; - echo '

        ' . __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '

        '; - - echo '

        '. __( 'Typography', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %s to remove unwanted fields from all Background options or an individual one. You can also filter %s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' ), 'ot_get_option()', 'ot_recognized_typography_fields', 'ot_recognized_font_families, ot_recognized_font_sizes, ot_recognized_font_styles, ot_recognized_font_variants, ot_recognized_font_weights, ot_recognized_letter_spacing, ot_recognized_line_heights, ot_recognized_text_decorations ' . __( 'and', 'option-tree' ) . ' ot_recognized_text_transformations' ) . '

        '; - - echo '

        ' . __( 'This example would filter ot_recognized_font_families to build your own font stack. Added to functions.php.', 'option-tree' ) . '

        '; - echo '
        function filter_ot_recognized_font_families( $array, $field_id ) {
        +
        +		echo '

        ' . esc_html__( 'Textblock', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Textblock Titled', 'option-tree' ) . ':

        '; + echo '

        ' . esc_html__( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Typography', 'option-tree' ) . ':

        '; + + /* translators: %1$s: function name, %2$s: filter name, %3$s: filter name list */ + $string = esc_html__( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %1$s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'ot_get_option()', 'ot_recognized_typography_fields', 'ot_recognized_font_families, ot_recognized_font_sizes, ot_recognized_font_styles, ot_recognized_font_variants, ot_recognized_font_weights, ot_recognized_letter_spacing, ot_recognized_line_heights, ot_recognized_text_decorations ' . esc_html__( 'and', 'option-tree' ) . ' ot_recognized_text_transformations' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'This example would filter ot_recognized_font_families to build your own font stack. Added to functions.php.', 'option-tree' ) . '

        '; + echo '
        function filter_ot_recognized_font_families( $array, $field_id ) {
           
           /* only run the filter when the field ID is my_google_fonts_headings */
           if ( $field_id == \'my_google_fonts_headings\' ) {
        @@ -394,164 +491,163 @@ function ot_type_option_types() {
         }
         add_filter( \'ot_recognized_font_families\', \'filter_ot_recognized_font_families\', 10, 2 );
        '; - echo '

        '. __( 'Upload', 'option-tree' ) . ':

        '; - echo '

        ' . sprintf( __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %s any media to your new server and change the URIs if necessary.', 'option-tree' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ), 'FTP' ) . '

        '; - - echo '
        '; - - echo '
        '; - - } - + echo '

        ' . esc_html__( 'Upload', 'option-tree' ) . ':

        '; + + /* translators: %1$s: button text, %2$s: the FTP protocol */ + $string = esc_html__( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%1$s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %2$s any media to your new server and change the URIs if necessary.', 'option-tree' ); + echo '

        ' . sprintf( $string, esc_html( apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ), 'FTP' ) . '

        '; // phpcs:ignore + + echo '
        '; + + echo '
        '; + } } -/** - * ot_get_option() option type. - * - * This is a callback function to display text about ot_get_option(). - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_ot_get_option' ) ) { - - function ot_type_ot_get_option() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'Description', 'option-tree' ) . ':

        '; - - echo '

        ' . __( 'This function returns a value from the "option_tree" array of saved values or the default value supplied. The returned value would be mixed. Meaning it could be a string, integer, boolean, or array.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'Usage', 'option-tree' ) . ':

        '; - - echo '

        <?php ot_get_option( $option_id, $default ); ?>

        '; - - echo '

        ' . __( 'Parameters', 'option-tree' ) . ':

        '; - - echo '$option_id'; - - echo '

        (' . __( 'string', 'option-tree' ) . ') (' . __( 'required', 'option-tree' ) . ') ' . __( 'Enter the options unique identifier.', 'option-tree' ) . '
        ' . __( 'Default:', 'option-tree' ) . ' ' . __( 'None', 'option-tree' ) . '

        '; - - echo '$default'; - - echo '

        (' . __( 'string', 'option-tree' ) . ') (' . __( 'optional', 'option-tree' ) . ') ' . __( 'Enter a default return value. This is just incase the request returns null.', 'option-tree' ) . '
        ' . __( 'Default', 'option-tree' ) . ': ' . __( 'None', 'option-tree' ) . '

        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * The ot_get_option() option type. + * + * This is a callback function to display text about ot_get_option(). + * + * @access public + * @since 2.0 + */ + function ot_type_ot_get_option() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'Description', 'option-tree' ) . ':

        '; + + echo '

        ' . esc_html__( 'This function returns a value from the "option_tree" array of saved values or the default value supplied. The returned value would be mixed. Meaning it could be a string, integer, boolean, or array.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Usage', 'option-tree' ) . ':

        '; + + echo '

        <?php ot_get_option( $option_id, $default ); ?>

        '; + + echo '

        ' . esc_html__( 'Parameters', 'option-tree' ) . ':

        '; + + echo '$option_id'; + + echo '

        (' . esc_html__( 'string', 'option-tree' ) . ') (' . esc_html__( 'required', 'option-tree' ) . ') ' . esc_html__( 'Enter the options unique identifier.', 'option-tree' ) . '
        ' . esc_html__( 'Default:', 'option-tree' ) . ' ' . esc_html__( 'None', 'option-tree' ) . '

        '; + + echo '$default'; + + echo '

        (' . esc_html__( 'string', 'option-tree' ) . ') (' . esc_html__( 'optional', 'option-tree' ) . ') ' . esc_html__( 'Enter a default return value. This is just incase the request returns null.', 'option-tree' ) . '
        ' . esc_html__( 'Default', 'option-tree' ) . ': ' . esc_html__( 'None', 'option-tree' ) . '

        '; + + echo '
        '; + + echo '
        '; + } } -/** - * get_option_tree() option type. - * - * This is a callback function to display text about get_option_tree(). - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_get_option_tree' ) ) { - - function ot_type_get_option_tree() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'Use', 'option-tree' ) . 'ot_get_option()' . __( 'instead', 'option-tree' ) . '.

        '; - - echo '

        '. __( 'Description', 'option-tree' ) . ':

        '; - - echo '

        ' . __( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'Usage', 'option-tree' ) . ':

        '; - - echo '

        <?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?>

        '; - - echo '

        ' . __( 'Parameters', 'option-tree' ) . ':

        '; - - echo '$item_id'; - - echo '

        (' . __( 'string', 'option-tree' ) . ') (' . __( 'required', 'option-tree' ) . ') ' . __( 'Enter a unique Option Key to get a returned value or array.', 'option-tree' ) . '
        ' . __( 'Default:', 'option-tree' ) . ' ' . __( 'None', 'option-tree' ) . '

        '; - - echo '$options'; - - echo '

        (' . __( 'array', 'option-tree' ) . ') (' . __( 'optional', 'option-tree' ) . ') ' . __( 'Used to cut down on database queries in template files.', 'option-tree' ) . '
        ' . __( 'Default', 'option-tree' ) . ': ' . __( 'None', 'option-tree' ) . '

        '; - - echo '$echo'; - - echo '

        (' . __( 'boolean', 'option-tree' ) . ') (' . __( 'optional', 'option-tree' ) . ') ' . __( 'Echo the output.', 'option-tree' ) . '
        ' . __( 'Default', 'option-tree' ) . ': FALSE

        '; - - echo '$is_array'; - - echo '

        (' . __( 'boolean', 'option-tree' ) . ') (' . __( 'optional', 'option-tree' ) . ') ' . __( 'Used to indicate the $item_id is an array of values.', 'option-tree' ) . '
        ' . __( 'Default', 'option-tree' ) . ': FALSE

        '; - - echo '$offset'; - - echo '

        (' . __( 'integer', 'option-tree' ) . ') (' . __( 'optional', 'option-tree' ) . ') ' . __( 'Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).', 'option-tree' ) . '
        ' . __( 'Default', 'option-tree' ) . ': -1

        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * The get_option_tree() option type. + * + * This is a callback function to display text about get_option_tree(). + * + * @access public + * @since 2.0 + */ + function ot_type_get_option_tree() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Use', 'option-tree' ) . 'ot_get_option()' . esc_html__( 'instead', 'option-tree' ) . '.

        '; + + echo '

        ' . esc_html__( 'Description', 'option-tree' ) . ':

        '; + + echo '

        ' . esc_html__( 'This function returns, or echos if asked, a value from the "option_tree" array of saved values.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Usage', 'option-tree' ) . ':

        '; + + echo '

        <?php get_option_tree( $item_id, $options, $echo, $is_array, $offset ); ?>

        '; + + echo '

        ' . esc_html__( 'Parameters', 'option-tree' ) . ':

        '; + + echo '$item_id'; + + echo '

        (' . esc_html__( 'string', 'option-tree' ) . ') (' . esc_html__( 'required', 'option-tree' ) . ') ' . esc_html__( 'Enter a unique Option Key to get a returned value or array.', 'option-tree' ) . '
        ' . esc_html__( 'Default:', 'option-tree' ) . ' ' . esc_html__( 'None', 'option-tree' ) . '

        '; + + echo '$options'; + + echo '

        (' . esc_html__( 'array', 'option-tree' ) . ') (' . esc_html__( 'optional', 'option-tree' ) . ') ' . esc_html__( 'Used to cut down on database queries in template files.', 'option-tree' ) . '
        ' . esc_html__( 'Default', 'option-tree' ) . ': ' . esc_html__( 'None', 'option-tree' ) . '

        '; + + echo '$echo'; + + echo '

        (' . esc_html__( 'boolean', 'option-tree' ) . ') (' . esc_html__( 'optional', 'option-tree' ) . ') ' . esc_html__( 'Echo the output.', 'option-tree' ) . '
        ' . esc_html__( 'Default', 'option-tree' ) . ': FALSE

        '; + + echo '$is_array'; + + echo '

        (' . esc_html__( 'boolean', 'option-tree' ) . ') (' . esc_html__( 'optional', 'option-tree' ) . ') ' . esc_html__( 'Used to indicate the $item_id is an array of values.', 'option-tree' ) . '
        ' . esc_html__( 'Default', 'option-tree' ) . ': FALSE

        '; + + echo '$offset'; + + echo '

        (' . esc_html__( 'integer', 'option-tree' ) . ') (' . esc_html__( 'optional', 'option-tree' ) . ') ' . esc_html__( 'Numeric offset key for the $item_id array, -1 will return all values (an array starts at 0).', 'option-tree' ) . '
        ' . esc_html__( 'Default', 'option-tree' ) . ': -1

        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Examples option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_examples' ) ) { - - function ot_type_examples() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        ' . __( 'If you\'re using the plugin version of OptionTree it is highly recommended to include a function_exists check in your code, as described in the examples below. If you\'ve integrated OptionTree directly into your themes root directory, you will not need to wrap your code with function_exists, as you\'re guaranteed to have the ot_get_option() function available.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'String Examples', 'option-tree' ) . ':

        '; - - echo '

        ' . __( 'Returns the value of test_input.', 'option-tree' ) . '

        '; - - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +
        +	/**
        +	 * Examples option type.
        +	 *
        +	 * @access public
        +	 * @since  2.0
        +	 */
        +	function ot_type_examples() {
        +
        +		// Format setting outer wrapper.
        +		echo '
        '; + + // Description. + echo '
        '; + + /* translators: %1$s: function name, %2$s: emphasis on not, %3$s: function name, %4$s: function name */ + $string = esc_html__( 'If you\'re using the plugin version of OptionTree it is highly recommended to include a %1$s check in your code, as described in the examples below. If you\'ve integrated OptionTree directly into your themes root directory, you will %2$s need to wrap your code with %3$s, as you\'re guaranteed to have the %4$s function available.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'function_exists', '' . esc_html__( 'not', 'option-tree' ) . '', 'function_exists', 'ot_get_option()' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'String Examples', 'option-tree' ) . ':

        '; + + /* translators: %s: option id */ + $string = esc_html__( 'Returns the value of %s.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'test_input' ) . '

        '; // phpcs:ignore + + echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           $test_input = ot_get_option( \'test_input\' );
         }
        '; - echo '

        ' . __( 'Returns the value of test_input, but also has a default value if it returns empty.', 'option-tree' ) . '

        '; - - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +		/* translators: %s: option id */
        +		$string = esc_html__( 'Returns the value of %s, but also has a default value if it returns empty.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'test_input' ) . '

        '; // phpcs:ignore + + echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           $test_input = ot_get_option( \'test_input\', \'default input value goes here.\' );
         }
        '; - - echo '

        ' . __( 'Array Examples', 'option-tree' ) . ':

        '; - - echo '

        ' . __( 'Assigns the value of navigation_ids to the variable $ids. It then echos an unordered list of links (navigation) using wp_list_pages().', 'option-tree' ) . '

        '; - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +		echo '

        ' . esc_html__( 'Array Examples', 'option-tree' ) . ':

        '; + + /* translators: %1$s: option id, %2$s: variable name, %3$s: function name */ + $string = esc_html__( 'Assigns the value of to the variable . It then echos an unordered list of links (navigation) using .', 'option-tree' ); + echo '

        ' . sprintf( $string, 'navigation_ids', '$ids', 'wp_list_pages()' ) . '

        '; // phpcs:ignore + + echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           /* get an array of page id\'s */
           $ids = ot_get_option( \'navigation_ids\', array() );
         
        @@ -567,11 +663,13 @@ function ot_type_examples() {
             echo \'</ul>\';
           }
           
        -}
        '; - - echo '

        ' . __( 'The next two examples demonstrate how to use the Measurement option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' ) . '

        '; - - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +}
        '; + + /* translators: %s: option type name */ + $string = esc_html__( 'The next two examples demonstrate how to use the %s option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' ); + echo '

        ' . sprintf( $string. '' . esc_html__( 'Measurement', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + + echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           /* get the array */
           $measurement = ot_get_option( \'measurement_option_type_id\' );
           
        @@ -584,7 +682,7 @@ function ot_type_examples() {
           
         }
        '; - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +		echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           /* get the array, and have a default just incase */
           $measurement = ot_get_option( \'measurement_option_type_id\', array( \'10\', \'px\' ) );
           
        @@ -593,11 +691,11 @@ function ot_type_examples() {
             echo implode( \'\', $measurement );
           }
           
        -}
        '; - - echo '

        ' . __( 'This example displays a very basic slider loop.', 'option-tree' ) . '

        '; - - echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        +}
        '; + + echo '

        ' . esc_html__( 'This example displays a very basic slider loop.', 'option-tree' ) . '

        '; + + echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           
           /* get the slider array */
           $slides = ot_get_option( \'my_slider\', array() );
        @@ -613,149 +711,178 @@ function ot_type_examples() {
           }
           
         }
        '; - - echo '
        '; - - echo '
        '; - - } - -} -/** - * Layouts Overview option type. - * - * @return string - * - * @access public - * @since 2.0 - */ + echo '
        '; + + echo '
        '; + } +} if ( ! function_exists( 'ot_type_layouts_overview' ) ) { - - function ot_type_layouts_overview() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'It\'s Super Simple', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'Layouts make your theme awesome! With theme options data that you can save/import/export you can package themes with different color variations, or make it easy to do A/B testing on text and so much more. Basically, you save a snapshot of your data as a layout.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'Once you have created all your different layouts, or theme variations, you can save them to a separate text file for repackaging with your theme. Alternatively, you could just make different variations for yourself and change your theme with the click of a button, all without deleting your previous options data.', 'option-tree' ) . '

        '; - - echo '

        ' . __( ' Adding a layout is ridiculously easy, follow these steps and you\'ll be on your way to having a WordPress super theme.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'For Developers', 'option-tree' ) . ':

        '; - - echo '
        ' . __( 'Creating a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the OptionTre->Settings->Layouts tab.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Enter a name for your layout in the text field and hit "Save Layouts", you\'ve created your first layout.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Activating a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the OptionTre->Settings->Layouts tab.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Deleting a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the OptionTre->Settings->Layouts tab.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Edit Layout Data', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the Appearance->Theme Options page.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '

        ' . __( 'End-Users Mode', 'option-tree' ) . ':

        '; - - echo '
        ' . __( 'Creating a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the Appearance->Theme Options page.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Enter a name for your layout in the text field and hit "New Layout", you\'ve created your first layout.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Activating a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the Appearance->Theme Options page.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Deleting a Layout', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        ' . __( 'Edit Layout Data', 'option-tree' ) . ':
        '; - echo '
          '; - echo '
        • '. __( 'Go to the Appearance->Theme Options tab.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Layouts Overview option type. + * + * @access public + * @since 2.0 + */ + function ot_type_layouts_overview() { + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'It\'s Super Simple', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Layouts make your theme awesome! With theme options data that you can save/import/export you can package themes with different color variations, or make it easy to do A/B testing on text and so much more. Basically, you save a snapshot of your data as a layout.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'Once you have created all your different layouts, or theme variations, you can save them to a separate text file for repackaging with your theme. Alternatively, you could just make different variations for yourself and change your theme with the click of a button, all without deleting your previous options data.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( ' Adding a layout is ridiculously easy, follow these steps and you\'ll be on your way to having a WordPress super theme.', 'option-tree' ) . '

        '; + + echo '

        ' . esc_html__( 'For Developers', 'option-tree' ) . ':

        '; + + echo '
        ' . esc_html__( 'Creating a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s tab.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Enter a name for your layout in the text field and hit "Save Layouts", you\'ve created your first layout.', 'option-tree' ) . '
        • '; + echo '
        • ' . esc_html__( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Activating a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s tab.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Click on the activate layout button in the actions list.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Deleting a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s tab.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'OptionTree->Settings->Layouts', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Click on the delete layout button in the actions list.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Edit Layout Data', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s page.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '
        • '; + echo '
        • ' . esc_html__( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '
        • '; + echo '
        • ' . esc_html__( 'If you want to edit a new layout, first create it then save your theme options.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '

        ' . esc_html__( 'End-Users Mode', 'option-tree' ) . ':

        '; + + echo '
        ' . esc_html__( 'Creating a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s page.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Enter a name for your layout in the text field and hit "New Layout", you\'ve created your first layout.', 'option-tree' ) . '
        • '; + echo '
        • ' . esc_html__( 'Adding a new layout is as easy as repeating the steps above.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Activating a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s page.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Choose a layout from the select list and click the "Activate Layout" button.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Deleting a Layout', 'option-tree' ) . ':
        '; + echo '
          '; + echo '
        • ' . esc_html__( 'End-Users mode does not allow deleting layouts.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        ' . esc_html__( 'Edit Layout Data', 'option-tree' ) . ':
        '; + echo '
          '; + + /* translators: %s: visual path to the page */ + $string = esc_html__( 'Go to the %s page.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'Appearance->Theme Options', 'option-tree' ) . '' ) . '
        • '; // phpcs:ignore + echo '
        • ' . esc_html__( 'Modify and save your theme options and the layout will be updated automatically.', 'option-tree' ) . '
        • '; + echo '
        • ' . esc_html__( 'Saving theme options data will update the currently active layout, so before you start saving make sure you want to modify the current layout.', 'option-tree' ) . '
        • '; + echo '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Meta Boxes option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_meta_boxes' ) ) { - - function ot_type_meta_boxes() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'How-to-guide', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'There are a few simple steps you need to take in order to use OptionTree\'s built in Meta Box API. In the code below I\'ll show you a basic demo of how to create your very own custom meta box using any number of the option types you have at your disposal. If you would like to see some demo code, there is a directory named theme-mode inside the assets directory that contains a file named demo-meta-boxes.php you can reference.', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'It\'s important to note that Meta Boxes do not support WYSIWYG editors at this time and if you set one of your options to Textarea it will automatically revert to a Textarea Simple until a valid solution is found. WordPress released this statement regarding the wp_editor() function:', 'option-tree' ) . '

        '; - - echo '
        ' . __( 'Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.', 'option-tree' ) . '
        '; - - echo '
        ' . __( 'Create and include your custom meta boxes file.', 'option-tree' ) . '
        '; - echo '
          '; - echo '
        • '. __( 'Create a file and name it anything you want, maybe meta-boxes.php.', 'option-tree' ) . '
        • '; - echo '
        • '. __( 'As well, you\'ll probably want to create a directory named includes to put your meta-boxes.php into which will help keep you file structure nice and tidy.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Add the following code to your functions.php.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        /**
        +
        +	/**
        +	 * Meta Boxes option type.
        +	 *
        +	 * @access public
        +	 * @since  2.0
        +	 */
        +	function ot_type_meta_boxes() {
        +
        +		// Format setting outer wrapper.
        +		echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'How-to-guide', 'option-tree' ) . '

        '; + + /* translators: %1$s: directory name, %2$s: directory name, %3$s: file type */ + $string = esc_html__( 'There are a few simple steps you need to take in order to use OptionTree\'s built in Meta Box API. In the code below I\'ll show you a basic demo of how to create your very own custom meta box using any number of the option types you have at your disposal. If you would like to see some demo code, there is a directory named %1$s inside the %2$s directory that contains a file named %3$s you can reference.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'theme-mode', 'assets', 'demo-meta-boxes.php' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'It\'s important to note that Meta Boxes do not support WYSIWYG editors at this time and if you set one of your options to Textarea it will automatically revert to a Textarea Simple until a valid solution is found. WordPress released this statement regarding the wp_editor() function:', 'option-tree' ) . '

        '; + + echo '
        ' . esc_html__( 'Once instantiated, the WYSIWYG editor cannot be moved around in the DOM. What this means in practical terms, is that you cannot put it in meta-boxes that can be dragged and placed elsewhere on the page.', 'option-tree' ) . '
        '; + + echo '
        ' . esc_html__( 'Create and include your custom meta boxes file.', 'option-tree' ) . '
        '; + + echo '
          '; + + /* translators: %s: file name */ + $string = esc_html__( 'Create a file and name it anything you want, maybe %s.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'meta-boxes.php' ) . '
        • '; // phpcs:ignore + + /* translators: %1$s: directory name, %2$s: file name */ + $string = esc_html__( 'As well, you\'ll probably want to create a directory named %1$s to put your %2$s into which will help keep you file structure nice and tidy.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'includes', 'meta-boxes.php' ) . '
        • '; // phpcs:ignore + + /* translators: %s: file name */ + $string = esc_html__( 'Add the following code to your %s.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'functions.php' ) . '
        • '; // phpcs:ignore + + echo '
        '; + + echo '
        /**
          * Meta Boxes
          */
         require( trailingslashit( get_template_directory() ) . \'includes/meta-boxes.php\' );
         
        '; - - echo '
          '; - echo '
        • ' . __( 'Add a variation of the following code to your meta-boxes.php. You\'ll obviously need to fill it in with all your custom array values. It\'s important to note here that we use the admin_init filter because if you were to call the ot_register_meta_box function before OptionTree was loaded the sky would fall on your head.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo "
        /**
        +
        +		echo '
          '; + + /* translators: %1$s: file name, %2$s: hook type, %3$s: function name */ + $string = esc_html__( 'Add a variation of the following code to your %1$s. You\'ll obviously need to fill it in with all your custom array values. It\'s important to note here that we use the %2$s filter because if you were to call the %3$s function before OptionTree was loaded the sky would fall on your head.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'meta-boxes.php', 'admin_init', 'ot_register_meta_box' ) . '
        • '; // phpcs:ignore + + echo '
        '; + + echo "
        /**
          * Initialize the meta boxes. 
          */
         add_action( 'admin_init', 'custom_meta_boxes' );
        @@ -784,46 +911,55 @@ function custom_meta_boxes() {
           
           ot_register_meta_box( $my_meta_box );
         
        -}
        "; - - echo '
        '; - - echo '
        '; - - } - +}
        "; + + echo '
        '; + + echo '
        '; + } } -/** - * Theme Mode option type. - * - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_theme_mode' ) ) { - - function ot_type_theme_mode() { - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo '
        '; - - echo '

        '. __( 'How-to-guide', 'option-tree' ) . '

        '; - - echo '

        ' . __( 'There are a few simple steps you need to take in order to use OptionTree as a theme included module. In the code below I\'ll show you a basic demo of how to include the entire plugin as a module, which will allow you to have the most up-to-date version of OptionTree without ever needing to hack the core of the plugin. If you would like to see some demo code, there is a directory named theme-mode inside the assets directory that contains a file named demo-theme-options.php you can reference.', 'option-tree' ) . '

        '; - - echo '
        ' . __( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '
        '; - echo '
          '; - echo '
        • ' . sprintf( __( 'Download the latest version of %s and unarchive the %s directory.', 'option-tree' ), '' . __( 'OptionTree', 'option-tree' ) . '', '.zip' ) . '
        • '; - echo '
        • ' . sprintf( __( 'Put the %s directory in the root of your theme. For example, the server path would be %s.', 'option-tree' ), 'option-tree', '/wp-content/themes/theme-name/option-tree/' ) . '
        • '; - echo '
        • ' . sprintf( __( 'Add the following code to the beginning of your %s.', 'option-tree' ), 'functions.php' ) . '
        • '; - echo '
        '; - - echo '
        /**
        +
        +	/**
        +	 * Theme Mode option type.
        +	 *
        +	 * @access public
        +	 * @since  2.0
        +	 */
        +	function ot_type_theme_mode() {
        +
        +		// Format setting outer wrapper.
        +		echo '
        '; + + // Description. + echo '
        '; + + echo '

        ' . esc_html__( 'How-to-guide', 'option-tree' ) . '

        '; + + /* translators: %1$s: directory name, %2$s: directory name, %3$s: file type */ + $string = esc_html__( 'There are a few simple steps you need to take in order to use OptionTree as a theme included module. In the code below I\'ll show you a basic demo of how to include the entire plugin as a module, which will allow you to have the most up-to-date version of OptionTree without ever needing to hack the core of the plugin. If you would like to see some demo code, there is a directory named %1$s inside the %2$s directory that contains a file named %3$s you can reference.', 'option-tree' ); + echo '

        ' . sprintf( $string, 'theme-mode', 'assets', 'demo-theme-options.php' ) . '

        '; // phpcs:ignore + + echo '
        ' . esc_html__( 'Step 1: Include the plugin & turn on theme mode.', 'option-tree' ) . '
        '; + + echo '
          '; + + /* translators: %1$s: directory name, %2$s: file type */ + $string = esc_html__( 'Download the latest version of %1$s and unarchive the %2$s directory.', 'option-tree' ); + echo '
        • ' . sprintf( $string, '' . esc_html__( 'OptionTree', 'option-tree' ) . '', '.zip' ) . '
        • '; // phpcs:ignore + + /* translators: %1$s: directory name, %2$s: directory path */ + $string = esc_html__( 'Put the %1$s directory in the root of your theme. For example, the server path would be %2$s.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'option-tree', '/wp-content/themes/theme-name/option-tree/' ) . '
        • '; // phpcs:ignore + + /* translators: %s: file name */ + $string = esc_html__( 'Add the following code to the beginning of your %s.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'functions.php' ) . '
        • '; // phpcs:ignore + + echo '
        '; + + echo '
        /**
          * Required: set \'ot_theme_mode\' filter to true.
          */
         add_filter( \'ot_theme_mode\', \'__return_true\' );
        @@ -833,31 +969,47 @@ function ot_type_theme_mode() {
          */
         require( trailingslashit( get_template_directory() ) . \'option-tree/ot-loader.php\' );
         
        '; - - echo '

        ' . sprintf( __( 'For a list of all the OptionTree UI display filters refer to the %s file found in the %s directory of this plugin. This file is the starting point for developing themes with Theme Mode.', 'option-tree' ), 'demo-functions.php', '/assets/theme-mode/' ) . '

        '; - - echo '

        ' . __( 'You now have OptionTree built into your theme and anytime an update is available replace the old version with the new one.', 'option-tree' ) . '

        '; - - echo '
        ' . __( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '
        '; - echo '
          '; - echo '
        • '. __( 'Create a file and name it anything you want, maybe theme-options.php, or use the built in file export to create it for you. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ) . '
        • '; - echo '
        • '. __( 'As well, you\'ll probably want to create a directory named includes to put your theme-options.php into which will help keep you file structure nice and tidy.', 'option-tree' ) . '
        • '; - echo '
        • ' . __( 'Add the following code to your functions.php.', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '
        /**
        +
        +		/* translators: %1$s: file name, %2$s: directory path */
        +		$string = esc_html__( 'For a list of all the OptionTree UI display filters refer to the %1$s file found in the %2$s directory of this plugin. This file is the starting point for developing themes with Theme Mode.', 'option-tree' );
        +		echo '

        ' . sprintf( $string, 'demo-functions.php', '/assets/theme-mode/' ) . '

        '; // phpcs:ignore + + echo '

        ' . esc_html__( 'You now have OptionTree built into your theme and anytime an update is available replace the old version with the new one.', 'option-tree' ) . '

        '; + + echo '
        ' . esc_html__( 'Step 2: Create Theme Options without using the UI Builder.', 'option-tree' ) . '
        '; + echo '
          '; + + /* translators: %s: file name */ + $string = esc_html__( 'Create a file and name it anything you want, maybe %s, or use the built in file export to create it for you. Remember, you should always check the file for errors before including it in your theme.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'theme-options.php' ) . '
        • '; // phpcs:ignore + + /* translators: %1$s: directory name, %2$s: file name */ + $string = esc_html__( 'As well, you\'ll probably want to create a directory named %1$s to put your %2$s into which will help keep you file structure nice and tidy.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'includes', 'theme-options.php' ) . '
        • '; // phpcs:ignore + + /* translators: %s: file name */ + $string = esc_html__( 'Add the following code to your %s.', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'functions.php' ) . '
        • '; // phpcs:ignore + + echo '
        '; + + echo '
        /**
          * Theme Options
          */
         require( trailingslashit( get_template_directory() ) . \'includes/theme-options.php\' );
         
        '; - - echo '
          '; - echo '
        • ' . __( 'Add a variation of the following code to your theme-options.php. You\'ll obviously need to fill it in with all your custom array values for contextual help (optional), sections (required), and settings (required).', 'option-tree' ) . '
        • '; - echo '
        '; - - echo '

        ' . __( 'The code below is a boilerplate to get your started. For a full list of the available option types click the "Option Types" tab above. Also a quick note, you don\'t need to put OptionTree in theme mode to manually create options but you will want to hide the docs and settings as each time you load the admin area the settings be written over with the code below if they\'ve changed in any way. However, this ensures your settings do not get tampered with by the end-user.', 'option-tree' ) . '

        '; - - echo "
        /**
        +
        +		echo '
          '; + + /* translators: %s: file name */ + $string = esc_html__( 'Add a variation of the following code to your %s. You\'ll obviously need to fill it in with all your custom array values for contextual help (optional), sections (required), and settings (required).', 'option-tree' ); + echo '
        • ' . sprintf( $string, 'theme-options.php' ) . '
        • '; // phpcs:ignore + + echo '
        '; + + echo '

        ' . esc_html__( 'The code below is a boilerplate to get your started. For a full list of the available option types click the "Option Types" tab above. Also a quick note, you don\'t need to put OptionTree in theme mode to manually create options but you will want to hide the docs and settings as each time you load the admin area the settings be written over with the code below if they\'ve changed in any way. However, this ensures your settings do not get tampered with by the end-user.', 'option-tree' ) . '

        '; + + echo "
        /**
          * Initialize the options before anything else. 
          */
         add_action( 'init', 'custom_theme_options', 1 );
        @@ -1007,14 +1159,9 @@ function custom_theme_options() {
           
         }
         
        "; - - echo '
        '; - - echo '
        '; - - } - -} -/* End of file ot-functions-docs-page.php */ -/* Location: ./includes/ot-functions-docs-page.php */ \ No newline at end of file + echo '
        '; + + echo '
        '; + } +} From 10ac3c319bd10bb131531b6cec46e177f7436505 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 05:14:16 -0800 Subject: [PATCH 18/67] Fix file docblock --- includes/class-ot-post-formats.php | 2 +- includes/ot-functions-compat.php | 2 +- includes/ot-functions-deprecated.php | 2 +- includes/ot-functions-settings-page.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/class-ot-post-formats.php b/includes/class-ot-post-formats.php index 47f7759..e6d4d1c 100755 --- a/includes/class-ot-post-formats.php +++ b/includes/class-ot-post-formats.php @@ -2,7 +2,7 @@ /** * OptionTree Post Formats. * - * @package OptionTree + * @package OptionTree */ if ( ! defined( 'OT_VERSION' ) ) { diff --git a/includes/ot-functions-compat.php b/includes/ot-functions-compat.php index 81b1494..c7a4811 100755 --- a/includes/ot-functions-compat.php +++ b/includes/ot-functions-compat.php @@ -1,6 +1,6 @@ Date: Sun, 3 Mar 2019 05:28:58 -0800 Subject: [PATCH 19/67] Fix broken code --- includes/ot-functions-docs-page.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/ot-functions-docs-page.php b/includes/ot-functions-docs-page.php index cd555e4..c1fd3c8 100755 --- a/includes/ot-functions-docs-page.php +++ b/includes/ot-functions-docs-page.php @@ -644,7 +644,7 @@ function ot_type_examples() { echo '

        ' . esc_html__( 'Array Examples', 'option-tree' ) . ':

        '; /* translators: %1$s: option id, %2$s: variable name, %3$s: function name */ - $string = esc_html__( 'Assigns the value of to the variable . It then echos an unordered list of links (navigation) using .', 'option-tree' ); + $string = esc_html__( 'Assigns the value of %1$s to the variable %2$s. It then echos an unordered list of links (navigation) using %3$s.', 'option-tree' ); echo '

        ' . sprintf( $string, 'navigation_ids', '$ids', 'wp_list_pages()' ) . '

        '; // phpcs:ignore echo '
        if ( function_exists( \'ot_get_option\' ) ) {
        @@ -667,7 +667,7 @@ function ot_type_examples() {
         
         		/* translators: %s: option type name */
         		$string = esc_html__( 'The next two examples demonstrate how to use the %s option type. The Measurement option type is an array with two key/value pairs. The first is the value of measurement and the second is the unit of measurement.', 'option-tree' );
        -		echo '

        ' . sprintf( $string. '' . esc_html__( 'Measurement', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore + echo '

        ' . sprintf( $string, '' . esc_html__( 'Measurement', 'option-tree' ) . '' ) . '

        '; // phpcs:ignore echo '
        if ( function_exists( \'ot_get_option\' ) ) {
           /* get the array */
        
        From aa5358c8f058523f7d92cbf13dd77b1be8a2f175 Mon Sep 17 00:00:00 2001
        From: Derek Herman 
        Date: Sun, 3 Mar 2019 06:30:15 -0800
        Subject: [PATCH 20/67] Fix phpcs issues
        
        ---
         includes/class-ot-settings.php | 1009 ++++++++++++++++++++++++++++++
         includes/ot-settings-api.php   | 1052 --------------------------------
         ot-loader.php                  |    2 +-
         3 files changed, 1010 insertions(+), 1053 deletions(-)
         create mode 100755 includes/class-ot-settings.php
         delete mode 100755 includes/ot-settings-api.php
        
        diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php
        new file mode 100755
        index 0000000..eb5fa37
        --- /dev/null
        +++ b/includes/class-ot-settings.php
        @@ -0,0 +1,1009 @@
        +options = $args;
        +
        +			// Return early if not viewing an admin page or no options.
        +			if ( ! is_admin() || ! is_array( $this->options ) ) {
        +				return false;
        +			}
        +
        +			// Load everything.
        +			$this->hooks();
        +		}
        +
        +		/**
        +		 * Execute the WordPress Hooks
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function hooks() {
        +
        +			/**
        +			 * Filter the `admin_menu` action hook priority.
        +			 *
        +			 * @since 2.5.0
        +			 *
        +			 * @param int $priority The priority. Default '10'.
        +			 */
        +			$priority = apply_filters( 'ot_admin_menu_priority', 10 );
        +
        +			// Add pages & menu items.
        +			add_action( 'admin_menu', array( $this, 'add_page' ), $priority );
        +
        +			// Register sections.
        +			add_action( 'admin_init', array( $this, 'add_sections' ) );
        +
        +			// Register settings.
        +			add_action( 'admin_init', array( $this, 'add_settings' ) );
        +
        +			// Reset options.
        +			add_action( 'admin_init', array( $this, 'reset_options' ), 10 );
        +
        +			// Initialize settings.
        +			add_action( 'admin_init', array( $this, 'initialize_settings' ), 11 );
        +		}
        +
        +		/**
        +		 * Loads each admin page
        +		 *
        +		 * @return bool
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function add_page() {
        +
        +			// Loop through options.
        +			foreach ( (array) $this->options as $option ) {
        +
        +				// Loop through pages.
        +				foreach ( (array) $this->get_pages( $option ) as $page ) {
        +
        +					/**
        +					 * Theme Check... stop nagging me about this kind of stuff.
        +					 * The damn admin pages are required for OT to function, duh!
        +					 */
        +					$theme_check_bs  = 'add_menu_' . 'page'; // phpcs:ignore
        +					$theme_check_bs2 = 'add_submenu_' . 'page'; // phpcs:ignore
        +
        +					// Load page in WP top level menu.
        +					if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) {
        +						$page_hook = $theme_check_bs(
        +							$page['page_title'],
        +							$page['menu_title'],
        +							$page['capability'],
        +							$page['menu_slug'],
        +							array( $this, 'display_page' ),
        +							$page['icon_url'],
        +							$page['position']
        +						);
        +
        +						// Load page in WP sub menu.
        +					} else {
        +						$page_hook = $theme_check_bs2(
        +							$page['parent_slug'],
        +							$page['page_title'],
        +							$page['menu_title'],
        +							$page['capability'],
        +							$page['menu_slug'],
        +							array( $this, 'display_page' )
        +						);
        +					}
        +
        +					// Only load if not a hidden page.
        +					if ( ! isset( $page['hidden_page'] ) ) {
        +
        +						// Associate $page_hook with page id.
        +						$this->page_hook[ $page['id'] ] = $page_hook;
        +
        +						// Add scripts.
        +						add_action( 'admin_print_scripts-' . $page_hook, array( $this, 'scripts' ) );
        +
        +						// Add styles.
        +						add_action( 'admin_print_styles-' . $page_hook, array( $this, 'styles' ) );
        +
        +						// Add contextual help.
        +						add_action( 'load-' . $page_hook, array( $this, 'help' ) );
        +					}
        +				}
        +			}
        +
        +			return false;
        +		}
        +
        +		/**
        +		 * Loads the scripts
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function scripts() {
        +			ot_admin_scripts();
        +		}
        +
        +		/**
        +		 * Loads the styles
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function styles() {
        +			ot_admin_styles();
        +		}
        +
        +		/**
        +		 * Loads the contextual help for each page
        +		 *
        +		 * @return bool
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function help() {
        +			$screen = get_current_screen();
        +
        +			// Loop through options.
        +			foreach ( (array) $this->options as $option ) {
        +
        +				// Loop through pages.
        +				foreach ( (array) $this->get_pages( $option ) as $page ) {
        +
        +					// Verify page.
        +					if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
        +
        +						// Set up the help tabs.
        +						if ( ! empty( $page['contextual_help']['content'] ) ) {
        +							foreach ( $page['contextual_help']['content'] as $contextual_help ) {
        +								$screen->add_help_tab(
        +									array(
        +										'id'      => esc_attr( $contextual_help['id'] ),
        +										'title'   => esc_attr( $contextual_help['title'] ),
        +										'content' => htmlspecialchars_decode( $contextual_help['content'] ),
        +									)
        +								);
        +							}
        +						}
        +
        +						// Set up the help sidebar.
        +						if ( ! empty( $page['contextual_help']['sidebar'] ) ) {
        +							$screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) );
        +						}
        +					}
        +				}
        +			}
        +
        +			return false;
        +		}
        +
        +		/**
        +		 * Loads the content for each page
        +		 *
        +		 * @access public
        +		 * @since  2.0
        +		 */
        +		public function display_page() {
        +			$screen = get_current_screen();
        +
        +			// Loop through settings.
        +			foreach ( (array) $this->options as $option ) {
        +
        +				// Loop through pages.
        +				foreach ( (array) $this->get_pages( $option ) as $page ) {
        +
        +					// Verify page.
        +					if ( ! isset( $page['hidden_page'] ) && $screen->id === $this->page_hook[ $page['id'] ] ) {
        +
        +						$show_buttons = isset( $page['show_buttons'] ) && false === $page['show_buttons'] ? false : true;
        +
        +						// Update active layout content.
        +						if ( isset( $_REQUEST['settings-updated'] ) && true === $_REQUEST['settings-updated'] ) { // phpcs:ignore
        +
        +							$layouts = get_option( ot_layouts_id() );
        +
        +							// Has active layout.
        +							if ( isset( $layouts['active_layout'] ) ) {
        +								$option_tree                          = get_option( $option['id'] );
        +								$layouts[ $layouts['active_layout'] ] = ot_encode( maybe_serialize( $option_tree ) );
        +								update_option( ot_layouts_id(), $layouts );
        +							}
        +						}
        +
        +						echo '
        '; + + echo '

        ' . wp_kses_post( $page['page_title'] ) . '

        '; + + echo ot_alert_message( $page ); // phpcs:ignore + + settings_errors( 'option-tree' ); + + // Header. + echo '
        '; + + echo '
          '; + + $link = '' . esc_html__( 'OptionTree', 'option-tree' ) . ''; + echo ''; + + echo '
        • ' . esc_html( apply_filters( 'ot_header_version_text', 'OptionTree ' . OT_VERSION, $page['id'] ) ) . '
        • '; + + // Add additional theme specific links here. + do_action( 'ot_header_list', $page['id'] ); + + echo '
        '; + + // Layouts form. + if ( 'ot_theme_options' === $page['id'] && true === OT_SHOW_NEW_LAYOUT ) { + ot_theme_options_layouts_form(); + } + + echo '
        '; + + // Remove forms on the custom settings pages. + if ( $show_buttons ) { + + echo '
        '; + + settings_fields( $option['id'] ); + } else { + + echo '
        '; + } + + // Sub Header. + echo '
        '; + + if ( $show_buttons ) { + echo ''; + } + + echo '
        '; + + // Navigation. + echo '
        '; + + // Check for sections. + if ( isset( $page['sections'] ) && 0 < count( $page['sections'] ) ) { + + echo ''; + } + + // Sections. + echo '
        '; + + echo '
        '; + + echo '
        '; + + $this->do_settings_sections( isset( $_GET['page'] ) ? $_GET['page'] : '' ); // phpcs:ignore + + echo '
        '; + + echo '
        '; + + echo '
        '; + + echo '
        '; + + echo '
        '; + + // Buttons. + if ( $show_buttons ) { + + echo '
        '; + + echo ''; + + echo '
        '; + } + + echo $show_buttons ? '' : '
        '; + + // Reset button. + if ( $show_buttons ) { + + echo '
        '; // phpcs:ignore + + // Form nonce. + wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' ); + + echo ''; + + echo ''; + + echo '
        '; + } + + echo '
        '; + } + } + } + + return false; + } + + /** + * Adds sections to the page + * + * @return bool + * + * @access public + * @since 2.0 + */ + public function add_sections() { + + // Loop through options. + foreach ( (array) $this->options as $option ) { + + // Loop through pages. + foreach ( (array) $this->get_pages( $option ) as $page ) { + + // Loop through page sections. + foreach ( (array) $this->get_sections( $page ) as $section ) { + + // Add each section. + add_settings_section( + $section['id'], + $section['title'], + array( $this, 'display_section' ), + $page['menu_slug'] + ); + + } + } + } + + return false; + } + + /** + * Callback for add_settings_section() + * + * @access public + * @since 2.0 + */ + public function display_section() { + /* currently pointless */ + } + + /** + * Add settings the the page + * + * @return bool + * + * @access public + * @since 2.0 + */ + public function add_settings() { + + // Loop through options. + foreach ( (array) $this->options as $option ) { + + register_setting( $option['id'], $option['id'], array( $this, 'sanitize_callback' ) ); + + // Loop through pages. + foreach ( (array) $this->get_pages( $option ) as $page ) { + + // Loop through page settings. + foreach ( (array) $this->get_the_settings( $page ) as $setting ) { + + // Skip if no setting ID. + if ( ! isset( $setting['id'] ) ) { + continue; + } + + // Add get_option param to the array. + $setting['get_option'] = $option['id']; + + // Add each setting. + add_settings_field( + $setting['id'], + $setting['label'], + array( $this, 'display_setting' ), + $page['menu_slug'], + $setting['section'], + $setting + ); + + } + } + } + + return false; + } + + /** + * Callback for add_settings_field() to build each setting by type + * + * @param array $args Setting object array. + * + * @access public + * @since 2.0 + */ + public function display_setting( $args = array() ) { + extract( $args ); // phpcs:ignore + + // Get current saved data. + $options = get_option( $get_option, false ); + + // Set field value. + $field_value = isset( $options[ $id ] ) ? $options[ $id ] : ''; + + // Set standard value. + if ( isset( $std ) ) { + $field_value = ot_filter_std_value( $field_value, $std ); + } + + // Allow the descriptions to be filtered before being displayed. + $desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id ); + + // Build the arguments array. + $_args = array( + 'type' => $type, + 'field_id' => $id, + 'field_name' => $get_option . '[' . $id . ']', + 'field_value' => $field_value, + 'field_desc' => $desc, + 'field_std' => isset( $std ) ? $std : '', + 'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15, + 'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post', + 'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category', + 'field_min_max_step' => isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1', + 'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '', + 'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and', + 'field_class' => isset( $class ) ? $class : '', + 'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(), + 'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(), + 'post_id' => ot_get_media_post_ID(), + 'get_option' => $get_option, + ); + + // Limit DB queries for Google Fonts. + if ( 'google-fonts' === $type ) { + ot_fetch_google_fonts(); + ot_set_google_fonts( $id, $field_value ); + } + + // Get the option HTML. + echo ot_display_by_type( $_args ); // phpcs:ignore + } + + /** + * Sets the option standards if nothing yet exists. + * + * @access public + * @since 2.0 + */ + public function initialize_settings() { + + // :oop through options. + foreach ( (array) $this->options as $option ) { + + // Skip if option is already set. + if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) { + return false; + } + + $defaults = array(); + + // Loop through pages. + foreach ( (array) $this->get_pages( $option ) as $page ) { + + // Loop through page settings. + foreach ( (array) $this->get_the_settings( $page ) as $setting ) { + + if ( isset( $setting['std'] ) ) { + + $defaults[ $setting['id'] ] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] ); + } + } + } + + update_option( $option['id'], $defaults ); + } + + return false; + } + + /** + * Sanitize callback for register_setting() + * + * @param mixed $input The setting input. + * @return string + * + * @access public + * @since 2.0 + */ + public function sanitize_callback( $input ) { + + // Store the post global for use later. + $post_global = $_POST; // phpcs:ignore + + // Loop through options. + foreach ( (array) $this->options as $option ) { + + // Loop through pages. + foreach ( (array) $this->get_pages( $option ) as $page ) { + + // Loop through page settings. + foreach ( (array) $this->get_the_settings( $page ) as $setting ) { + + // Verify setting has a type & value. + if ( isset( $setting['type'] ) && isset( $input[ $setting['id'] ] ) ) { + + // Get the defaults. + $current_settings = get_option( ot_settings_id() ); + $current_options = get_option( $option['id'] ); + + // Validate setting. + if ( is_array( $input[ $setting['id'] ] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) { + + // Required title setting. + $required_setting = array( + array( + 'id' => 'title', + 'label' => __( 'Title', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'text', + 'rows' => '', + 'class' => 'option-tree-setting-title', + 'post_type' => '', + 'choices' => array(), + ), + ); + + $decoded = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } + + // Convert the settings to an array. + $settings = maybe_unserialize( $decoded ); + + // Settings are empty for some odd ass reason get the defaults. + if ( empty( $settings ) ) { + $settings = 'slider' === $setting['type'] ? ot_slider_settings( $setting['id'] ) : ot_list_item_settings( $setting['id'] ); + } + + // Merge the two settings arrays. + $settings = array_merge( $required_setting, $settings ); + + // Create an empty WPML id array. + $wpml_ids = array(); + + foreach ( $input[ $setting['id'] ] as $k => $setting_array ) { + + foreach ( $settings as $sub_setting ) { + + // Setup the WPML ID. + $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k; + + // Add id to array. + $wpml_ids[] = $wpml_id; + + /* verify sub setting has a type & value */ + if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) { + + // Validate setting. + $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); + } + } + } + } elseif ( is_array( $input[ $setting['id'] ] ) && 'social-links' === $setting['type'] ) { + + $decoded = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } + + // Convert the settings to an array. + $settings = maybe_unserialize( $decoded ); + + // Settings are empty get the defaults. + if ( empty( $settings ) ) { + $settings = ot_social_links_settings( $setting['id'] ); + } + + // Create an empty WPML id array. + $wpml_ids = array(); + + foreach ( $input[ $setting['id'] ] as $k => $setting_array ) { + + foreach ( $settings as $sub_setting ) { + + // Setup the WPML ID. + $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k; + + // Add id to array. + $wpml_ids[] = $wpml_id; + + // Verify sub setting has a type & value. + if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) { + + // Validate setting. + $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); + } + } + } + } else { + $input[ $setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ], $setting['type'], $setting['id'], $setting['id'] ); + } + } + + // Unregister WPML strings that were deleted from lists and sliders. + if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && in_array( $setting['type'], array( 'list-item', 'slider' ), true ) ) { + + if ( ! isset( $wpml_ids ) ) { + $wpml_ids = array(); + } + + foreach ( $current_settings['settings'] as $check_setting ) { + + if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) { + + foreach ( $current_options[ $setting['id'] ] as $key => $value ) { + + foreach ( $value as $ckey => $cvalue ) { + + $id = $setting['id'] . '_' . $ckey . '_' . $key; + + if ( ! in_array( $id, $wpml_ids, true ) ) { + ot_wpml_unregister_string( $id ); + } + } + } + } + } + } + + /* unregister WPML strings that were deleted from social links */ + if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && 'social-links' === $setting['type'] ) { + + if ( ! isset( $wpml_ids ) ) { + $wpml_ids = array(); + } + + foreach ( $current_settings['settings'] as $check_setting ) { + + if ( $setting['id'] === $check_setting['id'] && ! empty( $current_options[ $setting['id'] ] ) ) { + + foreach ( $current_options[ $setting['id'] ] as $key => $value ) { + + foreach ( $value as $ckey => $cvalue ) { + + $id = $setting['id'] . '_' . $ckey . '_' . $key; + + if ( ! in_array( $id, $wpml_ids, true ) ) { + ot_wpml_unregister_string( $id ); + } + } + } + } + } + } + } + } + } + + return $input; + } + + /** + * Helper function to get the pages array for an option + * + * @param array $option Option array. + * @return mixed + * + * @access public + * @since 2.0 + */ + public function get_pages( $option = array() ) { + + if ( empty( $option ) ) { + return false; + } + + // Check for pages. + if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) { + + // Return pages array. + return $option['pages']; + + } + + return false; + } + + /** + * Helper function to get the sections array for a page + * + * @param array $page Page array. + * @return mixed + * + * @access public + * @since 2.0 + */ + public function get_sections( $page = array() ) { + + if ( empty( $page ) ) { + return false; + } + + // Check for sections. + if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) { + + // Return sections array. + return $page['sections']; + + } + + return false; + } + + /** + * Helper function to get the settings array for a page + * + * @param array $page Page array. + * @return mixed + * + * @access public + * @since 2.0 + */ + public function get_the_settings( $page = array() ) { + + if ( empty( $page ) ) { + return false; + } + + /* check for settings */ + if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) { + + /* return settings array */ + return $page['settings']; + + } + + return false; + } + + /** + * Prints out all settings sections added to a particular settings page + * + * @global $wp_settings_sections Storage array of all settings sections added to admin pages. + * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections. + * + * @param string $page The slug name of the page whos settings sections you want to output. + * @return string + * + * @access public + * @since 2.0 + */ + public function do_settings_sections( $page ) { + global $wp_settings_sections, $wp_settings_fields; + + if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[ $page ] ) ) { + return false; + } + + foreach ( (array) $wp_settings_sections[ $page ] as $section ) { + + if ( ! isset( $section['id'] ) ) { + continue; + } + + $section_id = $section['id']; + + echo '
        '; + + call_user_func( $section['callback'], $section ); + + if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section_id ] ) ) { + continue; + } + + echo '
        '; + + /** + * Hook to insert arbitrary markup before the `do_settings_fields` method. + * + * @since 2.6.0 + * + * @param string $page The page slug. + * @param string $section_id The section ID. + */ + do_action( 'ot_do_settings_fields_before', $page, $section_id ); + + $this->do_settings_fields( $page, $section_id ); + + /** + * Hook to insert arbitrary markup after the `do_settings_fields` method. + * + * @since 2.6.0 + * + * @param string $page The page slug. + * @param string $section_id The section ID. + */ + do_action( 'ot_do_settings_fields_after', $page, $section_id ); + + echo '
        '; + + echo '
        '; + } + + } + + /** + * Print out the settings fields for a particular settings section + * + * @global $wp_settings_fields Storage array of settings fields and their pages/sections + * + * @param string $page Slug title of the admin page who's settings fields you want to show. + * @param string $section Slug title of the settings section who's fields you want to show. + * @return string + * + * @access public + * @since 2.0 + */ + public function do_settings_fields( $page, $section ) { + global $wp_settings_fields; + + if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[ $page ] ) || ! isset( $wp_settings_fields[ $page ][ $section ] ) ) { + return; + } + + foreach ( (array) $wp_settings_fields[ $page ][ $section ] as $field ) { + + $conditions = ''; + + if ( isset( $field['args']['condition'] ) && ! empty( $field['args']['condition'] ) ) { + + $conditions = ' data-condition="' . esc_attr( $field['args']['condition'] ) . '"'; + $conditions .= isset( $field['args']['operator'] ) && in_array( $field['args']['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['args']['operator'] ) . '"' : ''; + } + + // Build the setting CSS class. + if ( isset( $field['args']['class'] ) && ! empty( $field['args']['class'] ) ) { + + $classes = explode( ' ', $field['args']['class'] ); + + foreach ( $classes as $key => $value ) { + $classes[ $key ] = $value . '-wrap'; + } + + $class = 'format-settings ' . implode( ' ', $classes ); + } else { + + $class = 'format-settings'; + } + + echo '
        '; // phpcs:ignore + + echo '
        '; + + if ( 'textblock' !== $field['args']['type'] && ! empty( $field['title'] ) ) { + + echo '
        '; + + echo '

        ' . wp_kses_post( $field['title'] ) . '

        '; + + echo '
        '; + } + + call_user_func( $field['callback'], $field['args'] ); + + echo '
        '; + + echo '
        '; + } + } + + /** + * Resets page options before the screen is displayed + * + * @access public + * @since 2.0 + * + * @return bool + */ + public function reset_options() { + + // Check for reset action. + if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) { // phpcs:ignore + + // Loop through options. + foreach ( (array) $this->options as $option ) { + + // Loop through pages. + foreach ( (array) $this->get_pages( $option ) as $page ) { + + // Verify page. + if ( isset( $_GET['page'] ) && $_GET['page'] === $page['menu_slug'] ) { + + // Reset options. + delete_option( $option['id'] ); + } + } + } + } + return false; + } + } + +} + +if ( ! function_exists( 'ot_register_settings' ) ) { + + /** + * This method instantiates the settings class & builds the UI. + * + * @uses OT_Settings() + * + * @param array $args Array of arguments to create settings. + * + * @access public + * @since 2.0 + */ + function ot_register_settings( $args ) { + if ( ! $args ) { + return; + } + + new OT_Settings( $args ); + } +} diff --git a/includes/ot-settings-api.php b/includes/ot-settings-api.php deleted file mode 100755 index db922c9..0000000 --- a/includes/ot-settings-api.php +++ /dev/null @@ -1,1052 +0,0 @@ - - * @copyright Copyright (c) 2013, Derek Herman - */ -if ( ! class_exists( 'OT_Settings' ) ) { - - class OT_Settings { - - /* the options array */ - private $options; - - /* hooks for targeting admin pages */ - private $page_hook; - - /** - * Constructor - * - * @param array An array of options - * @return void - * - * @access public - * @since 2.0 - */ - public function __construct( $args ) { - - $this->options = $args; - - /* return early if not viewing an admin page or no options */ - if ( ! is_admin() || ! is_array( $this->options ) ) - return false; - - /* load everything */ - $this->hooks(); - - } - - /** - * Execute the WordPress Hooks - * - * @return void - * - * @access public - * @since 2.0 - */ - public function hooks() { - - /** - * Filter the `admin_menu` action hook priority. - * - * @since 2.5.0 - * - * @param int $priority The priority. Default '10'. - */ - $priority = apply_filters( 'ot_admin_menu_priority', 10 ); - - /* add pages & menu items */ - add_action( 'admin_menu', array( $this, 'add_page' ), $priority ); - - /* register sections */ - add_action( 'admin_init', array( $this, 'add_sections' ) ); - - /* register settings */ - add_action( 'admin_init', array( $this, 'add_settings' ) ); - - /* reset options */ - add_action( 'admin_init', array( $this, 'reset_options' ), 10 ); - - /* initialize settings */ - add_action( 'admin_init', array( $this, 'initialize_settings' ), 11 ); - - } - - /** - * Loads each admin page - * - * @return void - * - * @access public - * @since 2.0 - */ - public function add_page() { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /** - * Theme Check... stop nagging me about this kind of stuff. - * The damn admin pages are required for OT to function, duh! - */ - $theme_check_bs = 'add_menu_' . 'page'; - $theme_check_bs2 = 'add_submenu_' . 'page'; - - /* load page in WP top level menu */ - if ( ! isset( $page['parent_slug'] ) || empty( $page['parent_slug'] ) ) { - $page_hook = $theme_check_bs( - $page['page_title'], - $page['menu_title'], - $page['capability'], - $page['menu_slug'], - array( $this, 'display_page' ), - $page['icon_url'], - $page['position'] - ); - /* load page in WP sub menu */ - } else { - $page_hook = $theme_check_bs2( - $page['parent_slug'], - $page['page_title'], - $page['menu_title'], - $page['capability'], - $page['menu_slug'], - array( $this, 'display_page' ) - ); - } - - /* only load if not a hidden page */ - if ( ! isset( $page['hidden_page'] ) ) { - - /* associate $page_hook with page id */ - $this->page_hook[$page['id']] = $page_hook; - - /* add scripts */ - add_action( 'admin_print_scripts-' . $page_hook, array( $this, 'scripts' ) ); - - /* add styles */ - add_action( 'admin_print_styles-' . $page_hook, array( $this, 'styles' ) ); - - /* add contextual help */ - add_action( 'load-' . $page_hook, array( $this, 'help' ) ); - - } - - } - - } - - return false; - } - - /** - * Loads the scripts - * - * @return void - * - * @access public - * @since 2.0 - */ - public function scripts() { - ot_admin_scripts(); - } - - /** - * Loads the styles - * - * @return void - * - * @access public - * @since 2.0 - */ - public function styles() { - ot_admin_styles(); - } - - /** - * Loads the contextual help for each page - * - * @return void - * - * @access public - * @since 2.0 - */ - public function help() { - $screen = get_current_screen(); - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* verify page */ - if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) { - - /* set up the help tabs */ - if ( ! empty( $page['contextual_help']['content'] ) ) { - foreach( $page['contextual_help']['content'] as $contextual_help ) { - $screen->add_help_tab( - array( - 'id' => esc_attr( $contextual_help['id'] ), - 'title' => esc_attr( $contextual_help['title'] ), - 'content' => htmlspecialchars_decode( $contextual_help['content'] ), - ) - ); - } - } - - /* set up the help sidebar */ - if ( ! empty( $page['contextual_help']['sidebar'] ) ) { - $screen->set_help_sidebar( htmlspecialchars_decode( $page['contextual_help']['sidebar'] ) ); - } - - } - - } - - } - - return false; - } - - /** - * Loads the content for each page - * - * @return string - * - * @access public - * @since 2.0 - */ - public function display_page() { - $screen = get_current_screen(); - - /* loop through settings */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* verify page */ - if ( ! isset( $page['hidden_page'] ) && $screen->id == $this->page_hook[$page['id']] ) { - - $show_buttons = isset( $page['show_buttons'] ) && $page['show_buttons'] == false ? false : true; - - /* update active layout content */ - if ( isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ) { - - $layouts = get_option( ot_layouts_id() ); - - /* has active layout */ - if ( isset( $layouts['active_layout'] ) ) { - $option_tree = get_option( $option['id'] ); - $layouts[$layouts['active_layout']] = ot_encode( serialize( $option_tree ) ); - update_option( ot_layouts_id(), $layouts ); - } - - } - - echo '
        '; - - echo '

        ' . $page['page_title'] . '

        '; - - echo ot_alert_message( $page ); - - settings_errors( 'option-tree' ); - - /* Header */ - echo '
        '; - - echo '
          '; - - echo ''; - - echo '
        • ' . apply_filters( 'ot_header_version_text', 'OptionTree ' . OT_VERSION, $page['id'] ) . '
        • '; - - // Add additional theme specific links here. - do_action( 'ot_header_list', $page['id'] ); - - echo '
        '; - - /* layouts form */ - if ( $page['id'] == 'ot_theme_options' && OT_SHOW_NEW_LAYOUT == true ) - ot_theme_options_layouts_form(); - - echo '
        '; - - /* remove forms on the custom settings pages */ - if ( $show_buttons ) { - - echo '
        '; - - settings_fields( $option['id'] ); - - } else { - - echo '
        '; - - } - - /* Sub Header */ - echo '
        '; - - if ( $show_buttons ) - echo ''; - - echo '
        '; - - /* Navigation */ - echo '
        '; - - /* check for sections */ - if ( isset( $page['sections'] ) && count( $page['sections'] ) > 0 ) { - - echo '
          '; - - /* loop through page sections */ - foreach( (array) $page['sections'] as $section ) { - echo '
        • ' . $section['title'] . '
        • '; - } - - echo '
        '; - - } - - /* sections */ - echo '
        '; - - echo '
        '; - - echo '
        '; - - $this->do_settings_sections( $_GET['page'] ); - - echo '
        '; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - /* buttons */ - if ( $show_buttons ) { - - echo '
        '; - - echo ''; - - echo '
        '; - - } - - echo $show_buttons ? '' : '
        '; - - /* reset button */ - if ( $show_buttons ) { - - echo '
        '; - - /* form nonce */ - wp_nonce_field( 'option_tree_reset_form', 'option_tree_reset_nonce' ); - - echo ''; - - echo ''; - - echo '
        '; - - } - - echo '
        '; - - } - - } - - } - - return false; - } - - /** - * Adds sections to the page - * - * @return void - * - * @access public - * @since 2.0 - */ - public function add_sections() { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* loop through page sections */ - foreach( (array) $this->get_sections( $page ) as $section ) { - - /* add each section */ - add_settings_section( - $section['id'], - $section['title'], - array( $this, 'display_section' ), - $page['menu_slug'] - ); - - } - - } - - } - - return false; - } - - /** - * Callback for add_settings_section() - * - * @return string - * - * @access public - * @since 2.0 - */ - public function display_section() { - /* currently pointless */ - } - - /** - * Add settings the the page - * - * @return void - * - * @access public - * @since 2.0 - */ - public function add_settings() { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - register_setting( $option['id'], $option['id'], array ( $this, 'sanitize_callback' ) ); - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* loop through page settings */ - foreach( (array) $this->get_the_settings( $page ) as $setting ) { - - /* skip if no setting ID */ - if ( ! isset( $setting['id'] ) ) - continue; - - /* add get_option param to the array */ - $setting['get_option'] = $option['id']; - - /* add each setting */ - add_settings_field( - $setting['id'], - $setting['label'], - array( $this, 'display_setting' ), - $page['menu_slug'], - $setting['section'], - $setting - ); - - } - - } - - } - - return false; - } - - /** - * Callback for add_settings_field() to build each setting by type - * - * @param array Setting object array - * @return string - * - * @access public - * @since 2.0 - */ - public function display_setting( $args = array() ) { - - extract( $args ); - - /* get current saved data */ - $options = get_option( $get_option, false ); - - // Set field value - $field_value = isset( $options[$id] ) ? $options[$id] : ''; - - /* set standard value */ - if ( isset( $std ) ) { - $field_value = ot_filter_std_value( $field_value, $std ); - } - - // Allow the descriptions to be filtered before being displayed - $desc = apply_filters( 'ot_filter_description', ( isset( $desc ) ? $desc : '' ), $id ); - - /* build the arguments array */ - $_args = array( - 'type' => $type, - 'field_id' => $id, - 'field_name' => $get_option . '[' . $id . ']', - 'field_value' => $field_value, - 'field_desc' => $desc, - 'field_std' => isset( $std ) ? $std : '', - 'field_rows' => isset( $rows ) && ! empty( $rows ) ? $rows : 15, - 'field_post_type' => isset( $post_type ) && ! empty( $post_type ) ? $post_type : 'post', - 'field_taxonomy' => isset( $taxonomy ) && ! empty( $taxonomy ) ? $taxonomy : 'category', - 'field_min_max_step'=> isset( $min_max_step ) && ! empty( $min_max_step ) ? $min_max_step : '0,100,1', - 'field_condition' => isset( $condition ) && ! empty( $condition ) ? $condition : '', - 'field_operator' => isset( $operator ) && ! empty( $operator ) ? $operator : 'and', - 'field_class' => isset( $class ) ? $class : '', - 'field_choices' => isset( $choices ) && ! empty( $choices ) ? $choices : array(), - 'field_settings' => isset( $settings ) && ! empty( $settings ) ? $settings : array(), - 'post_id' => ot_get_media_post_ID(), - 'get_option' => $get_option, - ); - - // Limit DB queries for Google Fonts. - if ( $type == 'google-fonts' ) { - ot_fetch_google_fonts(); - ot_set_google_fonts( $id, $field_value ); - } - - /* get the option HTML */ - echo ot_display_by_type( $_args ); - } - - /** - * Sets the option standards if nothing yet exists. - * - * @return void - * - * @access public - * @since 2.0 - */ - public function initialize_settings() { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* skip if option is already set */ - if ( isset( $option['id'] ) && get_option( $option['id'], false ) ) { - return false; - } - - $defaults = array(); - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* loop through page settings */ - foreach( (array) $this->get_the_settings( $page ) as $setting ) { - - if ( isset( $setting['std'] ) ) { - - $defaults[$setting['id']] = ot_validate_setting( $setting['std'], $setting['type'], $setting['id'] ); - - } - - } - - } - - update_option( $option['id'], $defaults ); - - } - - return false; - } - - /** - * Sanitize callback for register_setting() - * - * @return string - * - * @access public - * @since 2.0 - */ - public function sanitize_callback( $input ) { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* loop through page settings */ - foreach( (array) $this->get_the_settings( $page ) as $setting ) { - - /* verify setting has a type & value */ - if ( isset( $setting['type'] ) && isset( $input[$setting['id']] ) ) { - - /* get the defaults */ - $current_settings = get_option( ot_settings_id() ); - $current_options = get_option( $option['id'] ); - - /* validate setting */ - if ( is_array( $input[$setting['id']] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) { - - /* required title setting */ - $required_setting = array( - array( - 'id' => 'title', - 'label' => __( 'Title', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'text', - 'rows' => '', - 'class' => 'option-tree-setting-title', - 'post_type' => '', - 'choices' => array() - ) - ); - - /* get the settings array */ - $settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array(); - - /* settings are empty for some odd ass reason get the defaults */ - if ( empty( $settings ) ) { - $settings = 'slider' == $setting['type'] ? - ot_slider_settings( $setting['id'] ) : - ot_list_item_settings( $setting['id'] ); - } - - /* merge the two settings array */ - $settings = array_merge( $required_setting, $settings ); - - /* create an empty WPML id array */ - $wpml_ids = array(); - - foreach( $input[$setting['id']] as $k => $setting_array ) { - - foreach( $settings as $sub_setting ) { - - /* setup the WPML ID */ - $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k; - - /* add id to array */ - $wpml_ids[] = $wpml_id; - - /* verify sub setting has a type & value */ - if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) { - - /* validate setting */ - $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id ); - - } - - } - - } - - } else if ( is_array( $input[$setting['id']] ) && $setting['type'] == 'social-links' ) { - - /* get the settings array */ - $settings = isset( $_POST[$setting['id'] . '_settings_array'] ) ? unserialize( ot_decode( $_POST[$setting['id'] . '_settings_array'] ) ) : array(); - - /* settings are empty get the defaults */ - if ( empty( $settings ) ) { - $settings = ot_social_links_settings( $setting['id'] ); - } - - /* create an empty WPML id array */ - $wpml_ids = array(); - - foreach( $input[$setting['id']] as $k => $setting_array ) { - - foreach( $settings as $sub_setting ) { - - /* setup the WPML ID */ - $wpml_id = $setting['id'] . '_' . $sub_setting['id'] . '_' . $k; - - /* add id to array */ - $wpml_ids[] = $wpml_id; - - /* verify sub setting has a type & value */ - if ( isset( $sub_setting['type'] ) && isset( $input[$setting['id']][$k][$sub_setting['id']] ) ) { - - /* validate setting */ - $input[$setting['id']][$k][$sub_setting['id']] = ot_validate_setting( $input[$setting['id']][$k][$sub_setting['id']], $sub_setting['type'], $sub_setting['id'], $wpml_id ); - - } - - } - - } - - } else { - - $input[$setting['id']] = ot_validate_setting( $input[$setting['id']], $setting['type'], $setting['id'], $setting['id'] ); - - } - - } - - /* unregister WPML strings that were deleted from lists and sliders */ - if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && in_array( $setting['type'], array( 'list-item', 'slider' ) ) ) { - - if ( ! isset( $wpml_ids ) ) - $wpml_ids = array(); - - foreach( $current_settings['settings'] as $check_setting ) { - - if ( $setting['id'] == $check_setting['id'] && ! empty( $current_options[$setting['id']] ) ) { - - foreach( $current_options[$setting['id']] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - $id = $setting['id'] . '_' . $ckey . '_' . $key; - - if ( ! in_array( $id, $wpml_ids ) ) { - - ot_wpml_unregister_string( $id ); - - } - - } - - } - - } - - } - - } - - /* unregister WPML strings that were deleted from social links */ - if ( isset( $current_settings['settings'] ) && isset( $setting['type'] ) && $setting['type'] == 'social-links' ) { - - if ( ! isset( $wpml_ids ) ) - $wpml_ids = array(); - - foreach( $current_settings['settings'] as $check_setting ) { - - if ( $setting['id'] == $check_setting['id'] && ! empty( $current_options[$setting['id']] ) ) { - - foreach( $current_options[$setting['id']] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - $id = $setting['id'] . '_' . $ckey . '_' . $key; - - if ( ! in_array( $id, $wpml_ids ) ) { - - ot_wpml_unregister_string( $id ); - - } - - } - - } - - } - - } - - } - - } - - } - - } - - return $input; - - } - - /** - * Helper function to get the pages array for an option - * - * @param array Option array - * @return mixed - * - * @access public - * @since 2.0 - */ - public function get_pages( $option = array() ) { - - if ( empty( $option ) ) - return false; - - /* check for pages */ - if ( isset( $option['pages'] ) && ! empty( $option['pages'] ) ) { - - /* return pages array */ - return $option['pages']; - - } - - return false; - } - - /** - * Helper function to get the sections array for a page - * - * @param array Page array - * @return mixed - * - * @access public - * @since 2.0 - */ - public function get_sections( $page = array() ) { - - if ( empty( $page ) ) - return false; - - /* check for sections */ - if ( isset( $page['sections'] ) && ! empty( $page['sections'] ) ) { - - /* return sections array */ - return $page['sections']; - - } - - return false; - } - - /** - * Helper function to get the settings array for a page - * - * @param array Page array - * @return mixed - * - * @access public - * @since 2.0 - */ - public function get_the_settings( $page = array() ) { - - if ( empty( $page ) ) - return false; - - /* check for settings */ - if ( isset( $page['settings'] ) && ! empty( $page['settings'] ) ) { - - /* return settings array */ - return $page['settings']; - - } - - return false; - } - - /** - * Prints out all settings sections added to a particular settings page - * - * @global $wp_settings_sections Storage array of all settings sections added to admin pages - * @global $wp_settings_fields Storage array of settings fields and info about their pages/sections - * - * @param string The slug name of the page whos settings sections you want to output - * @return string - * - * @access public - * @since 2.0 - */ - public function do_settings_sections( $page ) { - global $wp_settings_sections, $wp_settings_fields; - - if ( ! isset( $wp_settings_sections ) || ! isset( $wp_settings_sections[$page] ) ) { - return false; - } - - foreach ( (array) $wp_settings_sections[$page] as $section ) { - - if ( ! isset( $section['id'] ) ) - continue; - - $section_id = $section['id']; - - echo '
        '; - - call_user_func( $section['callback'], $section ); - - if ( ! isset( $wp_settings_fields ) || ! isset( $wp_settings_fields[$page] ) || ! isset( $wp_settings_fields[$page][$section_id] ) ) - continue; - - echo '
        '; - - /** - * Hook to insert arbitrary markup before the `do_settings_fields` method. - * - * @since 2.6.0 - * - * @param string $page The page slug. - * @param string $section_id The section ID. - */ - do_action( 'ot_do_settings_fields_before', $page, $section_id ); - - $this->do_settings_fields( $page, $section_id ); - - /** - * Hook to insert arbitrary markup after the `do_settings_fields` method. - * - * @since 2.6.0 - * - * @param string $page The page slug. - * @param string $section_id The section ID. - */ - do_action( 'ot_do_settings_fields_after', $page, $section_id ); - - echo '
        '; - - echo '
        '; - - } - - } - - /** - * Print out the settings fields for a particular settings section - * - * @global $wp_settings_fields Storage array of settings fields and their pages/sections - * - * @param string $page Slug title of the admin page who's settings fields you want to show. - * @param string $section Slug title of the settings section who's fields you want to show. - * @return string - * - * @access public - * @since 2.0 - */ - public function do_settings_fields( $page, $section ) { - global $wp_settings_fields; - - if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) - return; - - foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { - - $conditions = ''; - - if ( isset( $field['args']['condition'] ) && ! empty( $field['args']['condition'] ) ) { - - $conditions = ' data-condition="' . $field['args']['condition'] . '"'; - $conditions.= isset( $field['args']['operator'] ) && in_array( $field['args']['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['args']['operator'] . '"' : ''; - - } - - // Build the setting CSS class - if ( isset( $field['args']['class'] ) && ! empty( $field['args']['class'] ) ) { - - $classes = explode( ' ', $field['args']['class'] ); - - foreach( $classes as $key => $value ) { - - $classes[$key] = $value . '-wrap'; - - } - - $class = 'format-settings ' . implode( ' ', $classes ); - - } else { - - $class = 'format-settings'; - - } - - echo '
        '; - - echo '
        '; - - if ( $field['args']['type'] != 'textblock' && ! empty( $field['title'] ) ) { - - echo '
        '; - - echo '

        ' . $field['title'] . '

        '; - - echo '
        '; - - } - - call_user_func( $field['callback'], $field['args'] ); - - echo '
        '; - - echo '
        '; - - } - - } - - /** - * Resets page options before the screen is displayed - * - * @return void - * - * @access public - * @since 2.0 - */ - public function reset_options() { - - /* check for reset action */ - if ( isset( $_POST['option_tree_reset_nonce'] ) && wp_verify_nonce( $_POST['option_tree_reset_nonce'], 'option_tree_reset_form' ) ) { - - /* loop through options */ - foreach( (array) $this->options as $option ) { - - /* loop through pages */ - foreach( (array) $this->get_pages( $option ) as $page ) { - - /* verify page */ - if ( isset( $_GET['page'] ) && $_GET['page'] == $page['menu_slug'] ) { - - /* reset options */ - delete_option( $option['id'] ); - - } - - } - - } - - } - - return false; - - } - - } - -} - -/** - * This method instantiates the settings class & builds the UI. - * - * @uses OT_Settings() - * - * @param array Array of arguments to create settings - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_register_settings' ) ) { - - function ot_register_settings( $args ) { - if ( ! $args ) - return; - - $ot_settings = new OT_Settings( $args ); - } - -} - -/* End of file ot-settings-api.php */ -/* Location: ./includes/ot-settings-api.php */ \ No newline at end of file diff --git a/ot-loader.php b/ot-loader.php index 702efe4..356083b 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -270,7 +270,7 @@ private function admin_includes() { 'ot-functions-admin', 'ot-functions-option-types', 'ot-functions-compat', - 'ot-settings-api', + 'class-ot-settings', ); // Include the meta box api. From 91faca32c565b542a37594d85ee4b3a7adc45084 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 06:32:25 -0800 Subject: [PATCH 21/67] Fix typo --- includes/class-ot-settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index eb5fa37..8513a04 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -525,7 +525,7 @@ public function display_setting( $args = array() ) { */ public function initialize_settings() { - // :oop through options. + // Loop through options. foreach ( (array) $this->options as $option ) { // Skip if option is already set. From 5a38c20dbedcdfa16a1bde09206d34a25d464565 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 21:12:17 -0800 Subject: [PATCH 22/67] Fix phpcs issues --- includes/ot-functions-option-types.php | 5955 ++++++++++++------------ 1 file changed, 2943 insertions(+), 3012 deletions(-) diff --git a/includes/ot-functions-option-types.php b/includes/ot-functions-option-types.php index 1590f7e..08fa1e5 100755 --- a/includes/ot-functions-option-types.php +++ b/includes/ot-functions-option-types.php @@ -1,3233 +1,3164 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Builds the HTML for each of the available option types by calling those - * function with call_user_func and passing the arguments to the second param. - * - * All fields are required! - * - * @param array $args The array of arguments are as follows: - * @param string $type Type of option. - * @param string $field_id The field ID. - * @param string $field_name The field Name. - * @param mixed $field_value The field value is a string or an array of values. - * @param string $field_desc The field description. - * @param string $field_std The standard value. - * @param string $field_class Extra CSS classes. - * @param array $field_choices The array of option choices. - * @param array $field_settings The array of settings for a list item. - * @return string - * - * @access public - * @since 2.0 - */ +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); +} + if ( ! function_exists( 'ot_display_by_type' ) ) { - function ot_display_by_type( $args = array() ) { - - /* allow filters to be executed on the array */ - $args = apply_filters( 'ot_display_by_type', $args ); - - /* build the function name */ - $function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] ); - - /* call the function & pass in arguments array */ - if ( function_exists( $function_name_by_type ) ) { - call_user_func( $function_name_by_type, $args ); - } else { - echo '

        ' . __( 'Sorry, this function does not exist', 'option-tree' ) . '

        '; - } - - } - + /** + * Builds the HTML for each of the available option types by calling those + * function with call_user_func and passing the arguments to the second param. + * + * All fields are required! + * + * @param array $args The array of arguments are as follows. + * @var string $type Type of option. + * @var string $field_id The field ID. + * @var string $field_name The field Name. + * @var mixed $field_value The field value is a string or an array of values. + * @var string $field_desc The field description. + * @var string $field_std The standard value. + * @var string $field_class Extra CSS classes. + * @var array $field_choices The array of option choices. + * @var array $field_settings The array of settings for a list item. + * + * @access public + * @since 2.0 + */ + function ot_display_by_type( $args = array() ) { + + // Allow filters to be executed on the array. + $args = apply_filters( 'ot_display_by_type', $args ); + + // Build the function name. + $function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] ); + + // Call the function & pass in arguments array. + if ( function_exists( $function_name_by_type ) ) { + call_user_func( $function_name_by_type, $args ); + } else { + echo '

        ' . esc_html__( 'Sorry, this function does not exist', 'option-tree' ) . '

        '; + } + + } } -/** - * Background option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_background' ) ) { - - function ot_type_background( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* If an attachment ID is stored here fetch its URL and replace the value */ - if ( isset( $field_value['background-image'] ) && wp_attachment_is_image( $field_value['background-image'] ) ) { - - $attachment_data = wp_get_attachment_image_src( $field_value['background-image'], 'original' ); - - /* check for attachment data */ - if ( $attachment_data ) { - - $field_src = $attachment_data[0]; - - } - - } - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* allow fields to be filtered */ - $ot_recognized_background_fields = apply_filters( 'ot_recognized_background_fields', array( - 'background-color', - 'background-repeat', - 'background-attachment', - 'background-position', - 'background-size', - 'background-image' - ), $field_id ); - - echo '
        '; - - /* build background color */ - if ( in_array( 'background-color', $ot_recognized_background_fields ) ) { - - echo '
        '; - - /* colorpicker JS */ - echo ''; - - /* set background color */ - $background_color = isset( $field_value['background-color'] ) ? esc_attr( $field_value['background-color'] ) : ''; - - /* input */ - echo ''; - - echo '
        '; - - } - - /* build background repeat */ - if ( in_array( 'background-repeat', $ot_recognized_background_fields ) ) { - - $background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : ''; - - echo ''; - - } - - /* build background attachment */ - if ( in_array( 'background-attachment', $ot_recognized_background_fields ) ) { - - $background_attachment = isset( $field_value['background-attachment'] ) ? esc_attr( $field_value['background-attachment'] ) : ''; - - echo ''; - - } - - /* build background position */ - if ( in_array( 'background-position', $ot_recognized_background_fields ) ) { - - $background_position = isset( $field_value['background-position'] ) ? esc_attr( $field_value['background-position'] ) : ''; - - echo ''; - - } - - /* Build background size */ - if ( in_array( 'background-size', $ot_recognized_background_fields ) ) { - - /** - * Use this filter to create a select instead of an text input. - * Be sure to return the array in the correct format. Add an empty - * value to the first choice so the user can leave it blank. - * - array( - array( - 'label' => 'background-size', - 'value' => '' - ), - array( - 'label' => 'cover', - 'value' => 'cover' - ), - array( - 'label' => 'contain', - 'value' => 'contain' - ) - ) - * - */ - $choices = apply_filters( 'ot_type_background_size_choices', '', $field_id ); - - if ( is_array( $choices ) && ! empty( $choices ) ) { - - /* build select */ - echo ''; - - } else { - - echo ''; - - } - - } - - echo '
        '; - - /* build background image */ - if ( in_array( 'background-image', $ot_recognized_background_fields ) ) { - - echo '
        '; - - /* input */ - echo ''; - - /* add media button */ - echo '' . __( 'Add Media', 'option-tree' ) . ''; - - echo '
        '; - - /* media */ - if ( isset( $field_value['background-image'] ) && $field_value['background-image'] !== '' ) { - - /* replace image src */ - if ( isset( $field_src ) ) - $field_value['background-image'] = $field_src; - - echo '
        '; - - if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) - echo '
        '; - - echo '' . __( 'Remove Media', 'option-tree' ) . ''; - - echo '
        '; - - } - - } - - echo '
        '; - - echo '
        '; - - } - + + /** + * Background option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_background( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // If an attachment ID is stored here fetch its URL and replace the value. + if ( isset( $field_value['background-image'] ) && wp_attachment_is_image( $field_value['background-image'] ) ) { + + $attachment_data = wp_get_attachment_image_src( $field_value['background-image'], 'original' ); + + /* check for attachment data */ + if ( $attachment_data ) { + + $field_src = $attachment_data[0]; + + } + } + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Allow fields to be filtered. + $ot_recognized_background_fields = apply_filters( + 'ot_recognized_background_fields', + array( + 'background-color', + 'background-repeat', + 'background-attachment', + 'background-position', + 'background-size', + 'background-image', + ), + $field_id + ); + + echo '
        '; + + // Build background color. + if ( in_array( 'background-color', $ot_recognized_background_fields, true ) ) { + + echo '
        '; + + echo ''; + + $background_color = isset( $field_value['background-color'] ) ? $field_value['background-color'] : ''; + + echo ''; + + echo '
        '; + } + + // Build background repeat. + if ( in_array( 'background-repeat', $ot_recognized_background_fields, true ) ) { + + $background_repeat = isset( $field_value['background-repeat'] ) ? esc_attr( $field_value['background-repeat'] ) : ''; + + echo ''; + } + + // Build background attachment. + if ( in_array( 'background-attachment', $ot_recognized_background_fields, true ) ) { + + $background_attachment = isset( $field_value['background-attachment'] ) ? $field_value['background-attachment'] : ''; + + echo ''; + } + + // Build background position. + if ( in_array( 'background-position', $ot_recognized_background_fields, true ) ) { + + $background_position = isset( $field_value['background-position'] ) ? $field_value['background-position'] : ''; + + echo ''; + } + + // Build background size . + if ( in_array( 'background-size', $ot_recognized_background_fields, true ) ) { + + /** + * Use this filter to create a select instead of an text input. + * Be sure to return the array in the correct format. Add an empty + * value to the first choice so the user can leave it blank. + * + * Example: array( + * array( + * 'label' => 'background-size', + * 'value' => '' + * ), + * array( + * 'label' => 'cover', + * 'value' => 'cover' + * ), + * array( + * 'label' => 'contain', + * 'value' => 'contain' + * ) + * ) + */ + $choices = apply_filters( 'ot_type_background_size_choices', '', $field_id ); + + if ( is_array( $choices ) && ! empty( $choices ) ) { + + // Build select. + echo ''; + } else { + + echo ''; + } + } + + echo '
        '; + + // Build background image. + if ( in_array( 'background-image', $ot_recognized_background_fields, true ) ) { + + echo '
        '; + + // Input. + echo ''; + + // Add media button. + echo '' . esc_html__( 'Add Media', 'option-tree' ) . ''; + + echo '
        '; + + // Media. + if ( isset( $field_value['background-image'] ) && '' !== $field_value['background-image'] ) { + + /* replace image src */ + if ( isset( $field_src ) ) { + $field_value['background-image'] = $field_src; + } + + echo '
        '; + + if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value['background-image'] ) ) { + echo '
        '; + } + + echo '' . esc_html__( 'Remove Media', 'option-tree' ) . ''; + + echo '
        '; + } + } + + echo '
        '; + + echo '
        '; + } } -/** - * Border Option Type - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The markup. - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_border' ) ) { - function ot_type_border( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* allow fields to be filtered */ - $ot_recognized_border_fields = apply_filters( 'ot_recognized_border_fields', array( - 'width', - 'unit', - 'style', - 'color' - ), $field_id ); - - /* build border width */ - if ( in_array( 'width', $ot_recognized_border_fields ) ) { - - $width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : ''; - - echo '
        '; - - } - - /* build unit dropdown */ - if ( in_array( 'unit', $ot_recognized_border_fields ) ) { - - echo '
        '; - - echo ''; - - echo '
        '; - - } - - /* build style dropdown */ - if ( in_array( 'style', $ot_recognized_border_fields ) ) { - - echo '
        '; - - echo ''; - - echo '
        '; - - } - - /* build color */ - if ( in_array( 'color', $ot_recognized_border_fields ) ) { - - echo '
        '; - - /* colorpicker JS */ - echo ''; - - /* set color */ - $color = isset( $field_value['color'] ) ? esc_attr( $field_value['color'] ) : ''; - - /* input */ - echo ''; - - echo '
        '; - - } - - echo '
        '; - - echo '
        '; - - } + /** + * Border Option Type + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_border( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Allow fields to be filtered. + $ot_recognized_border_fields = apply_filters( + 'ot_recognized_border_fields', + array( + 'width', + 'unit', + 'style', + 'color', + ), + $field_id + ); + + // Build border width. + if ( in_array( 'width', $ot_recognized_border_fields, true ) ) { + + $width = isset( $field_value['width'] ) ? $field_value['width'] : ''; + + echo '
        '; + } + + // Build unit dropdown. + if ( in_array( 'unit', $ot_recognized_border_fields, true ) ) { + + echo '
        '; + + echo ''; + + echo '
        '; + } + + // Build style dropdown. + if ( in_array( 'style', $ot_recognized_border_fields, true ) ) { + + echo '
        '; + + echo ''; + + echo '
        '; + } + + // Build color. + if ( in_array( 'color', $ot_recognized_border_fields, true ) ) { + + echo '
        '; + + echo ''; + + $color = isset( $field_value['color'] ) ? $field_value['color'] : ''; + + echo ''; + + echo '
        '; + } + + echo '
        '; + + echo '
        '; + } } -/** - * Box Shadow Option Type - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The markup. - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_box_shadow' ) ) { - function ot_type_box_shadow( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* allow fields to be filtered */ - $ot_recognized_box_shadow_fields = apply_filters( 'ot_recognized_box_shadow_fields', array( - 'inset', - 'offset-x', - 'offset-y', - 'blur-radius', - 'spread-radius', - 'color' - ), $field_id ); - - /* build inset */ - if ( in_array( 'inset', $ot_recognized_box_shadow_fields ) ) { - - echo '

        '; - echo ''; - echo ''; - echo '

        '; - - } - - /* build horizontal offset */ - if ( in_array( 'offset-x', $ot_recognized_box_shadow_fields ) ) { - - $offset_x = isset( $field_value['offset-x'] ) ? esc_attr( $field_value['offset-x'] ) : ''; - - echo '
        '; - - } - - /* build vertical offset */ - if ( in_array( 'offset-y', $ot_recognized_box_shadow_fields ) ) { - - $offset_y = isset( $field_value['offset-y'] ) ? esc_attr( $field_value['offset-y'] ) : ''; - - echo '
        '; - - } - - /* build blur-radius radius */ - if ( in_array( 'blur-radius', $ot_recognized_box_shadow_fields ) ) { - - $blur_radius = isset( $field_value['blur-radius'] ) ? esc_attr( $field_value['blur-radius'] ) : ''; - - echo '
        '; - - } - - /* build spread-radius radius */ - if ( in_array( 'spread-radius', $ot_recognized_box_shadow_fields ) ) { - - $spread_radius = isset( $field_value['spread-radius'] ) ? esc_attr( $field_value['spread-radius'] ) : ''; - - echo '
        '; - - } - - /* build color */ - if ( in_array( 'color', $ot_recognized_box_shadow_fields ) ) { - - echo '
        '; - - /* colorpicker JS */ - echo ''; - - /* set color */ - $color = isset( $field_value['color'] ) ? esc_attr( $field_value['color'] ) : ''; - - /* input */ - echo ''; - - echo '
        '; - - } - - echo '
        '; - - echo '
        '; - - } + /** + * Box Shadow Option Type + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_box_shadow( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Allow fields to be filtered. + $ot_recognized_box_shadow_fields = apply_filters( + 'ot_recognized_box_shadow_fields', + array( + 'inset', + 'offset-x', + 'offset-y', + 'blur-radius', + 'spread-radius', + 'color', + ), + $field_id + ); + + // Build inset. + if ( in_array( 'inset', $ot_recognized_box_shadow_fields, true ) ) { + + echo '

        '; + echo ''; + echo ''; + echo '

        '; + } + + // Build horizontal offset. + if ( in_array( 'offset-x', $ot_recognized_box_shadow_fields, true ) ) { + + $offset_x = isset( $field_value['offset-x'] ) ? esc_attr( $field_value['offset-x'] ) : ''; + + echo '
        '; + } + + // Build vertical offset. + if ( in_array( 'offset-y', $ot_recognized_box_shadow_fields, true ) ) { + + $offset_y = isset( $field_value['offset-y'] ) ? esc_attr( $field_value['offset-y'] ) : ''; + + echo '
        '; + } + + // Build blur-radius radius. + if ( in_array( 'blur-radius', $ot_recognized_box_shadow_fields, true ) ) { + + $blur_radius = isset( $field_value['blur-radius'] ) ? esc_attr( $field_value['blur-radius'] ) : ''; + + echo '
        '; + } + + // Build spread-radius radius. + if ( in_array( 'spread-radius', $ot_recognized_box_shadow_fields, true ) ) { + + $spread_radius = isset( $field_value['spread-radius'] ) ? esc_attr( $field_value['spread-radius'] ) : ''; + + echo '
        '; + } + + // Build color. + if ( in_array( 'color', $ot_recognized_box_shadow_fields, true ) ) { + + echo '
        '; + echo ''; + + $color = isset( $field_value['color'] ) ? $field_value['color'] : ''; + + echo ''; + + echo '
        '; + } + + echo '
        '; + + echo '
        '; + } } -/** - * Category Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_category_checkbox' ) ) { - - function ot_type_category_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* get category array */ - $categories = get_categories( apply_filters( 'ot_type_category_checkbox_query', array( 'hide_empty' => false ), $field_id ) ); - - /* build categories */ - if ( ! empty( $categories ) ) { - foreach ( $categories as $category ) { - echo '

        '; - echo 'term_id] ) ? checked( $field_value[$category->term_id], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

        '; - } - } else { - echo '

        ' . __( 'No Categories Found', 'option-tree' ) . '

        '; - } - - echo '
        '; - - echo '
        '; - - } - + + /** + * Category Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_category_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args );// phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Get category array. + $categories = get_categories( apply_filters( 'ot_type_category_checkbox_query', array( 'hide_empty' => false ), $field_id ) ); + + // Build categories. + if ( ! empty( $categories ) ) { + foreach ( $categories as $category ) { + echo '

        '; + echo 'term_id ] ) ? checked( $field_value[ $category->term_id ], $category->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

        '; + } + } else { + echo '

        ' . esc_html__( 'No Categories Found', 'option-tree' ) . '

        '; + } + + echo '
        '; + + echo '
        '; + } } -/** - * Category Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_category_select' ) ) { - - function ot_type_category_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build category */ - echo ''; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Category Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_category_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build category. + echo ''; + + echo '
        '; + + echo '
        '; + } } -/** - * Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_checkbox' ) ) { - - function ot_type_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build checkbox */ - foreach ( (array) $field_choices as $key => $choice ) { - if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) { - echo '

        '; - echo ''; - echo ''; - echo '

        '; - } - } - - echo '
        '; - - echo '
        '; - - } - + + /** + * Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build checkbox. + foreach ( (array) $field_choices as $key => $choice ) { + if ( isset( $choice['value'] ) && isset( $choice['label'] ) ) { + echo '

        '; + echo ''; + echo ''; + echo '

        '; + } + } + + echo '
        '; + + echo '
        '; + } } -/** - * Colorpicker option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - * @updated 2.2.0 - */ if ( ! function_exists( 'ot_type_colorpicker' ) ) { - - function ot_type_colorpicker( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build colorpicker */ - echo '
        '; - - /* colorpicker JS */ - echo ''; - - /* set the default color */ - $std = $field_std ? 'data-default-color="' . $field_std . '"' : ''; - - /* input */ - echo ''; - - echo '
        '; - - echo '
        '; - - echo '
        '; - - } - -} -/** - * Colorpicker Opacity option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) { + /** + * Colorpicker option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + * @updated 2.2.0 + */ + function ot_type_colorpicker( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; - function ot_type_colorpicker_opacity( $args = array() ) { + // Build colorpicker. + echo '
        '; - $args['field_class'] = isset( $args['field_class'] ) ? $args['field_class'] . ' ot-colorpicker-opacity' : 'ot-colorpicker-opacity'; - ot_type_colorpicker( $args ); + // Colorpicker JS. + echo ''; - } + // Input. + echo ''; + echo '
        '; + + echo '
        '; + + echo '
        '; + } +} + +if ( ! function_exists( 'ot_type_colorpicker_opacity' ) ) { + + /** + * Colorpicker Opacity option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_colorpicker_opacity( $args = array() ) { + + $args['field_class'] = isset( $args['field_class'] ) ? $args['field_class'] . ' ot-colorpicker-opacity' : 'ot-colorpicker-opacity'; + ot_type_colorpicker( $args ); + } } -/** - * CSS option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_css' ) ) { - - function ot_type_css( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build textarea for CSS */ - echo ''; - - /* build pre to convert it into ace editor later */ - echo '
        ' . esc_textarea( $field_value ) . '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * CSS option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_css( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build textarea for CSS. + echo ''; + + // Build pre to convert it into ace editor later. + echo '
        ' . esc_textarea( $field_value ) . '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Custom Post Type Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_custom_post_type_checkbox' ) ) { - - function ot_type_custom_post_type_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* setup the post types */ - $post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' ); - - /* query posts array */ - $my_posts = get_posts( apply_filters( 'ot_type_custom_post_type_checkbox_query', array( 'post_type' => $post_type, 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); - - /* has posts */ - if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { - foreach( $my_posts as $my_post ) { - $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; - echo '

        '; - echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

        '; - } - } else { - echo '

        ' . __( 'No Posts Found', 'option-tree' ) . '

        '; - } - - echo '
        '; - - echo '
        '; - - } - + + /** + * Custom Post Type Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_custom_post_type_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Setup the post types. + $post_type = isset( $field_post_type ) ? explode( ',', $field_post_type ) : array( 'post' ); + + // Query posts array. + $my_posts = get_posts( + apply_filters( + 'ot_type_custom_post_type_checkbox_query', + array( + 'post_type' => $post_type, + 'posts_per_page' => -1, + 'orderby' => 'title', + 'order' => 'ASC', + 'post_status' => 'any', + ), + $field_id + ) + ); + + // Has posts. + if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { + foreach ( $my_posts as $my_post ) { + $post_title = ! emoty( $my_post->post_title ) ? $my_post->post_title : 'Untitled'; + echo '

        '; + echo 'ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

        '; + } + } else { + echo '

        ' . esc_html__( 'No Posts Found', 'option-tree' ) . '

        '; + } + + echo '
        '; + + echo '
        '; + } } -/** - * Custom Post Type Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_custom_post_type_select' ) ) { - - function ot_type_custom_post_type_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build category */ - echo ''; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Custom Post Type Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_custom_post_type_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build category. + echo ''; + + echo '
        '; + + echo '
        '; + } } -/** - * Date Picker option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.3 - */ if ( ! function_exists( 'ot_type_date_picker' ) ) { - - function ot_type_date_picker( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* filter date format */ - $date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id ); - - /** - * Filter the addition of the readonly attribute. - * - * @since 2.5.0 - * - * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. - * @param string $field_id The field ID. - */ - $is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id ); - - /* format setting outer wrapper */ - echo '
        '; - - /* date picker JS */ - echo ''; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build date picker */ - echo ''; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Date Picker option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.3 + */ + function ot_type_date_picker( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Filter date format. + $date_format = apply_filters( 'ot_type_date_picker_date_format', 'yy-mm-dd', $field_id ); + + /** + * Filter the addition of the readonly attribute. + * + * @since 2.5.0 + * + * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. + * @param string $field_id The field ID. + */ + $is_readonly = apply_filters( 'ot_type_date_picker_readonly', false, $field_id ); + + // Format setting outer wrapper. + echo '
        '; + + // Date picker JS. + echo ''; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build date picker. + echo ''; + + echo '
        '; + + echo '
        '; + } } -/** - * Date Time Picker option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.3 - */ if ( ! function_exists( 'ot_type_date_time_picker' ) ) { - - function ot_type_date_time_picker( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* filter date format */ - $date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id ); - - /** - * Filter the addition of the readonly attribute. - * - * @since 2.5.0 - * - * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. - * @param string $field_id The field ID. - */ - $is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id ); - - /* format setting outer wrapper */ - echo '
        '; - - /* date time picker JS */ - echo ''; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build date time picker */ - echo ''; - - echo '
        '; - - echo '
        '; - - } - + + /** + * Date Time Picker option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.3 + */ + function ot_type_date_time_picker( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Filter date format. + $date_format = apply_filters( 'ot_type_date_time_picker_date_format', 'yy-mm-dd', $field_id ); + + /** + * Filter the addition of the readonly attribute. + * + * @since 2.5.0 + * + * @param bool $is_readonly Whether to add the 'readonly' attribute. Default 'false'. + * @param string $field_id The field ID. + */ + $is_readonly = apply_filters( 'ot_type_date_time_picker_readonly', false, $field_id ); + + // Format setting outer wrapper. + echo '
        '; + + // Date time picker JS. + echo ''; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build date time picker. + echo ''; + + echo '
        '; + + echo '
        '; + } } -/** - * Dimension Option Type - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The markup. - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_dimension' ) ) { - function ot_type_dimension( $args = array() ) { + /** + * Dimension Option Type + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_dimension( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore - /* turns arguments array into variables */ - extract( $args ); + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; - /* verify a description */ - $has_desc = $field_desc ? true : false; + // Format setting outer wrapper. + echo '
        '; - /* format setting outer wrapper */ - echo '
        '; + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; + // Format setting inner wrapper. + echo '
        '; - /* format setting inner wrapper */ - echo '
        '; + // Allow fields to be filtered. + $ot_recognized_dimension_fields = apply_filters( + 'ot_recognized_dimension_fields', + array( + 'width', + 'height', + 'unit', + ), + $field_id + ); - /* allow fields to be filtered */ - $ot_recognized_dimension_fields = apply_filters( 'ot_recognized_dimension_fields', array( - 'width', - 'height', - 'unit' - ), $field_id ); + // Build width dimension. + if ( in_array( 'width', $ot_recognized_dimension_fields, true ) ) { - /* build width dimension */ - if ( in_array( 'width', $ot_recognized_dimension_fields ) ) { + $width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : ''; + echo '
        '; + } - $width = isset( $field_value['width'] ) ? esc_attr( $field_value['width'] ) : ''; + // Build height dimension. + if ( in_array( 'height', $ot_recognized_dimension_fields, true ) ) { - echo '
        '; + $height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : ''; + echo '
        '; + } - } + // Build unit dropdown. + if ( in_array( 'unit', $ot_recognized_dimension_fields, true ) ) { - /* build height dimension */ - if ( in_array( 'height', $ot_recognized_dimension_fields ) ) { + echo '
        '; - $height = isset( $field_value['height'] ) ? esc_attr( $field_value['height'] ) : ''; + echo '
        '; + echo ''; - } - - /* build unit dropdown */ - if ( in_array( 'unit', $ot_recognized_dimension_fields ) ) { - - echo '
        '; - - echo ''; - - echo '
        '; - - } - - echo '
        '; + foreach ( ot_recognized_dimension_unit_types( $field_id ) as $unit ) { + echo ''; + } - echo '
        '; + echo ''; - } + echo '
        '; + } + echo '
        '; + + echo '
        '; + } } -/** - * Gallery option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The gallery metabox markup. - * - * @access public - * @since 2.2.0 - */ if ( ! function_exists( 'ot_type_gallery' ) ) { - function ot_type_gallery( $args = array() ) { - - // Turns arguments array into variables - extract( $args ); - - // Verify a description - $has_desc = $field_desc ? true : false; - - // Format setting outer wrapper - echo ''; - - } + /** + * Gallery option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.2.0 + */ + function ot_type_gallery( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo ''; + } } -/** - * Google Fonts option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_google_fonts' ) ) { - - function ot_type_google_fonts( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* allow fields to be filtered */ - $ot_recognized_google_fonts_fields = apply_filters( 'ot_recognized_google_font_fields', array( - 'variants', - 'subsets' - ), $field_id ); - - // Set a default to show at least one item. - if ( ! is_array( $field_value ) || empty( $field_value ) ) { - $field_value = array( array( - 'family' => '', - 'variants' => array(), - 'subsets' => array() - ) ); - } - - foreach( $field_value as $key => $value ) { - - echo '
        '; - - /* build font family */ - $family = isset( $value['family'] ) ? $value['family'] : ''; - echo '
        '; - echo '' . __( 'Remove Google Font', 'option-tree' ) . ''; - echo ''; - echo '
        '; - - /* build font variants */ - if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) { - $variants = isset( $value['variants'] ) ? $value['variants'] : array(); - echo '
        '; - foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) { - echo '

        '; - echo ''; - echo ''; - echo '

        '; - } - echo '
        '; - } - - /* build font subsets */ - if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) { - $subsets = isset( $value['subsets'] ) ? $value['subsets'] : array(); - echo '
        '; - foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) { - echo '

        '; - echo ''; - echo ''; - echo '

        '; - } - echo '
        '; - } - - echo '
        '; - - } - - echo '
        '; - - /* build font family */ - echo '
        '; - echo '' . __( 'Remove Google Font', 'option-tree' ) . ''; - echo ''; - echo '
        '; - - /* build font variants */ - if ( in_array( 'variants', $ot_recognized_google_fonts_fields ) ) { - echo '
        '; - echo '
        '; - } - - /* build font subsets */ - if ( in_array( 'subsets', $ot_recognized_google_fonts_fields ) ) { - echo '
        '; - echo '
        '; - } - - echo '
        '; - - echo '' . __( 'Add Google Font', 'option-tree' ) . ''; - - echo '
        '; - - echo '
        '; - - } + /** + * Google Fonts option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_google_fonts( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Allow fields to be filtered. + $ot_recognized_google_fonts_fields = apply_filters( + 'ot_recognized_google_font_fields', + array( + 'variants', + 'subsets', + ), + $field_id + ); + + // Set a default to show at least one item. + if ( ! is_array( $field_value ) || empty( $field_value ) ) { + $field_value = array( + array( + 'family' => '', + 'variants' => array(), + 'subsets' => array(), + ), + ); + } + + foreach ( $field_value as $key => $value ) { + + echo '
        '; + + // Build font family. + $family = isset( $value['family'] ) ? $value['family'] : ''; + echo '
        '; + echo '' . esc_html__( 'Remove Google Font', 'option-tree' ) . ''; + echo ''; + echo '
        '; + + // Build font variants. + if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) { + $variants = isset( $value['variants'] ) ? $value['variants'] : array(); + echo '
        '; + foreach ( ot_recognized_google_font_variants( $field_id, $family ) as $variant_key => $variant ) { + echo '

        '; + echo ''; + echo ''; + echo '

        '; + } + echo '
        '; + } + + // Build font subsets. + if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) { + $subsets = isset( $value['subsets'] ) ? $value['subsets'] : array(); + echo '
        '; + foreach ( ot_recognized_google_font_subsets( $field_id, $family ) as $subset_key => $subset ) { + echo '

        '; + echo ''; + echo ''; + echo '

        '; + } + echo '
        '; + } + + echo '
        '; + } + + echo '
        '; + + /* build font family */ + echo '
        '; + echo '' . esc_html__( 'Remove Google Font', 'option-tree' ) . ''; + echo ''; + echo '
        '; + + // Build font variants. + if ( in_array( 'variants', $ot_recognized_google_fonts_fields, true ) ) { + echo '
        '; + echo '
        '; + } + + // Build font subsets. + if ( in_array( 'subsets', $ot_recognized_google_fonts_fields, true ) ) { + echo '
        '; + echo '
        '; + } + + echo '
        '; + + echo '' . esc_html__( 'Add Google Font', 'option-tree' ) . ''; + + echo '
        '; + + echo '
        '; + } } -/** - * JavaScript option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_javascript' ) ) { - - function ot_type_javascript( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
        '; - - /* description */ - echo $has_desc ? '
        ' . htmlspecialchars_decode( $field_desc ) . '
        ' : ''; - - /* format setting inner wrapper */ - echo '
        '; - - /* build textarea for CSS */ - echo ''; - - /* build pre to convert it into ace editor later */ - echo '
        ' . esc_textarea( $field_value ) . '
        '; - - echo '
        '; - - echo '
        '; - - } - + + /** + * JavaScript option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_javascript( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Build textarea for CSS. + echo ''; + + // Build pre to convert it into ace editor later. + echo '
        ' . esc_textarea( $field_value ) . '
        '; + + echo '
        '; + + echo '
        '; + } } -/** - * Link Color option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The markup. - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_link_color' ) ) { - function ot_type_link_color( $args = array() ) { + /** + * Link Color option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_link_color( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo ''; + } +} + +if ( ! function_exists( 'ot_type_list_item' ) ) { + + /** + * List Item option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_list_item( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Default. + $sortable = true; + + // Check if the list can be sorted. + if ( ! empty( $field_class ) ) { + $classes = explode( ' ', $field_class ); + if ( in_array( 'not-sortable', $classes, true ) ) { + $sortable = false; + str_replace( 'not-sortable', '', $field_class ); + } + } + + // Format setting outer wrapper. + echo '
        '; + + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; + + // Format setting inner wrapper. + echo '
        '; + + // Pass the settings array arround. + echo ''; + + /** + * Settings pages have array wrappers like 'option_tree'. + * So we need that value to create a proper array to save to. + * This is only for NON metabox settings. + */ + if ( ! isset( $get_option ) ) { + $get_option = ''; + } + + // Build list items. + echo '
          '; + + if ( is_array( $field_value ) && ! empty( $field_value ) ) { + + foreach ( $field_value as $key => $list_item ) { + + echo '
        • '; + ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type ); + echo '
        • '; + } + } + + echo '
        '; + + // Button. + echo '' . esc_html__( 'Add New', 'option-tree' ) . ''; + + // Description. + $list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : ''; + echo '
        ' . esc_html( apply_filters( 'ot_list_item_description', $list_desc, $field_id ) ) . '
        '; + + echo '
        '; + + echo '
        '; + } +} + +if ( ! function_exists( 'ot_type_measurement' ) ) { + + /** + * Measurement option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_measurement( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; - /* turns arguments array into variables */ - extract( $args ); + // Format setting outer wrapper. + echo '
        '; - /* verify a description */ - $has_desc = $field_desc ? true : false; + // Description. + echo $has_desc ? '
        ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
        ' : ''; - /* format setting outer wrapper */ - echo ''; +if ( ! function_exists( 'ot_type_numeric_slider' ) ) { - } + /** + * Numeric Slider option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.1 + */ + function ot_type_numeric_slider( $args = array() ) { - } + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore - echo '
        '; + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; - echo '
      '; + $_options = explode( ',', $field_min_max_step ); + $min = isset( $_options[0] ) ? $_options[0] : 0; + $max = isset( $_options[1] ) ? $_options[1] : 100; + $step = isset( $_options[2] ) ? $_options[2] : 1; - } + // Format setting outer wrapper. + echo '
      '; -} + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; -/** - * List Item option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_type_list_item' ) ) { - - function ot_type_list_item( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - // Default - $sortable = true; - - // Check if the list can be sorted - if ( ! empty( $field_class ) ) { - $classes = explode( ' ', $field_class ); - if ( in_array( 'not-sortable', $classes ) ) { - $sortable = false; - str_replace( 'not-sortable', '', $field_class ); - } - } - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* pass the settings array arround */ - echo ''; - - /** - * settings pages have array wrappers like 'option_tree'. - * So we need that value to create a proper array to save to. - * This is only for NON metabox settings. - */ - if ( ! isset( $get_option ) ) - $get_option = ''; - - /* build list items */ - echo '
        '; - - if ( is_array( $field_value ) && ! empty( $field_value ) ) { - - foreach( $field_value as $key => $list_item ) { - - echo '
      • '; - ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type ); - echo '
      • '; - - } - - } - - echo '
      '; - - /* button */ - echo '' . __( 'Add New', 'option-tree' ) . ''; - - /* description */ - $list_desc = $sortable ? __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) : ''; - echo '
      ' . apply_filters( 'ot_list_item_description', $list_desc, $field_id ) . '
      '; - - echo '
      '; - - echo '
      '; - - } - -} + // Format setting inner wrapper. + echo '
      '; -/** - * Measurement option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_type_measurement' ) ) { - - function ot_type_measurement( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - echo '
      '; - - echo ''; - - echo '
      '; - - /* build measurement */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - -} + echo '
      '; -/** - * Numeric Slider option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.1 - */ -if ( ! function_exists( 'ot_type_numeric_slider' ) ) { + echo ''; + + echo ''; - function ot_type_numeric_slider( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - $_options = explode( ',', $field_min_max_step ); - $min = isset( $_options[0] ) ? $_options[0] : 0; - $max = isset( $_options[1] ) ? $_options[1] : 100; - $step = isset( $_options[2] ) ? $_options[2] : 1; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - echo '
      '; - - echo ''; - - echo ''; - - echo '
      '; - - echo '
      '; - - echo '
      '; - - echo '
      '; - } + echo '
      '; + echo '
      '; + + echo '
      '; + + echo '
      '; + } } -/** - * On/Off option type - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array The options arguments - * @return string The gallery metabox markup. - * - * @access public - * @since 2.2.0 - */ if ( ! function_exists( 'ot_type_on_off' ) ) { - function ot_type_on_off( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* Force only two choices, and allowing filtering on the choices value & label */ - $field_choices = array( - array( - /** - * Filter the value of the On button. - * - * @since 2.5.0 - * - * @param string The On button value. Default 'on'. - * @param string $field_id The field ID. - * @param string $filter_id For filtering both on/off value with one function. - */ - 'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ), - /** - * Filter the label of the On button. - * - * @since 2.5.0 - * - * @param string The On button label. Default 'On'. - * @param string $field_id The field ID. - * @param string $filter_id For filtering both on/off label with one function. - */ - 'label' => apply_filters( 'ot_on_off_switch_on_label', __( 'On', 'option-tree' ), $field_id, 'on' ) - ), - array( - /** - * Filter the value of the Off button. - * - * @since 2.5.0 - * - * @param string The Off button value. Default 'off'. - * @param string $field_id The field ID. - * @param string $filter_id For filtering both on/off value with one function. - */ - 'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ), - /** - * Filter the label of the Off button. - * - * @since 2.5.0 - * - * @param string The Off button label. Default 'Off'. - * @param string $field_id The field ID. - * @param string $filter_id For filtering both on/off label with one function. - */ - 'label' => apply_filters( 'ot_on_off_switch_off_label', __( 'Off', 'option-tree' ), $field_id, 'off' ) - ) - ); - - /** - * Filter the width of the On/Off switch. - * - * @since 2.5.0 - * - * @param string The switch width. Default '100px'. - * @param string $field_id The field ID. - */ - $switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id ); - - echo '
      '; - - /* build radio */ - foreach ( (array) $field_choices as $key => $choice ) { - echo ' - + /** + * On/Off option type + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args The options arguments. + * + * @access public + * @since 2.2.0 + */ + function ot_type_on_off( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Force only two choices, and allowing filtering on the choices value & label. + $field_choices = array( + array( + /** + * Filter the value of the On button. + * + * @since 2.5.0 + * + * @param string $value The On button value. Default 'on'. + * @param string $field_id The field ID. + * @param string $filter_id For filtering both on/off value with one function. + */ + 'value' => apply_filters( 'ot_on_off_switch_on_value', 'on', $field_id, 'on' ), + /** + * Filter the label of the On button. + * + * @since 2.5.0 + * + * @param string $label The On button label. Default 'On'. + * @param string $field_id The field ID. + * @param string $filter_id For filtering both on/off label with one function. + */ + 'label' => apply_filters( 'ot_on_off_switch_on_label', esc_html__( 'On', 'option-tree' ), $field_id, 'on' ), + ), + array( + /** + * Filter the value of the Off button. + * + * @since 2.5.0 + * + * @param string $value The Off button value. Default 'off'. + * @param string $field_id The field ID. + * @param string $filter_id For filtering both on/off value with one function. + */ + 'value' => apply_filters( 'ot_on_off_switch_off_value', 'off', $field_id, 'off' ), + /** + * Filter the label of the Off button. + * + * @since 2.5.0 + * + * @param string $label The Off button label. Default 'Off'. + * @param string $field_id The field ID. + * @param string $filter_id For filtering both on/off label with one function. + */ + 'label' => apply_filters( 'ot_on_off_switch_off_label', esc_html__( 'Off', 'option-tree' ), $field_id, 'off' ), + ), + ); + + /** + * Filter the width of the On/Off switch. + * + * @since 2.5.0 + * + * @param string $switch_width The switch width. Default '100px'. + * @param string $field_id The field ID. + */ + $switch_width = apply_filters( 'ot_on_off_switch_width', '100px', $field_id ); + + echo '
      '; // phpcs:ignore + + // Build radio. + foreach ( (array) $field_choices as $key => $choice ) { + echo ' + '; - } - - echo ''; + } - echo '
      '; + echo ''; - echo '
      '; + echo '
      '; - echo '
      '; + echo '
      '; - } + echo '
      '; + } } -/** - * Page Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_page_checkbox' ) ) { - - function ot_type_page_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* query pages array */ - $my_posts = get_posts( apply_filters( 'ot_type_page_checkbox_query', array( 'post_type' => array( 'page' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); - - /* has pages */ - if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { - foreach( $my_posts as $my_post ) { - $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; - echo '

      '; - echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

      '; - } - } else { - echo '

      ' . __( 'No Pages Found', 'option-tree' ) . '

      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Page Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_page_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Query pages array. + $my_posts = get_posts( + apply_filters( + 'ot_type_page_checkbox_query', + array( + 'post_type' => array( 'page' ), + 'posts_per_page' => -1, + 'orderby' => 'title', + 'order' => 'ASC', + 'post_status' => 'any', + ), + $field_id + ) + ); + + // Has pages. + if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { + foreach ( $my_posts as $my_post ) { + $post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled'; + echo '

      '; + echo 'ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

      '; + } + } else { + echo '

      ' . esc_html__( 'No Pages Found', 'option-tree' ) . '

      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Page Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_page_select' ) ) { - - function ot_type_page_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build page select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Page Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_page_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build page select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Post Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_post_checkbox' ) ) { - - function ot_type_post_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* query posts array */ - $my_posts = get_posts( apply_filters( 'ot_type_post_checkbox_query', array( 'post_type' => array( 'post' ), 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC', 'post_status' => 'any' ), $field_id ) ); - - /* has posts */ - if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { - foreach( $my_posts as $my_post ) { - $post_title = '' != $my_post->post_title ? $my_post->post_title : 'Untitled'; - echo '

      '; - echo 'ID] ) ? checked( $field_value[$my_post->ID], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

      '; - } - } else { - echo '

      ' . __( 'No Posts Found', 'option-tree' ) . '

      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Post Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_post_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Query posts array. + $my_posts = get_posts( + apply_filters( + 'ot_type_post_checkbox_query', + array( + 'post_type' => array( 'post' ), + 'posts_per_page' => -1, + 'orderby' => 'title', + 'order' => 'ASC', + 'post_status' => 'any', + ), + $field_id + ) + ); + + // Has posts. + if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { + foreach ( $my_posts as $my_post ) { + $post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled'; + echo '

      '; + echo 'ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

      '; + } + } else { + echo '

      ' . esc_html__( 'No Posts Found', 'option-tree' ) . '

      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Post Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_post_select' ) ) { - - function ot_type_post_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build page select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Post Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_post_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + /* description */ + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build page select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Radio option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_radio' ) ) { - - function ot_type_radio( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build radio */ - foreach ( (array) $field_choices as $key => $choice ) { - echo '

      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Radio option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_radio( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build radio. + foreach ( (array) $field_choices as $key => $choice ) { + echo '

      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Radio Images option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_radio_image' ) ) { - - function ot_type_radio_image( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /** - * load the default filterable images if nothing - * has been set in the choices array. - */ - if ( empty( $field_choices ) ) - $field_choices = ot_radio_images( $field_id ); - - /* build radio image */ - foreach ( (array) $field_choices as $key => $choice ) { - - $src = str_replace( 'OT_URL', OT_URL, $choice['src'] ); - $src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src ); - - /* make radio image source filterable */ - $src = apply_filters( 'ot_type_radio_image_src', $src, $field_id ); - - /** - * Filter the image attributes. - * - * @since 2.5.3 - * - * @param string $attributes The image attributes. - * @param string $field_id The field ID. - * @param array $choice The choice. - */ - $attributes = apply_filters( 'ot_type_radio_image_attributes', '', $field_id, $choice ); - - echo '
      '; - echo '

      '; - echo '' . esc_attr( $choice['label'] ) .''; - echo '
      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Radio Images option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_radio_image( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + /** + * Load the default filterable images if nothing + * has been set in the choices array. + */ + if ( empty( $field_choices ) ) { + $field_choices = ot_radio_images( $field_id ); + } + + // Build radio image. + foreach ( (array) $field_choices as $key => $choice ) { + + $src = str_replace( 'OT_URL', OT_URL, $choice['src'] ); + $src = str_replace( 'OT_THEME_URL', OT_THEME_URL, $src ); + + // Make radio image source filterable. + $src = apply_filters( 'ot_type_radio_image_src', $src, $field_id ); + + /** + * Filter the image attributes. + * + * @since 2.5.3 + * + * @param string $attributes The image attributes. + * @param string $field_id The field ID. + * @param array $choice The choice. + */ + $attributes = apply_filters( 'ot_type_radio_image_attributes', '', $field_id, $choice ); + + echo '
      '; + echo '

      '; + echo '' . esc_attr( $choice['label'] ) . ''; // phpcs:ignore + echo '
      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_select' ) ) { - - function ot_type_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* filter choices array */ - $field_choices = apply_filters( 'ot_type_select_choices', $field_choices, $field_id ); - - /* format setting inner wrapper */ - echo '
      '; - - /* build select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Filter choices array. + $field_choices = apply_filters( 'ot_type_select_choices', $field_choices, $field_id ); + + // Format setting inner wrapper. + echo '
      '; + + // Build select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Sidebar Select option type. - * - * This option type makes it possible for users to select a WordPress registered sidebar - * to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars', - * and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are - * available on a specific content area. - * - * For example, if we create a WordPress theme that provides the ability to change the - * Blog Sidebar and we don't want to have the footer sidebars available on this area, - * we can unset those sidebars either manually or by using a regular expression if we - * have a common name like footer-sidebar-$i. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.1 - */ if ( ! function_exists( 'ot_type_sidebar_select' ) ) { - - function ot_type_sidebar_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build page select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Sidebar Select option type. + * + * This option type makes it possible for users to select a WordPress registered sidebar + * to use on a specific area. By using the two provided filters, 'ot_recognized_sidebars', + * and 'ot_recognized_sidebars_{$field_id}' we can be selective about which sidebars are + * available on a specific content area. + * + * For example, if we create a WordPress theme that provides the ability to change the + * Blog Sidebar and we don't want to have the footer sidebars available on this area, + * we can unset those sidebars either manually or by using a regular expression if we + * have a common name like footer-sidebar-$i. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.1 + */ + function ot_type_sidebar_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build page select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * List Item option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_slider' ) ) { - - function ot_type_slider( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* pass the settings array arround */ - echo ''; - - /** - * settings pages have array wrappers like 'option_tree'. - * So we need that value to create a proper array to save to. - * This is only for NON metabox settings. - */ - if ( ! isset( $get_option ) ) - $get_option = ''; - - /* build list items */ - echo '
        '; - - if ( is_array( $field_value ) && ! empty( $field_value ) ) { - - foreach( $field_value as $key => $list_item ) { - - echo '
      • '; - ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type ); - echo '
      • '; - - } - - } - - echo '
      '; - - /* button */ - echo '' . __( 'Add New', 'option-tree' ) . ''; - - /* description */ - echo '
      ' . __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '
      '; - - echo '
      '; - - echo '
      '; - - } - + + /** + * List Item option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_slider( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Pass the settings array around. + echo ''; + + /** + * Settings pages have array wrappers like 'option_tree'. + * So we need that value to create a proper array to save to. + * This is only for NON metabox settings. + */ + if ( ! isset( $get_option ) ) { + $get_option = ''; + } + + // Build list items. + echo '
        '; + + if ( is_array( $field_value ) && ! empty( $field_value ) ) { + + foreach ( $field_value as $key => $list_item ) { + + echo '
      • '; + ot_list_item_view( $field_id, $key, $list_item, $post_id, $get_option, $field_settings, $type ); + echo '
      • '; + } + } + + echo '
      '; + + // Button. + echo '' . esc_html__( 'Add New', 'option-tree' ) . ''; // phpcs:ignore + + // Description. + echo '
      ' . esc_html__( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ) . '
      '; + + echo '
      '; + + echo '
      '; + } } -/** - * Social Links option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.4.0 - */ if ( ! function_exists( 'ot_type_social_links' ) ) { - - function ot_type_social_links( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* Load the default social links */ - if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) { - - $field_value = apply_filters( 'ot_type_social_links_defaults', array( - array( - 'name' => __( 'Facebook', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Twitter', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Google+', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'LinkedIn', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Pinterest', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Youtube', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Dribbble', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Github', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Forrst', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Digg', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Delicious', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Tumblr', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Skype', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'SoundCloud', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Vimeo', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'Flickr', 'option-tree' ), - 'title' => '', - 'href' => '' - ), - array( - 'name' => __( 'VK.com', 'option-tree' ), - 'title' => '', - 'href' => '' - ) - ), $field_id ); - - } - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* pass the settings array arround */ - echo ''; - - /** - * settings pages have array wrappers like 'option_tree'. - * So we need that value to create a proper array to save to. - * This is only for NON metabox settings. - */ - if ( ! isset( $get_option ) ) - $get_option = ''; - - /* build list items */ - echo '
        '; - - if ( is_array( $field_value ) && ! empty( $field_value ) ) { - - foreach( $field_value as $key => $link ) { - - echo '
      • '; - ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings, $type ); - echo '
      • '; - - } - - } - - echo '
      '; - - /* button */ - echo '' . __( 'Add New', 'option-tree' ) . ''; - - /* description */ - echo '
      ' . apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) . '
      '; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Social Links option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.4.0 + */ + function ot_type_social_links( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Load the default social links. + if ( empty( $field_value ) && apply_filters( 'ot_type_social_links_load_defaults', true, $field_id ) ) { + + $field_value = apply_filters( + 'ot_type_social_links_defaults', + array( + array( + 'name' => __( 'Facebook', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Twitter', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Google+', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'LinkedIn', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Pinterest', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Youtube', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Dribbble', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Github', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Forrst', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Digg', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Delicious', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Tumblr', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Skype', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'SoundCloud', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Vimeo', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'Flickr', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + array( + 'name' => __( 'VK.com', 'option-tree' ), + 'title' => '', + 'href' => '', + ), + ), + $field_id + ); + + } + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Pass the settings array around. + echo ''; + + /** + * Settings pages have array wrappers like 'option_tree'. + * So we need that value to create a proper array to save to. + * This is only for NON metabox settings. + */ + if ( ! isset( $get_option ) ) { + $get_option = ''; + } + + // Build list items. + echo '
        '; + + if ( is_array( $field_value ) && ! empty( $field_value ) ) { + + foreach ( $field_value as $key => $link ) { + + echo '
      • '; + ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings, $type ); + echo '
      • '; + } + } + + echo '
      '; + + // Button. + echo '' . esc_html__( 'Add New', 'option-tree' ) . ''; // phpcs:ignore + + // Description. + echo '
      ' . esc_html( apply_filters( 'ot_social_links_description', __( 'You can re-order with drag & drop, the order will update after saving.', 'option-tree' ), $field_id ) ) . '
      '; + + echo '
      '; + + echo '
      '; + } } -/** - * Spacing Option Type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.5.0 - */ if ( ! function_exists( 'ot_type_spacing' ) ) { - function ot_type_spacing( $args = array() ) { + /** + * Spacing Option Type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.5.0 + */ + function ot_type_spacing( $args = array() ) { - /* turns arguments array into variables */ - extract( $args ); + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore - /* verify a description */ - $has_desc = $field_desc ? true : false; + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; - /* format setting outer wrapper */ - echo '
      '; + // Format setting outer wrapper. + echo '
      '; - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; - /* format setting inner wrapper */ - echo '
      '; + // Format setting inner wrapper. + echo '
      '; - /* allow fields to be filtered */ - $ot_recognized_spacing_fields = apply_filters( 'ot_recognized_spacing_fields', array( - 'top', - 'right', - 'bottom', - 'left', - 'unit' - ), $field_id ); + // Allow fields to be filtered. + $ot_recognized_spacing_fields = apply_filters( + 'ot_recognized_spacing_fields', + array( + 'top', + 'right', + 'bottom', + 'left', + 'unit', + ), + $field_id + ); - /* build top spacing */ - if ( in_array( 'top', $ot_recognized_spacing_fields ) ) { + // Build top spacing. + if ( in_array( 'top', $ot_recognized_spacing_fields, true ) ) { - $top = isset( $field_value['top'] ) ? esc_attr( $field_value['top'] ) : ''; + $top = isset( $field_value['top'] ) ? $field_value['top'] : ''; - echo '
      '; + echo '
      '; + } - } + // Build right spacing. + if ( in_array( 'right', $ot_recognized_spacing_fields, true ) ) { - /* build right spacing */ - if ( in_array( 'right', $ot_recognized_spacing_fields ) ) { + $right = isset( $field_value['right'] ) ? $field_value['right'] : ''; - $right = isset( $field_value['right'] ) ? esc_attr( $field_value['right'] ) : ''; + echo '
      '; + } - echo '
      '; + // Build bottom spacing. + if ( in_array( 'bottom', $ot_recognized_spacing_fields, true ) ) { - } + $bottom = isset( $field_value['bottom'] ) ? $field_value['bottom'] : ''; - /* build bottom spacing */ - if ( in_array( 'bottom', $ot_recognized_spacing_fields ) ) { + echo '
      '; + } - $bottom = isset( $field_value['bottom'] ) ? esc_attr( $field_value['bottom'] ) : ''; + // Build left spacing. + if ( in_array( 'left', $ot_recognized_spacing_fields, true ) ) { - echo '
      '; + $left = isset( $field_value['left'] ) ? $field_value['left'] : ''; - } + echo '
      '; + } - /* build left spacing */ - if ( in_array( 'left', $ot_recognized_spacing_fields ) ) { + // Build unit dropdown. + if ( in_array( 'unit', $ot_recognized_spacing_fields, true ) ) { - $left = isset( $field_value['left'] ) ? esc_attr( $field_value['left'] ) : ''; + echo '
      '; - echo '
      '; + echo ''; - - echo ''; - - foreach ( ot_recognized_spacing_unit_types( $field_id ) as $unit ) { - echo ''; - } - - echo ''; - - echo '
      '; + foreach ( ot_recognized_spacing_unit_types( $field_id ) as $unit ) { + echo ''; + } - } - - echo '
      '; + echo ''; - echo '
      '; + echo '
      '; + } - } + echo '
      '; + echo '
      '; + } } -/** - * Tab option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.3.0 - */ if ( ! function_exists( 'ot_type_tab' ) ) { - - function ot_type_tab( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* format setting outer wrapper */ - echo '
      '; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Tab option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @access public + * @since 2.3.0 + */ + function ot_type_tab() { + echo '

      '; + } } -/** - * Tag Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_tag_checkbox' ) ) { - - function ot_type_tag_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* get tags */ - $tags = get_tags( array( 'hide_empty' => false ) ); - - /* has tags */ - if ( $tags ) { - foreach( $tags as $tag ) { - echo '

      '; - echo 'term_id] ) ? checked( $field_value[$tag->term_id], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

      '; - } - } else { - echo '

      ' . __( 'No Tags Found', 'option-tree' ) . '

      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Tag Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_tag_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Get tags. + $tags = get_tags( array( 'hide_empty' => false ) ); + + // Has tags. + if ( $tags ) { + foreach ( $tags as $tag ) { + echo '

      '; + echo 'term_id ] ) ? checked( $field_value[ $tag->term_id ], $tag->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

      '; + } + } else { + echo '

      ' . esc_html__( 'No Tags Found', 'option-tree' ) . '

      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Tag Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_tag_select' ) ) { - - function ot_type_tag_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build tag select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Tag Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_tag_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build tag select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Taxonomy Checkbox option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_taxonomy_checkbox' ) ) { - - function ot_type_taxonomy_checkbox( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* setup the taxonomy */ - $taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' ); - - /* get taxonomies */ - $taxonomies = get_categories( apply_filters( 'ot_type_taxonomy_checkbox_query', array( 'hide_empty' => false, 'taxonomy' => $taxonomy ), $field_id ) ); - - /* has tags */ - if ( $taxonomies ) { - foreach( $taxonomies as $taxonomy ) { - echo '

      '; - echo 'term_id] ) ? checked( $field_value[$taxonomy->term_id], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; - echo ''; - echo '

      '; - } - } else { - echo '

      ' . __( 'No Taxonomies Found', 'option-tree' ) . '

      '; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Taxonomy Checkbox option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_taxonomy_checkbox( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Setup the taxonomy. + $taxonomy = isset( $field_taxonomy ) ? explode( ',', $field_taxonomy ) : array( 'category' ); + + // Get taxonomies. + $taxonomies = get_categories( + apply_filters( + 'ot_type_taxonomy_checkbox_query', + array( + 'hide_empty' => false, + 'taxonomy' => $taxonomy, + ), + $field_id + ) + ); + + // Has tags. + if ( $taxonomies ) { + foreach ( $taxonomies as $taxonomy ) { + echo '

      '; + echo 'term_id ] ) ? checked( $field_value[ $taxonomy->term_id ], $taxonomy->term_id, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; + echo ''; + echo '

      '; + } + } else { + echo '

      ' . esc_html__( 'No Taxonomies Found', 'option-tree' ) . '

      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Taxonomy Select option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_taxonomy_select' ) ) { - - function ot_type_taxonomy_select( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build tag select */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Taxonomy Select option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_taxonomy_select( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build tag select. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Text option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_text' ) ) { - - function ot_type_text( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build text input */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Text option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_text( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build text input. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Textarea option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_textarea' ) ) { - - function ot_type_textarea( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build textarea */ - wp_editor( - $field_value, - esc_attr( $field_id ), - array( - 'editor_class' => esc_attr( $field_class ), - 'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ), - 'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ), - 'textarea_name' => esc_attr( $field_name ), - 'textarea_rows' => esc_attr( $field_rows ), - 'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ), - 'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id ) - ) - ); - - echo '
      '; - - echo '
      '; - - } - + + /** + * Textarea option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_textarea( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Build textarea. + wp_editor( + $field_value, + esc_attr( $field_id ), + array( + 'editor_class' => esc_attr( $field_class ), + 'wpautop' => apply_filters( 'ot_wpautop', false, $field_id ), + 'media_buttons' => apply_filters( 'ot_media_buttons', true, $field_id ), + 'textarea_name' => esc_attr( $field_name ), + 'textarea_rows' => esc_attr( $field_rows ), + 'tinymce' => apply_filters( 'ot_tinymce', true, $field_id ), + 'quicktags' => apply_filters( 'ot_quicktags', array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ), $field_id ), + ) + ); + + echo '
      '; + + echo '
      '; + } } -/** - * Textarea Simple option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_textarea_simple' ) ) { - - function ot_type_textarea_simple( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* filter to allow wpautop */ - $wpautop = apply_filters( 'ot_wpautop', false, $field_id ); - - /* wpautop $field_value */ - if ( $wpautop == true ) - $field_value = wpautop( $field_value ); - - /* build textarea simple */ - echo ''; - - echo '
      '; - - echo '
      '; - - } - + + /** + * Textarea Simple option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_textarea_simple( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Filter to allow wpautop. + $wpautop = apply_filters( 'ot_wpautop', false, $field_id ); + + // Wpautop $field_value. + if ( true === $wpautop ) { + $field_value = wpautop( $field_value ); + } + + // Build textarea simple. + echo ''; + + echo '
      '; + + echo '
      '; + } } -/** - * Textblock option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_textblock' ) ) { - - function ot_type_textblock( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo '
      ' . htmlspecialchars_decode( $field_desc ) . '
      '; - - echo '
      '; - - } - + + /** + * Textblock option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_textblock( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      '; + + echo '
      '; + } } -/** - * Textblock Titled option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_textblock_titled' ) ) { - - function ot_type_textblock_titled( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo '
      ' . htmlspecialchars_decode( $field_desc ) . '
      '; - - echo '
      '; - - } - + + /** + * Textblock Titled option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_textblock_titled( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      '; + + echo '
      '; + } } -/** - * Typography option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_typography' ) ) { - - function ot_type_typography( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* allow fields to be filtered */ - $ot_recognized_typography_fields = apply_filters( 'ot_recognized_typography_fields', array( - 'font-color', - 'font-family', - 'font-size', - 'font-style', - 'font-variant', - 'font-weight', - 'letter-spacing', - 'line-height', - 'text-decoration', - 'text-transform' - ), $field_id ); - - /* build font color */ - if ( in_array( 'font-color', $ot_recognized_typography_fields ) ) { - - /* build colorpicker */ - echo '
      '; - - /* colorpicker JS */ - echo ''; - - /* set background color */ - $background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : ''; - - /* input */ - echo ''; - - echo '
      '; - - } - - /* build font family */ - if ( in_array( 'font-family', $ot_recognized_typography_fields ) ) { - $font_family = isset( $field_value['font-family'] ) ? $field_value['font-family'] : ''; - echo ''; - } - - /* build font size */ - if ( in_array( 'font-size', $ot_recognized_typography_fields ) ) { - $font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : ''; - echo ''; - } - - /* build font style */ - if ( in_array( 'font-style', $ot_recognized_typography_fields ) ) { - $font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : ''; - echo ''; - } - - /* build font variant */ - if ( in_array( 'font-variant', $ot_recognized_typography_fields ) ) { - $font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : ''; - echo ''; - } - - /* build font weight */ - if ( in_array( 'font-weight', $ot_recognized_typography_fields ) ) { - $font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : ''; - echo ''; - } - - /* build letter spacing */ - if ( in_array( 'letter-spacing', $ot_recognized_typography_fields ) ) { - $letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : ''; - echo ''; - } - - /* build line height */ - if ( in_array( 'line-height', $ot_recognized_typography_fields ) ) { - $line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : ''; - echo ''; - } - - /* build text decoration */ - if ( in_array( 'text-decoration', $ot_recognized_typography_fields ) ) { - $text_decoration = isset( $field_value['text-decoration'] ) ? esc_attr( $field_value['text-decoration'] ) : ''; - echo ''; - } - - /* build text transform */ - if ( in_array( 'text-transform', $ot_recognized_typography_fields ) ) { - $text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : ''; - echo ''; - } - - echo '
      '; - - echo '
      '; - - } - + + /** + * Typography option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_typography( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; + + // Format setting inner wrapper. + echo '
      '; + + // Allow fields to be filtered. + $ot_recognized_typography_fields = apply_filters( + 'ot_recognized_typography_fields', + array( + 'font-color', + 'font-family', + 'font-size', + 'font-style', + 'font-variant', + 'font-weight', + 'letter-spacing', + 'line-height', + 'text-decoration', + 'text-transform', + ), + $field_id + ); + + // Build font color. + if ( in_array( 'font-color', $ot_recognized_typography_fields, true ) ) { + + // Build colorpicker. + echo '
      '; + + // Colorpicker JS. + echo ''; + + // Set background color. + $background_color = isset( $field_value['font-color'] ) ? esc_attr( $field_value['font-color'] ) : ''; + + /* input */ + echo ''; + + echo '
      '; + } + + // Build font family. + if ( in_array( 'font-family', $ot_recognized_typography_fields, true ) ) { + $font_family = isset( $field_value['font-family'] ) ? $field_value['font-family'] : ''; + echo ''; + } + + // Build font size. + if ( in_array( 'font-size', $ot_recognized_typography_fields, true ) ) { + $font_size = isset( $field_value['font-size'] ) ? esc_attr( $field_value['font-size'] ) : ''; + echo ''; + } + + // Build font style. + if ( in_array( 'font-style', $ot_recognized_typography_fields, true ) ) { + $font_style = isset( $field_value['font-style'] ) ? esc_attr( $field_value['font-style'] ) : ''; + echo ''; + } + + // Build font variant. + if ( in_array( 'font-variant', $ot_recognized_typography_fields, true ) ) { + $font_variant = isset( $field_value['font-variant'] ) ? esc_attr( $field_value['font-variant'] ) : ''; + echo ''; + } + + // Build font weight. + if ( in_array( 'font-weight', $ot_recognized_typography_fields, true ) ) { + $font_weight = isset( $field_value['font-weight'] ) ? esc_attr( $field_value['font-weight'] ) : ''; + echo ''; + } + + // Build letter spacing. + if ( in_array( 'letter-spacing', $ot_recognized_typography_fields, true ) ) { + $letter_spacing = isset( $field_value['letter-spacing'] ) ? esc_attr( $field_value['letter-spacing'] ) : ''; + echo ''; + } + + // Build line height. + if ( in_array( 'line-height', $ot_recognized_typography_fields, true ) ) { + $line_height = isset( $field_value['line-height'] ) ? esc_attr( $field_value['line-height'] ) : ''; + echo ''; + } + + // Build text decoration. + if ( in_array( 'text-decoration', $ot_recognized_typography_fields, true ) ) { + $text_decoration = isset( $field_value['text-decoration'] ) ? esc_attr( $field_value['text-decoration'] ) : ''; + echo ''; + } + + // Build text transform. + if ( in_array( 'text-transform', $ot_recognized_typography_fields, true ) ) { + $text_transform = isset( $field_value['text-transform'] ) ? esc_attr( $field_value['text-transform'] ) : ''; + echo ''; + } + + echo '
      '; + + echo '
      '; + + } } -/** - * Upload option type. - * - * See @ot_display_by_type to see the full list of available arguments. - * - * @param array An array of arguments. - * @return string - * - * @access public - * @since 2.0 - */ if ( ! function_exists( 'ot_type_upload' ) ) { - - function ot_type_upload( $args = array() ) { - - /* turns arguments array into variables */ - extract( $args ); - - /* verify a description */ - $has_desc = $field_desc ? true : false; - - /* If an attachment ID is stored here fetch its URL and replace the value */ - if ( $field_value && wp_attachment_is_image( $field_value ) ) { - - $attachment_data = wp_get_attachment_image_src( $field_value, 'original' ); - - /* check for attachment data */ - if ( $attachment_data ) { - - $field_src = $attachment_data[0]; - - } - - } - - /* format setting outer wrapper */ - echo '
      '; - - /* description */ - echo $has_desc ? '
      ' . htmlspecialchars_decode( $field_desc ) . '
      ' : ''; - - /* format setting inner wrapper */ - echo '
      '; - - /* build upload */ - echo '
      '; - - /* input */ - echo ''; - - /* add media button */ - echo '' . __( 'Add Media', 'option-tree' ) . ''; - - echo '
      '; - - /* media */ - if ( $field_value ) { - - echo '
      '; - - /* replace image src */ - if ( isset( $field_src ) ) - $field_value = $field_src; - - if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) ) - echo '
      '; - - echo '' . __( 'Remove Media', 'option-tree' ) . ''; - - echo '
      '; - - } - - echo '
      '; - - echo '
      '; - - } - -} -/* End of file ot-functions-option-types.php */ -/* Location: ./includes/ot-functions-option-types.php */ + /** + * Upload option type. + * + * See @ot_display_by_type to see the full list of available arguments. + * + * @param array $args An array of arguments. + * + * @access public + * @since 2.0 + */ + function ot_type_upload( $args = array() ) { + + // Turns arguments array into variables. + extract( $args ); // phpcs:ignore + + // Verify a description. + $has_desc = ! empty( $field_desc ) ? true : false; + + // If an attachment ID is stored here fetch its URL and replace the value. + if ( $field_value && wp_attachment_is_image( $field_value ) ) { + + $attachment_data = wp_get_attachment_image_src( $field_value, 'original' ); + + // Check for attachment data. + if ( $attachment_data ) { + + $field_src = $attachment_data[0]; + } + } + + // Format setting outer wrapper. + echo '
      '; + + // Description. + echo $has_desc ? '
      ' . wp_kses_post( htmlspecialchars_decode( $field_desc ) ) . '
      ' : ''; // phpcs:ignore + + // Format setting inner wrapper. + echo '
      '; + + // Build upload. + echo '
      '; + + echo ''; + + // Add media button. + echo '' . esc_html__( 'Add Media', 'option-tree' ) . ''; // phpcs:ignore + + echo '
      '; + + // Media. + if ( $field_value ) { + + echo '
      '; + + // Replace image src. + if ( isset( $field_src ) ) { + $field_value = $field_src; + } + + if ( preg_match( '/\.(?:jpe?g|png|gif|ico)$/i', $field_value ) ) { + echo '
      '; + } + + echo '' . esc_html__( 'Remove Media', 'option-tree' ) . ''; + + echo '
      '; + + } + + echo '
      '; + + echo '
      '; + } +} From 2ee06b05d6ab8694f6c9fa2399aa8f0444fe0f16 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 21:15:36 -0800 Subject: [PATCH 23/67] Keep from calling without a type --- includes/ot-functions-option-types.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/ot-functions-option-types.php b/includes/ot-functions-option-types.php index 08fa1e5..c17c6d4 100755 --- a/includes/ot-functions-option-types.php +++ b/includes/ot-functions-option-types.php @@ -30,14 +30,18 @@ * @var array $field_choices The array of option choices. * @var array $field_settings The array of settings for a list item. * - * @access public - * @since 2.0 + * @access public + * @since 2.0 */ function ot_display_by_type( $args = array() ) { // Allow filters to be executed on the array. $args = apply_filters( 'ot_display_by_type', $args ); + if ( empty( $args['type'] ) ) { + return; + } + // Build the function name. $function_name_by_type = str_replace( '-', '_', 'ot_type_' . $args['type'] ); From cdc7db733ea1b125a54e663be51fd4ebf455dcb8 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 3 Mar 2019 23:52:18 -0800 Subject: [PATCH 24/67] Fix theme path --- ot-loader.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ot-loader.php b/ot-loader.php index 356083b..88130fd 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -228,11 +228,13 @@ private function constants() { define( 'OT_URL', plugin_dir_url( __FILE__ ) ); } else { if ( true === OT_CHILD_THEME_MODE ) { - $path = ltrim( end( explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + $temp_path = explode( get_stylesheet(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); + $path = ltrim( end( $temp_path ), '/' ); define( 'OT_DIR', trailingslashit( trailingslashit( get_stylesheet_directory() ) . $path ) ); define( 'OT_URL', trailingslashit( trailingslashit( get_stylesheet_directory_uri() ) . $path ) ); } else { - $path = ltrim( end( explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ) ), '/' ); + $temp_path = explode( get_template(), str_replace( '\\', '/', dirname( __FILE__ ) ) ); + $path = ltrim( end( $temp_path ), '/' ); define( 'OT_DIR', trailingslashit( trailingslashit( get_template_directory() ) . $path ) ); define( 'OT_URL', trailingslashit( trailingslashit( get_template_directory_uri() ) . $path ) ); } From 97adf98c9bb265ebf3997908442513a9fec78116 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 4 Mar 2019 00:08:02 -0800 Subject: [PATCH 25/67] Remove param --- includes/ot-functions-option-types.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ot-functions-option-types.php b/includes/ot-functions-option-types.php index c17c6d4..4aab4cc 100755 --- a/includes/ot-functions-option-types.php +++ b/includes/ot-functions-option-types.php @@ -2369,7 +2369,7 @@ function ot_type_social_links( $args = array() ) { foreach ( $field_value as $key => $link ) { echo '
    • '; - ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings, $type ); + ot_social_links_view( $field_id, $key, $link, $post_id, $get_option, $field_settings ); echo '
    • '; } } From 9b4ed022d2c52bb0be63473d2a6aa40b6c5ae797 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:36:12 -0800 Subject: [PATCH 26/67] Exclude demo files --- .phpcs.ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/.phpcs.ruleset.xml b/.phpcs.ruleset.xml index 1289380..ac49c2a 100644 --- a/.phpcs.ruleset.xml +++ b/.phpcs.ruleset.xml @@ -11,6 +11,7 @@ https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders --> /vendor/* /tests/wp-tests/* + /assets/theme-mode/* From c10a1a8190fb664f0c352cb65c9aed50438bed6e Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:38:32 -0800 Subject: [PATCH 27/67] Fix typo --- includes/class-ot-meta-box.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-ot-meta-box.php b/includes/class-ot-meta-box.php index 84bfec8..6b7e0f0 100755 --- a/includes/class-ot-meta-box.php +++ b/includes/class-ot-meta-box.php @@ -268,7 +268,7 @@ public function save_meta_box( $post_id, $post_object ) { // Convert the settings to an array. $settings = maybe_unserialize( $decoded ); - // Settings are empty for some odd ass reason get the defaults. + // Settings are empty for some odd reason get the defaults. if ( empty( $settings ) ) { $settings = ( 'slider' === $field['type'] ) ? ot_slider_settings( $field['id'] ) : ot_list_item_settings( $field['id'] ); } From 7fccdfdb1c4fd0f7d782158527f565713caf8fbf Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:48:46 -0800 Subject: [PATCH 28/67] Remove xml import --- includes/ot-functions-compat.php | 25 ----------- includes/ot-functions-settings-page.php | 55 ------------------------- 2 files changed, 80 deletions(-) diff --git a/includes/ot-functions-compat.php b/includes/ot-functions-compat.php index c7a4811..195d505 100755 --- a/includes/ot-functions-compat.php +++ b/includes/ot-functions-compat.php @@ -31,21 +31,9 @@ function compat_ot_import_from_files() { // File path & name. - $ot_xml = '/option-tree/theme-options.xml'; $ot_data = '/option-tree/theme-options.txt'; $ot_layout = '/option-tree/layouts.txt'; - // XML file path - child theme first then parent. - if ( is_readable( get_stylesheet_directory() . $ot_xml ) ) { - - $xml_file = get_stylesheet_directory_uri() . $ot_xml; - - } elseif ( is_readable( get_template_directory() . $ot_xml ) ) { - - $xml_file = get_template_directory_uri() . $ot_xml; - - } - // Data file path - child theme first then parent. if ( is_readable( get_stylesheet_directory() . $ot_data ) ) { @@ -69,22 +57,9 @@ function compat_ot_import_from_files() { } // Check for files. - $has_xml = isset( $xml_file ) ? true : false; $has_data = isset( $data_file ) ? true : false; $has_layout = isset( $layout_file ) ? true : false; - // Auto import XML file. - if ( true === $has_xml && ! get_option( ot_settings_id() ) && class_exists( 'SimpleXMLElement' ) ) { - - $settings = ot_import_xml( $xml_file ); - - if ( isset( $settings ) && ! empty( $settings ) ) { - - update_option( ot_settings_id(), $settings ); - - } - } - // Auto import Data file. if ( true === $has_data && ! get_option( ot_options_id() ) ) { diff --git a/includes/ot-functions-settings-page.php b/includes/ot-functions-settings-page.php index 0157281..7915ad5 100755 --- a/includes/ot-functions-settings-page.php +++ b/includes/ot-functions-settings-page.php @@ -139,61 +139,6 @@ function ot_type_theme_options_ui() { } } -if ( ! function_exists( 'ot_type_import_xml' ) ) { - - /** - * Import XML option type. - * - * @access public - * @since 2.0 - */ - function ot_type_import_xml() { - - echo '
      '; - - // Form nonce. - wp_nonce_field( 'import_xml_form', 'import_xml_nonce' ); - - // Format setting outer wrapper. - echo '
      '; - - // Description. - echo '
      '; - - echo '

      ' . esc_html__( 'This import method has been deprecated. That means it has been replaced by a new method and is no longer supported, and may be removed from future versions. All themes that use this import method should be converted to use its replacement below.', 'option-tree' ) . '

      '; - - /* translators: %s: button text */ - echo '

      ' . sprintf( esc_html__( 'If you were given a Theme Options XML file with a premium or free theme, locate it on your hard drive and upload that file by clicking the upload button. A popup window will appear, upload the XML file and click "%s". The file URL should be in the upload input, if it is click "Import XML".', 'option-tree' ), esc_html( apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ) ) ) . '

      '; - - echo ''; - - echo '
      '; - - echo '
      '; - - // Build upload. - echo '
      '; - - // Input. - echo ''; - - // Get media post_id. - $id = ot_get_media_post_ID(); - $post_id = $id ? absint( $id ) : 0; - - // Add xml button. - echo '' . esc_html__( 'Add XML', 'option-tree' ) . ''; - - echo '
      '; - - echo '
      '; - - echo '
      '; - - echo '
      '; - } -} - if ( ! function_exists( 'ot_type_import_settings' ) ) { /** From b71d8f3e585efc8784e7fe72cf866b7152bb3fa4 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:51:17 -0800 Subject: [PATCH 29/67] Fix typo in function calls --- includes/ot-functions-option-types.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/ot-functions-option-types.php b/includes/ot-functions-option-types.php index 4aab4cc..a71824f 100755 --- a/includes/ot-functions-option-types.php +++ b/includes/ot-functions-option-types.php @@ -775,7 +775,7 @@ function ot_type_custom_post_type_checkbox( $args = array() ) { // Has posts. if ( is_array( $my_posts ) && ! empty( $my_posts ) ) { foreach ( $my_posts as $my_post ) { - $post_title = ! emoty( $my_post->post_title ) ? $my_post->post_title : 'Untitled'; + $post_title = ! empty( $my_post->post_title ) ? $my_post->post_title : 'Untitled'; echo '

      '; echo 'ID ] ) ? checked( $field_value[ $my_post->ID ], $my_post->ID, false ) : '' ) . ' class="option-tree-ui-checkbox ' . esc_attr( $field_class ) . '" />'; echo ''; @@ -3137,7 +3137,7 @@ function ot_type_upload( $args = array() ) { echo ''; // Add media button. - echo '' . esc_html__( 'Add Media', 'option-tree' ) . ''; // phpcs:ignore + echo '' . esc_html__( 'Add Media', 'option-tree' ) . ''; // phpcs:ignore echo '

      '; From c1efe7c24375121a1913976503e1f348da63947e Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:53:35 -0800 Subject: [PATCH 30/67] Remove xml import filter --- ot-loader.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/ot-loader.php b/ot-loader.php index 88130fd..43c2b22 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -378,9 +378,6 @@ private function hooks() { // default settings. add_action( 'admin_init', 'ot_default_settings', 2 ); - // add xml to upload filetypes array. - add_action( 'admin_init', 'ot_add_xml_to_upload_filetypes', 3 ); - // import. add_action( 'admin_init', 'ot_import', 4 ); From bf9ebeaf17ec76d2aebf1c7494a8364dd15d3c5a Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 22:57:50 -0800 Subject: [PATCH 31/67] Fix typo --- ot-loader.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ot-loader.php b/ot-loader.php index 43c2b22..dad36dd 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -20,13 +20,10 @@ * Forces Plugin Mode when OptionTree is already loaded and displays an admin notice. */ function ot_conflict_notice() { - echo '

      ' . esc_html__( 'OptionTree is installed as a plugin and also embedded in your current theme. Please deactivate the plugin to load the theme dependent version of OptionTree, and remove this warning.', 'option-tree' ) . '

      '; - } add_action( 'admin_notices', 'ot_conflict_notice' ); - } if ( ! class_exists( 'OT_Loader' ) ) { @@ -372,34 +369,34 @@ private function hooks() { // Adds the Theme Option page to the admin bar. add_action( 'admin_bar_menu', 'ot_register_theme_options_admin_bar_menu', 999 ); - // prepares the after save do_action. + // Prepares the after save do_action. add_action( 'admin_init', 'ot_after_theme_options_save', 1 ); // default settings. add_action( 'admin_init', 'ot_default_settings', 2 ); - // import. + // Import. add_action( 'admin_init', 'ot_import', 4 ); - // export. + // Export. add_action( 'admin_init', 'ot_export', 5 ); - // save settings. + // Save settings. add_action( 'admin_init', 'ot_save_settings', 6 ); - // save layouts. + // Save layouts. add_action( 'admin_init', 'ot_modify_layouts', 7 ); - // create media post. + // Create media post. add_action( 'admin_init', 'ot_create_media_post', 8 ); // Google Fonts front-end CSS. add_action( 'wp_enqueue_scripts', 'ot_load_google_fonts_css', 1 ); - // dynamic front-end CSS. + // Dynamic front-end CSS. add_action( 'wp_enqueue_scripts', 'ot_load_dynamic_css', 999 ); - // insert theme CSS dynamically. + // Insert theme CSS dynamically. add_action( 'ot_after_theme_options_save', 'ot_save_css' ); // AJAX call to create a new section. @@ -750,5 +747,5 @@ public function change_image_button( $translation, $text, $domain ) { * * @since 2.0 */ - $ot_loader = new OT_Loader(); + new OT_Loader(); } From 78c1688b2bf70531fa7abdb52c2b9b91fa3653d3 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 6 Mar 2019 23:01:17 -0800 Subject: [PATCH 32/67] Fix phpcs issues --- includes/ot-functions-admin.php | 11303 +++++++++++++++--------------- 1 file changed, 5552 insertions(+), 5751 deletions(-) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 61aff92..b79044e 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -1,6130 +1,5931 @@ - - * @copyright Copyright (c) 2013, Derek Herman - * @since 2.0 + * @package OptionTree */ -/** - * Registers the Theme Option page - * - * @uses ot_register_settings() - * - * @return void - * - * @access public - * @since 2.1 - */ -if ( ! function_exists( 'ot_register_theme_options_page' ) ) { - - function ot_register_theme_options_page() { - - /* get the settings array */ - $get_settings = get_option( ot_settings_id() ); - - /* sections array */ - $sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array(); - - /* settings array */ - $settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array(); - - /* contexual_help array */ - $contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array(); - - /* build the Theme Options */ - if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) { - - $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ); - - ot_register_settings( array( - array( - 'id' => ot_options_id(), - 'pages' => array( - array( - 'id' => 'ot_theme_options', - 'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ), - 'page_title' => apply_filters( 'ot_theme_options_page_title', __( 'Theme Options', 'option-tree' ) ), - 'menu_title' => apply_filters( 'ot_theme_options_menu_title', __( 'Theme Options', 'option-tree' ) ), - 'capability' => $caps, - 'menu_slug' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ), - 'icon_url' => apply_filters( 'ot_theme_options_icon_url', null ), - 'position' => apply_filters( 'ot_theme_options_position', null ), - 'updated_message' => apply_filters( 'ot_theme_options_updated_message', __( 'Theme Options updated.', 'option-tree' ) ), - 'reset_message' => apply_filters( 'ot_theme_options_reset_message', __( 'Theme Options reset.', 'option-tree' ) ), - 'button_text' => apply_filters( 'ot_theme_options_button_text', __( 'Save Changes', 'option-tree' ) ), - 'contextual_help' => apply_filters( 'ot_theme_options_contextual_help', $contextual_help ), - 'sections' => apply_filters( 'ot_theme_options_sections', $sections ), - 'settings' => apply_filters( 'ot_theme_options_settings', $settings ) - ) - ) - ) - ) - ); - - // Filters the options.php to add the minimum user capabilities. - add_filter( 'option_page_capability_' . ot_options_id(), function() use ( $caps ) { return $caps; }, 999 ); - - } - - } - -} - -/** - * Registers the Settings page - * - * @uses ot_register_settings() - * - * @return void - * - * @access public - * @since 2.1 - */ -if ( ! function_exists( 'ot_register_settings_page' ) ) { - - function ot_register_settings_page() { - global $ot_has_custom_theme_options; - - // Display UI Builder admin notice - if ( OT_SHOW_OPTIONS_UI == true && isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'ot-settings' && ( $ot_has_custom_theme_options == true || has_action( 'admin_init', 'custom_theme_options' ) || has_action( 'init', 'custom_theme_options' ) ) ) { - - function ot_has_custom_theme_options() { - - echo '

      ' . __( 'The Theme Options UI Builder is being overridden by a custom file in your theme. Any changes you make via the UI Builder will not be saved.', 'option-tree' ) . '

      '; - - } - - add_action( 'admin_notices', 'ot_has_custom_theme_options' ); - - } - - // Create the filterable pages array - $ot_register_pages_array = array( - array( - 'id' => 'ot', - 'page_title' => __( 'OptionTree', 'option-tree' ), - 'menu_title' => __( 'OptionTree', 'option-tree' ), - 'capability' => 'edit_theme_options', - 'menu_slug' => 'ot-settings', - 'icon_url' => null, - 'position' => 61, - 'hidden_page' => true - ), - array( - 'id' => 'settings', - 'parent_slug' => 'ot-settings', - 'page_title' => __( 'Settings', 'option-tree' ), - 'menu_title' => __( 'Settings', 'option-tree' ), - 'capability' => 'edit_theme_options', - 'menu_slug' => 'ot-settings', - 'icon_url' => null, - 'position' => null, - 'updated_message' => __( 'Theme Options updated.', 'option-tree' ), - 'reset_message' => __( 'Theme Options reset.', 'option-tree' ), - 'button_text' => __( 'Save Settings', 'option-tree' ), - 'show_buttons' => false, - 'sections' => array( - array( - 'id' => 'create_setting', - 'title' => __( 'Theme Options UI', 'option-tree' ) - ), - array( - 'id' => 'import', - 'title' => __( 'Import', 'option-tree' ) - ), - array( - 'id' => 'export', - 'title' => __( 'Export', 'option-tree' ) - ), - array( - 'id' => 'layouts', - 'title' => __( 'Layouts', 'option-tree' ) - ) - ), - 'settings' => array( - array( - 'id' => 'theme_options_ui_text', - 'label' => __( 'Theme Options UI Builder', 'option-tree' ), - 'type' => 'theme_options_ui', - 'section' => 'create_setting' - ), - array( - 'id' => 'import_xml_text', - 'label' => __( 'Settings XML', 'option-tree' ), - 'type' => 'import-xml', - 'section' => 'import' - ), - array( - 'id' => 'import_settings_text', - 'label' => __( 'Settings', 'option-tree' ), - 'type' => 'import-settings', - 'section' => 'import' - ), - array( - 'id' => 'import_data_text', - 'label' => __( 'Theme Options', 'option-tree' ), - 'type' => 'import-data', - 'section' => 'import' - ), - array( - 'id' => 'import_layouts_text', - 'label' => __( 'Layouts', 'option-tree' ), - 'type' => 'import-layouts', - 'section' => 'import' - ), - array( - 'id' => 'export_settings_file_text', - 'label' => __( 'Settings PHP File', 'option-tree' ), - 'type' => 'export-settings-file', - 'section' => 'export' - ), - array( - 'id' => 'export_settings_text', - 'label' => __( 'Settings', 'option-tree' ), - 'type' => 'export-settings', - 'section' => 'export' - ), - array( - 'id' => 'export_data_text', - 'label' => __( 'Theme Options', 'option-tree' ), - 'type' => 'export-data', - 'section' => 'export' - ), - array( - 'id' => 'export_layout_text', - 'label' => __( 'Layouts', 'option-tree' ), - 'type' => 'export-layouts', - 'section' => 'export' - ), - array( - 'id' => 'modify_layouts_text', - 'label' => __( 'Layout Management', 'option-tree' ), - 'type' => 'modify-layouts', - 'section' => 'layouts' - ) - ) - ), - array( - 'id' => 'documentation', - 'parent_slug' => 'ot-settings', - 'page_title' => __( 'Documentation', 'option-tree' ), - 'menu_title' => __( 'Documentation', 'option-tree' ), - 'capability' => 'edit_theme_options', - 'menu_slug' => 'ot-documentation', - 'icon_url' => null, - 'position' => null, - 'updated_message' => __( 'Theme Options updated.', 'option-tree' ), - 'reset_message' => __( 'Theme Options reset.', 'option-tree' ), - 'button_text' => __( 'Save Settings', 'option-tree' ), - 'show_buttons' => false, - 'sections' => array( - array( - 'id' => 'creating_options', - 'title' => __( 'Creating Options', 'option-tree' ) - ), - array( - 'id' => 'option_types', - 'title' => __( 'Option Types', 'option-tree' ) - ), - array( - 'id' => 'functions', - 'title' => __( 'Function References', 'option-tree' ) - ), - array( - 'id' => 'theme_mode', - 'title' => __( 'Theme Mode', 'option-tree' ) - ), - array( - 'id' => 'meta_boxes', - 'title' => __( 'Meta Boxes', 'option-tree' ) - ), - array( - 'id' => 'examples', - 'title' => __( 'Code Examples', 'option-tree' ) - ), - array( - 'id' => 'layouts_overview', - 'title' => __( 'Layouts Overview', 'option-tree' ) - ) - ), - 'settings' => array( - array( - 'id' => 'creating_options_text', - 'label' => __( 'Overview of available Theme Option fields.', 'option-tree' ), - 'type' => 'creating-options', - 'section' => 'creating_options' - ), - array( - 'id' => 'option_types_text', - 'label' => __( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ), - 'type' => 'option-types', - 'section' => 'option_types' - ), - array( - 'id' => 'functions_ot_get_option', - 'label' => __( 'Function Reference:ot_get_option()', 'option-tree' ), - 'type' => 'ot-get-option', - 'section' => 'functions' - ), - array( - 'id' => 'functions_get_option_tree', - 'label' => __( 'Function Reference:get_option_tree()', 'option-tree' ), - 'type' => 'get-option-tree', - 'section' => 'functions' - ), - array( - 'id' => 'theme_mode_text', - 'label' => __( 'Theme Mode', 'option-tree' ), - 'type' => 'theme-mode', - 'section' => 'theme_mode' - ), - array( - 'id' => 'meta_boxes_text', - 'label' => __( 'Meta Boxes', 'option-tree' ), - 'type' => 'meta-boxes', - 'section' => 'meta_boxes' - ), - array( - 'id' => 'example_text', - 'label' => __( 'Code examples for front-end development.', 'option-tree' ), - 'type' => 'examples', - 'section' => 'examples' - ), - array( - 'id' => 'layouts_overview_text', - 'label' => __( 'What\'s a layout anyhow?', 'option-tree' ), - 'type' => 'layouts-overview', - 'section' => 'layouts_overview' - ) - ) - ) - ); - - // Loop over the settings and remove as needed. - foreach( $ot_register_pages_array as $key => $page ) { - - // Remove various options from the Settings UI. - if ( $page['id'] == 'settings' ) { - - // Remove the Theme Options UI - if ( OT_SHOW_OPTIONS_UI == false ) { - - foreach( $page['sections'] as $section_key => $section ) { - if ( $section['id'] == 'create_setting' ) { - unset($ot_register_pages_array[$key]['sections'][$section_key]); - } - } - - foreach( $page['settings'] as $setting_key => $setting ) { - if ( $setting['section'] == 'create_setting' ) { - unset($ot_register_pages_array[$key]['settings'][$setting_key]); - } - } - - } - - // Remove parts of the Imports UI - if ( OT_SHOW_SETTINGS_IMPORT == false ) { - - foreach( $page['settings'] as $setting_key => $setting ) { - if ( $setting['section'] == 'import' && in_array( $setting['id'], array('import_xml_text', 'import_settings_text' ) ) ) { - unset($ot_register_pages_array[$key]['settings'][$setting_key]); - } - } - - } - - // Remove parts of the Export UI - if ( OT_SHOW_SETTINGS_EXPORT == false ) { - - foreach( $page['settings'] as $setting_key => $setting ) { - if ( $setting['section'] == 'export' && in_array( $setting['id'], array('export_settings_file_text', 'export_settings_text' ) ) ) { - unset($ot_register_pages_array[$key]['settings'][$setting_key]); - } - } - - } - - // Remove the Layouts UI - if ( OT_SHOW_NEW_LAYOUT == false ) { - - foreach( $page['sections'] as $section_key => $section ) { - if ( $section['id'] == 'layouts' ) { - unset($ot_register_pages_array[$key]['sections'][$section_key]); - } - } - - foreach( $page['settings'] as $setting_key => $setting ) { - if ( $setting['section'] == 'layouts' ) { - unset($ot_register_pages_array[$key]['settings'][$setting_key]); - } - } - - } - - } - - // Remove the Documentation UI. - if ( OT_SHOW_DOCS == false && $page['id'] == 'documentation' ) { - - unset( $ot_register_pages_array[$key] ); - - } - - } - - $ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array ); - - // Register the pages. - ot_register_settings( array( - array( - 'id' => ot_settings_id(), - 'pages' => $ot_register_pages_array - ) - ) - ); - - } - -} - -/** - * Runs directly after the Theme Options are save. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_after_theme_options_save' ) ) { - - function ot_after_theme_options_save() { - - $page = isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : ''; - $updated = isset( $_REQUEST['settings-updated'] ) && $_REQUEST['settings-updated'] == 'true' ? true : false; - - /* only execute after the theme options are saved */ - if ( apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) == $page && $updated ) { - - /* grab a copy of the theme options */ - $options = get_option( ot_options_id() ); - - /* execute the action hook and pass the theme options to it */ - do_action( 'ot_after_theme_options_save', $options ); - - } - - } - -} - -/** - * Validate the options by type before saving. - * - * This function will run on only some of the option types - * as all of them don't need to be validated, just the - * ones users are going to input data into; because they - * can't be trusted. - * - * @param mixed Setting value - * @param string Setting type - * @param string Setting field ID - * @param string WPML field ID - * @return mixed - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_validate_setting' ) ) { - - function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { - - /* exit early if missing data */ - if ( ! $input || ! $type || ! $field_id ) - return $input; - - $input = apply_filters( 'ot_validate_setting', $input, $type, $field_id ); - - /* WPML Register and Unregister strings */ - if ( ! empty( $wmpl_id ) ) { - - /* Allow filtering on the WPML option types */ - $single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ); - - if ( in_array( $type, $single_string_types ) ) { - - if ( ! empty( $input ) ) { - - ot_wpml_register_string( $wmpl_id, $input ); - - } else { - - ot_wpml_unregister_string( $wmpl_id ); - - } - - } - - } - - if ( 'background' == $type ) { - - $input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id ); - - $input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id ); - - // Loop over array and check for values - foreach( (array) $input as $key => $value ) { - if ( ! empty( $value ) ) { - $has_value = true; - } - } - - // No value; set to empty - if ( ! isset( $has_value ) ) { - $input = ''; - } - - } else if ( 'border' == $type ) { - - // Loop over array and set errors or unset key from array. - foreach( $input as $key => $value ) { - - // Validate width - if ( $key == 'width' && ! empty( $value ) && ! is_numeric( $value ) ) { - - $input[$key] = '0'; - - add_settings_error( 'option-tree', 'invalid_border_width', sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), 'width', '' . $field_id . '' ), 'error' ); - - } - - // Validate color - if ( $key == 'color' && ! empty( $value ) ) { - - $input[$key] = ot_validate_setting( $value, 'colorpicker', $field_id ); - - } - - // Unset keys with empty values. - if ( empty( $value ) && strlen( $value ) == 0 ) { - unset( $input[$key] ); - } - - } - - if ( empty( $input ) ) { - $input = ''; - } - - } else if ( 'box-shadow' == $type ) { - - // Validate inset - $input['inset'] = isset( $input['inset'] ) ? 'inset' : ''; - - // Validate offset-x - $input['offset-x'] = ot_validate_setting( $input['offset-x'], 'text', $field_id ); - - // Validate offset-y - $input['offset-y'] = ot_validate_setting( $input['offset-y'], 'text', $field_id ); - - // Validate blur-radius - $input['blur-radius'] = ot_validate_setting( $input['blur-radius'], 'text', $field_id ); - - // Validate spread-radius - $input['spread-radius'] = ot_validate_setting( $input['spread-radius'], 'text', $field_id ); - - // Validate color - $input['color'] = ot_validate_setting( $input['color'], 'colorpicker', $field_id ); - - // Unset keys with empty values. - foreach( $input as $key => $value ) { - if ( empty( $value ) && strlen( $value ) == 0 ) { - unset( $input[$key] ); - } - } - - // Set empty array to empty string. - if ( empty( $input ) ) { - $input = ''; - } - - } else if ( 'colorpicker' == $type ) { - - /* return empty & set error */ - if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) { - - $input = ''; - - add_settings_error( 'option-tree', 'invalid_hex', sprintf( __( 'The %s Colorpicker only allows valid hexadecimal or rgba values.', 'option-tree' ), '' . $field_id . '' ), 'error' ); - - } - - } else if ( 'colorpicker-opacity' == $type ) { - - // Not allowed - if ( is_array( $input ) ) { - $input = ''; - } - - // Validate color - $input = ot_validate_setting( $input, 'colorpicker', $field_id ); - - } else if ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ) ) ) { - - if ( ! current_user_can( 'unfiltered_html' ) && OT_ALLOW_UNFILTERED_HTML == false ) { - - $input = wp_kses_post( $input ); - - } - - } else if ( 'dimension' == $type ) { - - // Loop over array and set error keys or unset key from array. - foreach( $input as $key => $value ) { - if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) { - $errors[] = $key; - } - if ( empty( $value ) && strlen( $value ) == 0 ) { - unset( $input[$key] ); - } - } - - /* return 0 & set error */ - if ( isset( $errors ) ) { - - foreach( $errors as $error ) { - - $input[$error] = '0'; - - add_settings_error( 'option-tree', 'invalid_dimension_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '' . $error . '', '' . $field_id . '' ), 'error' ); - - } - - } - - if ( empty( $input ) ) { - $input = ''; - } - - } else if ( 'google-fonts' == $type ) { - - unset($input['%key%']); - - // Loop over array and check for values - if ( is_array( $input ) && ! empty( $input ) ) { - $input = array_values( $input ); - } - - // No value; set to empty - if ( empty( $input ) ) { - $input = ''; - } - - } else if ( 'link-color' == $type ) { - - // Loop over array and check for values - if ( is_array( $input ) && ! empty( $input ) ) { - foreach( $input as $key => $value ) { - if ( ! empty( $value ) ) { - $input[$key] = ot_validate_setting( $input[$key], 'colorpicker', $field_id . '-' . $key ); - $has_value = true; - } - } - } - - // No value; set to empty - if ( ! isset( $has_value ) ) { - $input = ''; - } - - } else if ( 'measurement' == $type ) { - - $input[0] = sanitize_text_field( $input[0] ); - - // No value; set to empty - if ( empty( $input[0] ) && strlen( $input[0] ) == 0 && empty( $input[1] ) ) { - $input = ''; - } - - } else if ( 'spacing' == $type ) { - - // Loop over array and set error keys or unset key from array. - foreach( $input as $key => $value ) { - if ( ! empty( $value ) && ! is_numeric( $value ) && $key !== 'unit' ) { - $errors[] = $key; - } - if ( empty( $value ) && strlen( $value ) == 0 ) { - unset( $input[$key] ); - } - } - - /* return 0 & set error */ - if ( isset( $errors ) ) { - - foreach( $errors as $error ) { - - $input[$error] = '0'; - - add_settings_error( 'option-tree', 'invalid_spacing_' . $error, sprintf( __( 'The %s input field for %s only allows numeric values.', 'option-tree' ), '' . $error . '', '' . $field_id . '' ), 'error' ); - - } - - } - - if ( empty( $input ) ) { - $input = ''; - } - - } else if ( 'typography' == $type && isset( $input['font-color'] ) ) { - - $input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id ); - - // Loop over array and check for values - foreach( $input as $key => $value ) { - if ( ! empty( $value ) ) { - $has_value = true; - } - } - - // No value; set to empty - if ( ! isset( $has_value ) ) { - $input = ''; - } - - } else if ( 'upload' == $type ) { - - if( filter_var( $input, FILTER_VALIDATE_INT ) === FALSE ) { - $input = esc_url_raw( $input ); - } - - } else if ( 'gallery' == $type ) { - - $input = trim( $input ); - - } else if ( 'social-links' == $type ) { - - // Loop over array and check for values, plus sanitize the text field - foreach( (array) $input as $key => $value ) { - if ( ! empty( $value ) && is_array( $value ) ) { - foreach( (array) $value as $item_key => $item_value ) { - if ( ! empty( $item_value ) ) { - $has_value = true; - $input[$key][$item_key] = sanitize_text_field( $item_value ); - } - } - } - } - - // No value; set to empty - if ( ! isset( $has_value ) ) { - $input = ''; - } - - } - - $input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id ); - - return $input; - - } - -} - -/** - * Setup the default admin styles - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_admin_styles' ) ) { - - function ot_admin_styles() { - global $wp_styles, $post; - - /* execute styles before actions */ - do_action( 'ot_admin_styles_before' ); - - /* load WP colorpicker */ - wp_enqueue_style( 'wp-color-picker' ); - - /* load admin styles */ - wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION ); - - /* load the RTL stylesheet */ - $wp_styles->add_data( 'ot-admin-css','rtl', true ); - - /* Remove styles added by the Easy Digital Downloads plugin */ - if ( isset( $post->post_type ) && $post->post_type == 'post' ) - wp_dequeue_style( 'jquery-ui-css' ); - - /** - * Filter the screen IDs used to dequeue `jquery-ui-css`. - * - * @since 2.5.0 - * - * @param array $screen_ids An array of screen IDs. - */ - $screen_ids = apply_filters( 'ot_dequeue_jquery_ui_css_screen_ids', array( - 'toplevel_page_ot-settings', - 'optiontree_page_ot-documentation', - 'appearance_page_ot-theme-options' - ) ); - - /* Remove styles added by the WP Review plugin and any custom pages added through filtering */ - if ( in_array( get_current_screen()->id, $screen_ids ) ) { - wp_dequeue_style( 'plugin_name-admin-ui-css' ); - wp_dequeue_style( 'jquery-ui-css' ); - } - - /* execute styles after actions */ - do_action( 'ot_admin_styles_after' ); - - } - -} - -/** - * Setup the default admin scripts - * - * @uses add_thickbox() Include Thickbox for file uploads - * @uses wp_enqueue_script() Add OptionTree scripts - * @uses wp_localize_script() Used to include arbitrary Javascript data - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_admin_scripts' ) ) { - - function ot_admin_scripts() { - - /* execute scripts before actions */ - do_action( 'ot_admin_scripts_before' ); - - if ( function_exists( 'wp_enqueue_media' ) ) { - /* WP 3.5 Media Uploader */ - wp_enqueue_media(); - } else { - /* Legacy Thickbox */ - add_thickbox(); - } - - /* load jQuery-ui slider */ - wp_enqueue_script( 'jquery-ui-slider' ); - - /* load jQuery-ui datepicker */ - wp_enqueue_script( 'jquery-ui-datepicker' ); - - /* load WP colorpicker */ - wp_enqueue_script( 'wp-color-picker' ); - - /* load Ace Editor for CSS Editing */ - wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3' ); - - /* load jQuery UI timepicker addon */ - wp_enqueue_script( 'jquery-ui-timepicker', OT_URL . 'assets/js/vendor/jquery/jquery-ui-timepicker.js', array( 'jquery', 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.4.3' ); - - /* load the post formats */ - if ( OT_META_BOXES == true && OT_POST_FORMATS == true ) { - wp_enqueue_script( 'ot-postformats', OT_URL . 'assets/js/ot-postformats.js', array( 'jquery' ), '1.0.1' ); - } - - /* load all the required scripts */ - wp_enqueue_script( 'ot-admin-js', OT_URL . 'assets/js/ot-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-slider', 'wp-color-picker', 'ace-editor', 'jquery-ui-datepicker', 'jquery-ui-timepicker' ), OT_VERSION ); - - /* create localized JS array */ - $localized_array = array( - 'ajax' => admin_url( 'admin-ajax.php' ), - 'nonce' => wp_create_nonce( 'option_tree' ), - 'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ), - 'remove_media_text' => __( 'Remove Media', 'option-tree' ), - 'reset_agree' => __( 'Are you sure you want to reset back to the defaults?', 'option-tree' ), - 'remove_no' => __( 'You can\'t remove this! But you can edit the values.', 'option-tree' ), - 'remove_agree' => __( 'Are you sure you want to remove this?', 'option-tree' ), - 'activate_layout_agree' => __( 'Are you sure you want to activate this layout?', 'option-tree' ), - 'setting_limit' => __( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ), - 'delete' => __( 'Delete Gallery', 'option-tree' ), - 'edit' => __( 'Edit Gallery', 'option-tree' ), - 'create' => __( 'Create Gallery', 'option-tree' ), - 'confirm' => __( 'Are you sure you want to delete this Gallery?', 'option-tree' ), - 'date_current' => __( 'Today', 'option-tree' ), - 'date_time_current' => __( 'Now', 'option-tree' ), - 'date_close' => __( 'Close', 'option-tree' ), - 'replace' => __( 'Featured Image', 'option-tree' ), - 'with' => __( 'Image', 'option-tree' ) - ); - - /* localized script attached to 'option_tree' */ - wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array ); - - /* execute scripts after actions */ - do_action( 'ot_admin_scripts_after' ); - - } - -} - -/** - * Returns the ID of a custom post type by post_title. - * - * @uses get_results() - * - * @return int - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_get_media_post_ID' ) ) { - - function ot_get_media_post_ID() { - - // Option ID - $option_id = 'ot_media_post_ID'; - - // Get the media post ID - $post_ID = get_option( $option_id, false ); - - // Add $post_ID to the DB - if ( $post_ID === false || empty( $post_ID ) ) { - global $wpdb; - - // Get the media post ID - $post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" ); - - // Add to the DB - if ( $post_ID !== null ) - update_option( $option_id, $post_ID ); - - } - - return $post_ID; - - } - -} - -/** - * Register custom post type & create the media post used to attach images. - * - * @uses get_results() - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_create_media_post' ) ) { - - function ot_create_media_post() { - - $regsiter_post_type = 'register_' . 'post_type'; - $regsiter_post_type( 'option-tree', array( - 'labels' => array( 'name' => __( 'Option Tree', 'option-tree' ) ), - 'public' => false, - 'show_ui' => false, - 'capability_type' => 'post', - 'exclude_from_search' => true, - 'hierarchical' => false, - 'rewrite' => false, - 'supports' => array( 'title', 'editor' ), - 'can_export' => false, - 'show_in_nav_menus' => false - ) ); - - /* look for custom page */ - $post_id = ot_get_media_post_ID(); - - /* no post exists */ - if ( $post_id == 0 ) { - - /* create post object */ - $_p = array(); - $_p['post_title'] = 'Media'; - $_p['post_name'] = 'media'; - $_p['post_status'] = 'private'; - $_p['post_type'] = 'option-tree'; - $_p['comment_status'] = 'closed'; - $_p['ping_status'] = 'closed'; - - /* insert the post into the database */ - wp_insert_post( $_p ); - - } - - } - -} - -/** - * Setup default settings array. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_default_settings' ) ) { - - function ot_default_settings() { - global $wpdb; - - if ( ! get_option( ot_settings_id() ) ) { - - $section_count = 0; - $settings_count = 0; - $settings = array(); - $table_name = $wpdb->prefix . 'option_tree'; - - if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $table_name ) ) == $table_name && $old_settings = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY item_sort ASC" ) ) { - - foreach ( $old_settings as $setting ) { - - /* heading is a section now */ - if ( $setting->item_type == 'heading' ) { - - /* add section to the sections array */ - $settings['sections'][$section_count]['id'] = $setting->item_id; - $settings['sections'][$section_count]['title'] = $setting->item_title; - - /* save the last section id to use in creating settings */ - $section = $setting->item_id; - - /* increment the section count */ - $section_count++; - - } else { - - /* add setting to the settings array */ - $settings['settings'][$settings_count]['id'] = $setting->item_id; - $settings['settings'][$settings_count]['label'] = $setting->item_title; - $settings['settings'][$settings_count]['desc'] = $setting->item_desc; - $settings['settings'][$settings_count]['section'] = $section; - $settings['settings'][$settings_count]['type'] = ot_map_old_option_types( $setting->item_type ); - $settings['settings'][$settings_count]['std'] = ''; - $settings['settings'][$settings_count]['class'] = ''; - - /* textarea rows */ - $rows = ''; - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) { - if ( (int) $setting->item_options > 0 ) { - $rows = (int) $setting->item_options; - } else { - $rows = 15; - } - } - $settings['settings'][$settings_count]['rows'] = $rows; - - /* post type */ - $post_type = ''; - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) { - if ( '' != $setting->item_options ) { - $post_type = $setting->item_options; - } else { - $post_type = 'post'; - } - } - $settings['settings'][$settings_count]['post_type'] = $post_type; - - /* choices */ - $choices = array(); - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) { - if ( '' != $setting->item_options ) { - $choices = ot_convert_string_to_array( $setting->item_options ); - } - } - $settings['settings'][$settings_count]['choices'] = $choices; - - $settings_count++; - } - - } - - /* make sure each setting has a section just incase */ - if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) { - foreach( $settings['settings'] as $k => $setting ) { - if ( '' == $setting['section'] ) { - $settings['settings'][$k]['section'] = $settings['sections'][0]['id']; - } - } - } - - } - - /* if array if not properly formed create fallback settings array */ - if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) { - - $settings = array( - 'sections' => array( - array( - 'id' => 'general', - 'title' => __( 'General', 'option-tree' ) - ) - ), - 'settings' => array( - array( - 'id' => 'sample_text', - 'label' => __( 'Sample Text Field Label', 'option-tree' ), - 'desc' => __( 'Description for the sample text field.', 'option-tree' ), - 'section' => 'general', - 'type' => 'text', - 'std' => '', - 'class' => '', - 'rows' => '', - 'post_type' => '', - 'choices' => array() - ) - ) - ); - - } - - /* update the settings array */ - update_option( ot_settings_id(), $settings ); - - /* get option tree array */ - $options = get_option( ot_options_id() ); - - /* validate options */ - if ( is_array( $options ) ) { - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $options[$setting['id']] ) ) { - - $content = ot_stripslashes( $options[$setting['id']] ); - - $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - - } - - } - - /* execute the action hook and pass the theme options to it */ - do_action( 'ot_before_theme_options_save', $options ); - - /* update the option tree array */ - update_option( ot_options_id(), $options ); - - } - - } - - } - -} - -/** - * Helper function to update the CSS option type after save. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_save_css' ) ) { - - function ot_save_css( $options ) { - - /* grab a copy of the settings */ - $settings = get_option( ot_settings_id() ); - - /* has settings */ - if ( isset( $settings['settings'] ) ) { - - /* loop through sections and insert CSS when needed */ - foreach( $settings['settings'] as $k => $setting ) { - - /* is the CSS option type */ - if ( isset( $setting['type'] ) && 'css' == $setting['type'] ) { - - /* insert CSS into dynamic.css */ - if ( isset( $options[$setting['id']] ) && '' !== $options[$setting['id']] ) { - - ot_insert_css_with_markers( $setting['id'], $options[$setting['id']] ); - - /* remove old CSS from dynamic.css */ - } else { - - ot_remove_old_css( $setting['id'] ); - - } - - } - - } - - } - - } - -} - -/** - * Helper function to load filters for XML mime type. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_add_xml_to_upload_filetypes' ) ) { - - function ot_add_xml_to_upload_filetypes() { - - add_filter( 'upload_mimes', 'ot_upload_mimes' ); - add_filter( 'wp_mime_type_icon', 'ot_xml_mime_type_icon', 10, 2 ); - - } - -} - -/** - * Filter 'upload_mimes' and add xml. - * - * @param array $mimes An array of valid upload mime types - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_upload_mimes' ) ) { - - function ot_upload_mimes( $mimes ) { - - $mimes['xml'] = 'application/xml'; - - return $mimes; - - } - -} - -/** - * Filters 'wp_mime_type_icon' and have xml display as a document. - * - * @param string $icon The mime icon - * @param string $mime The mime type - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_xml_mime_type_icon' ) ) { - - function ot_xml_mime_type_icon( $icon, $mime ) { - - if ( $mime == 'application/xml' || $mime == 'text/xml' ) - return wp_mime_type_icon( 'document' ); - - return $icon; - - } - -} - -/** - * Import before the screen is displayed. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_import' ) ) { - - function ot_import() { - - /* check and verify import xml nonce */ - if ( isset( $_POST['import_xml_nonce'] ) && wp_verify_nonce( $_POST['import_xml_nonce'], 'import_xml_form' ) ) { - - /* import input value */ - $file = isset( $_POST['import_xml'] ) ? esc_url( $_POST['import_xml'] ) : ''; - - /* validate xml file */ - if ( preg_match( "/(.xml)$/i", $file ) && class_exists( 'SimpleXMLElement' ) ) { - - $settings = ot_import_xml( $file ); - - } - - /* default message */ - $message = 'failed'; - - /* cleanup, save, & show success message */ - if ( isset( $settings ) && ! empty( $settings ) ) { - - /* delete file */ - if ( $file ) { - global $wpdb; - $attachmentid = $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$file'" ); - wp_delete_attachment( $attachmentid, true ); - } - - /* update settings */ - update_option( ot_settings_id(), $settings ); - - /* set message */ - $message = 'success'; - - } - - /* redirect */ - wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-xml', 'message' => $message ), $_POST['_wp_http_referer'] ) ) ); - exit; - - } - - /* check and verify import settings nonce */ - if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) { - - /* textarea value */ - $textarea = isset( $_POST['import_settings'] ) ? unserialize( ot_decode( $_POST['import_settings'] ) ) : ''; - - /* default message */ - $message = 'failed'; - - /* is array: save & show success message */ - if ( is_array( $textarea ) ) { - update_option( ot_settings_id(), $textarea ); - $message = 'success'; - } - - /* redirect */ - wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) ); - exit; - - } - - /* check and verify import theme options data nonce */ - if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) { - - /* default message */ - $message = 'failed'; - - /* textarea value */ - $options = isset( $_POST['import_data'] ) ? unserialize( ot_decode( $_POST['import_data'] ) ) : ''; - - /* get settings array */ - $settings = get_option( ot_settings_id() ); - - /* has options */ - if ( is_array( $options ) ) { - - /* validate options */ - if ( is_array( $settings ) ) { - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $options[$setting['id']] ) ) { - - $content = ot_stripslashes( $options[$setting['id']] ); - - $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - - } - - } - - } - - /* execute the action hook and pass the theme options to it */ - do_action( 'ot_before_theme_options_save', $options ); - - /* update the option tree array */ - update_option( ot_options_id(), $options ); - - $message = 'success'; - - } - - /* redirect accordingly */ - wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-data', 'message' => $message ), $_POST['_wp_http_referer'] ) ) ); - exit; - - } - - /* check and verify import layouts nonce */ - if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) { - - /* default message */ - $message = 'failed'; - - /* textarea value */ - $layouts = isset( $_POST['import_layouts'] ) ? unserialize( ot_decode( $_POST['import_layouts'] ) ) : ''; - - /* get settings array */ - $settings = get_option( ot_settings_id() ); - - /* has layouts */ - if ( is_array( $layouts ) ) { - - /* validate options */ - if ( is_array( $settings ) ) { - - foreach( $layouts as $key => $value ) { - - if ( $key == 'active_layout' ) - continue; - - $options = unserialize( ot_decode( $value ) ); - - foreach( $settings['settings'] as $setting ) { - - if ( isset( $options[$setting['id']] ) ) { - - $content = ot_stripslashes( $options[$setting['id']] ); - - $options[$setting['id']] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - - } - - } - - $layouts[$key] = ot_encode( serialize( $options ) ); - - } - - } - - /* update the option tree array */ - if ( isset( $layouts['active_layout'] ) ) { - - $new_options = unserialize( ot_decode( $layouts[$layouts['active_layout']] ) ); - - /* execute the action hook and pass the theme options to it */ - do_action( 'ot_before_theme_options_save', $new_options ); - - update_option( ot_options_id(), $new_options ); - - } - - /* update the option tree layouts array */ - update_option( ot_layouts_id(), $layouts ); - - $message = 'success'; - - } - - /* redirect accordingly */ - wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'import-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) ) ); - exit; - - } - - return false; - - } - -} - -/** - * Export before the screen is displayed. - * - * @return void - * - * @access public - * @since 2.0.8 - */ -if ( ! function_exists( 'ot_export' ) ) { - - function ot_export() { - - /* check and verify export settings file nonce */ - if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) { - - ot_export_php_settings_array(); - - } - - } - -} - -/** - * Reusable XMl import helper function. - * - * @param string $file The path to the file. - * @return mixed False or an array of settings. - * - * @access public - * @since 2.0.8 - */ -if ( ! function_exists( 'ot_import_xml' ) ) { - - function ot_import_xml( $file ) { - - $get_data = wp_remote_get( $file ); - - if ( is_wp_error( $get_data ) ) - return false; - - $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : false; - - if ( $rawdata ) { - - $section_count = 0; - $settings_count = 0; - - $section = ''; - - $settings = array(); - $xml = new SimpleXMLElement( $rawdata ); - - foreach ( $xml->row as $value ) { - - /* heading is a section now */ - if ( $value->item_type == 'heading' ) { - - /* add section to the sections array */ - $settings['sections'][$section_count]['id'] = (string) $value->item_id; - $settings['sections'][$section_count]['title'] = (string) $value->item_title; - - /* save the last section id to use in creating settings */ - $section = (string) $value->item_id; - - /* increment the section count */ - $section_count++; - - } else { - - /* add setting to the settings array */ - $settings['settings'][$settings_count]['id'] = (string) $value->item_id; - $settings['settings'][$settings_count]['label'] = (string) $value->item_title; - $settings['settings'][$settings_count]['desc'] = (string) $value->item_desc; - $settings['settings'][$settings_count]['section'] = $section; - $settings['settings'][$settings_count]['type'] = ot_map_old_option_types( (string) $value->item_type ); - $settings['settings'][$settings_count]['std'] = ''; - $settings['settings'][$settings_count]['class'] = ''; - - /* textarea rows */ - $rows = ''; - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'css', 'javascript', 'textarea' ) ) ) { - if ( (int) $value->item_options > 0 ) { - $rows = (int) $value->item_options; - } else { - $rows = 15; - } - } - $settings['settings'][$settings_count]['rows'] = $rows; - - /* post type */ - $post_type = ''; - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ) ) ) { - if ( '' != (string) $value->item_options ) { - $post_type = (string) $value->item_options; - } else { - $post_type = 'post'; - } - } - $settings['settings'][$settings_count]['post_type'] = $post_type; - - /* choices */ - $choices = array(); - if ( in_array( $settings['settings'][$settings_count]['type'], array( 'checkbox', 'radio', 'select' ) ) ) { - if ( '' != (string) $value->item_options ) { - $choices = ot_convert_string_to_array( (string) $value->item_options ); - } - } - $settings['settings'][$settings_count]['choices'] = $choices; - - $settings_count++; - } - - } - - /* make sure each setting has a section just incase */ - if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) { - foreach( $settings['settings'] as $k => $setting ) { - if ( '' == $setting['section'] ) { - $settings['settings'][$k]['section'] = $settings['sections'][0]['id']; - } - } - } - - return $settings; - - } - - return false; - } - -} - -/** - * Export the Theme Mode theme-options.php - * - * @return attachment - * - * @access public - * @since 2.0.8 - */ -if ( ! function_exists( 'ot_export_php_settings_array' ) ) { - - function ot_export_php_settings_array() { - - $content = ''; - $build_settings = ''; - $contextual_help = ''; - $sections = ''; - $settings = ''; - $option_tree_settings = get_option( ot_settings_id(), array() ); - - // Domain string helper - function ot_I18n_string( $string ) { - if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) { - $domain = str_replace( ' ', '-', trim( $_POST['domain'] ) ); - return "__( '$string', '$domain' )"; - } - return "'$string'"; - } - - header( "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); - header( "Pragma: no-cache "); - header( "Content-Description: File Transfer" ); - header( 'Content-Disposition: attachment; filename="theme-options.php"'); - header( "Content-Type: application/octet-stream"); - header( "Content-Transfer-Encoding: binary" ); - - /* build contextual help content */ - if ( isset( $option_tree_settings['contextual_help']['content'] ) ) { - $help = ''; - foreach( $option_tree_settings['contextual_help']['content'] as $value ) { - $_id = isset( $value['id'] ) ? $value['id'] : ''; - $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' ); - $_content = ot_I18n_string( isset( $value['content'] ) ? html_entity_decode( str_replace( "'", "\'", $value['content'] ) ) : '' ); - $help.= " - array( - 'id' => '$_id', - 'title' => $_title, - 'content' => $_content - ),"; - } - $help = substr_replace( $help, '' , -1 ); - $contextual_help = " - 'content' => array( $help - ),"; - } - - /* build contextual help sidebar */ - if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) { - $contextual_help.= " - 'sidebar' => " . ot_I18n_string( html_entity_decode( str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) ); - } - - /* check that $contexual_help has a value and add to $build_settings */ - if ( '' != $contextual_help ) { - $build_settings.= " - 'contextual_help' => array( $contextual_help - ),"; - } - - /* build sections */ - if ( isset( $option_tree_settings['sections'] ) ) { - foreach( $option_tree_settings['sections'] as $value ) { - $_id = isset( $value['id'] ) ? $value['id'] : ''; - $_title = ot_I18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' ); - $sections.= " - array( - 'id' => '$_id', - 'title' => $_title - ),"; - } - $sections = substr_replace( $sections, '' , -1 ); - } - - /* check that $sections has a value and add to $build_settings */ - if ( '' != $sections ) { - $build_settings.= " - 'sections' => array( $sections - )"; - } - - /* build settings */ - if ( isset( $option_tree_settings['settings'] ) ) { - foreach( $option_tree_settings['settings'] as $value ) { - $_id = isset( $value['id'] ) ? $value['id'] : ''; - $_label = ot_I18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' ); - $_desc = ot_I18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' ); - $_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : ''; - $_type = isset( $value['type'] ) ? $value['type'] : ''; - $_section = isset( $value['section'] ) ? $value['section'] : ''; - $_rows = isset( $value['rows'] ) ? $value['rows'] : ''; - $_post_type = isset( $value['post_type'] ) ? $value['post_type'] : ''; - $_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : ''; - $_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : ''; - $_class = isset( $value['class'] ) ? $value['class'] : ''; - $_condition = isset( $value['condition'] ) ? $value['condition'] : ''; - $_operator = isset( $value['operator'] ) ? $value['operator'] : ''; - - $choices = ''; - if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) { - foreach( $value['choices'] as $choice ) { - $_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : ''; - $_choice_label = ot_I18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' ); - $_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : ''; - $choices.= " - array( - 'value' => '$_choice_value', - 'label' => $_choice_label, - 'src' => '$_choice_src' - ),"; - } - $choices = substr_replace( $choices, '' , -1 ); - $choices = ", - 'choices' => array( $choices - )"; - } - - $std = "'$_std'"; - if ( is_array( $_std ) ) { - $std_array = array(); - foreach( $_std as $_sk => $_sv ) { - $std_array[] = "'$_sk' => '$_sv'"; - } - $std = 'array( -' . implode( ",\n", $std_array ) . ' - )'; - } - - $setting_settings = ''; - if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) { - foreach( $value['settings'] as $setting ) { - $_setting_id = isset( $setting['id'] ) ? $setting['id'] : ''; - $_setting_label = ot_I18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' ); - $_setting_desc = ot_I18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' ); - $_setting_std = isset( $setting['std'] ) ? $setting['std'] : ''; - $_setting_type = isset( $setting['type'] ) ? $setting['type'] : ''; - $_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : ''; - $_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : ''; - $_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : ''; - $_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : ''; - $_setting_class = isset( $setting['class'] ) ? $setting['class'] : ''; - $_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : ''; - $_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : ''; - - $setting_choices = ''; - if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) { - foreach( $setting['choices'] as $setting_choice ) { - $_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : ''; - $_setting_choice_label = ot_I18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' ); - $_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : ''; - $setting_choices.= " - array( - 'value' => '$_setting_choice_value', - 'label' => $_setting_choice_label, - 'src' => '$_setting_choice_src' - ),"; - } - $setting_choices = substr_replace( $setting_choices, '' , -1 ); - $setting_choices = ", - 'choices' => array( $setting_choices - )"; - } - - $setting_std = "'$_setting_std'"; - if ( is_array( $_setting_std ) ) { - $setting_std_array = array(); - foreach( $_setting_std as $_ssk => $_ssv ) { - $setting_std_array[] = "'$_ssk' => '$_ssv'"; - } - $setting_std = 'array( -' . implode( ",\n", $setting_std_array ) . ' - )'; - } - - $setting_settings.= " - array( - 'id' => '$_setting_id', - 'label' => $_setting_label, - 'desc' => $_setting_desc, - 'std' => $setting_std, - 'type' => '$_setting_type', - 'rows' => '$_setting_rows', - 'post_type' => '$_setting_post_type', - 'taxonomy' => '$_setting_taxonomy', - 'min_max_step'=> '$_setting_min_max_step', - 'class' => '$_setting_class', - 'condition' => '$_setting_condition', - 'operator' => '$_setting_operator'$setting_choices - ),"; - } - $setting_settings = substr_replace( $setting_settings, '' , -1 ); - $setting_settings = ", - 'settings' => array( $setting_settings - )"; - } - - $settings.= " - array( - 'id' => '$_id', - 'label' => $_label, - 'desc' => $_desc, - 'std' => $std, - 'type' => '$_type', - 'section' => '$_section', - 'rows' => '$_rows', - 'post_type' => '$_post_type', - 'taxonomy' => '$_taxonomy', - 'min_max_step'=> '$_min_max_step', - 'class' => '$_class', - 'condition' => '$_condition', - 'operator' => '$_operator'$choices$setting_settings - ),"; - } - $settings = substr_replace( $settings, '' , -1 ); - } - - /* check that $sections has a value and add to $build_settings */ - if ( '' != $settings ) { - $build_settings.= ", - 'settings' => array( $settings - )"; - } - - $content.= " $section ) { - - /* remove from array if missing values */ - if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' == $section['title'] && '' == $section['id'] ) ) { - - unset( $settings['sections'][$k] ); - - } else { - - /* validate label */ - if ( '' != $section['title'] ) { - - $settings['sections'][$k]['title'] = wp_kses_post( $section['title'] ); - - } - - /* missing title set to unfiltered ID */ - if ( ! isset( $section['title'] ) || '' == $section['title'] ) { - - $settings['sections'][$k]['title'] = wp_kses_post( $section['id'] ); - - /* missing ID set to title */ - } else if ( ! isset( $section['id'] ) || '' == $section['id'] ) { - - $section['id'] = wp_kses_post( $section['title'] ); - - } - - /* sanitize ID once everything has been checked first */ - $settings['sections'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) ); - - } - - } - - $settings['sections'] = ot_stripslashes( $settings['sections'] ); - - } - - /* validate settings by looping over array as many times as it takes */ - if ( isset( $settings['settings'] ) ) { - - $settings['settings'] = ot_validate_settings_array( $settings['settings'] ); - - } - - /* validate contextual_help */ - if ( isset( $settings['contextual_help']['content'] ) ) { - - /* fix numeric keys since drag & drop will change them */ - $settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] ); - - /* loop through content */ - foreach( $settings['contextual_help']['content'] as $k => $content ) { - - /* remove from array if missing values */ - if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' == $content['title'] && '' == $content['id'] ) ) { - - unset( $settings['contextual_help']['content'][$k] ); - - } else { - - /* validate label */ - if ( '' != $content['title'] ) { - - $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['title'] ); - - } - - /* missing title set to unfiltered ID */ - if ( ! isset( $content['title'] ) || '' == $content['title'] ) { - - $settings['contextual_help']['content'][$k]['title'] = wp_kses_post( $content['id'] ); - - /* missing ID set to title */ - } else if ( ! isset( $content['id'] ) || '' == $content['id'] ) { - - $content['id'] = wp_kses_post( $content['title'] ); - - } - - /* sanitize ID once everything has been checked first */ - $settings['contextual_help']['content'][$k]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) ); - - } - - /* validate textarea description */ - if ( isset( $content['content'] ) ) { - - $settings['contextual_help']['content'][$k]['content'] = wp_kses_post( $content['content'] ); - - } - - } - - } - - /* validate contextual_help sidebar */ - if ( isset( $settings['contextual_help']['sidebar'] ) ) { - - $settings['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] ); - - } - - $settings['contextual_help'] = ot_stripslashes( $settings['contextual_help'] ); - - /* default message */ - $message = 'failed'; - - /* is array: save & show success message */ - if ( is_array( $settings ) ) { - - /* WPML unregister ID's that have been removed */ - if ( function_exists( 'icl_unregister_string' ) ) { - - $current = get_option( ot_settings_id() ); - $options = get_option( ot_options_id() ); - - if ( isset( $current['settings'] ) ) { - - /* Empty ID array */ - $new_ids = array(); - - /* Build the WPML IDs array */ - foreach( $settings['settings'] as $setting ) { - - if ( $setting['id'] ) { - - $new_ids[] = $setting['id']; - - } - - } - - /* Remove missing IDs from WPML */ - foreach( $current['settings'] as $current_setting ) { - - if ( ! in_array( $current_setting['id'], $new_ids ) ) { - - if ( ! empty( $options[$current_setting['id']] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ) ) ) { - - foreach( $options[$current_setting['id']] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key ); - - } - - } - - } else if ( ! empty( $options[$current_setting['id']] ) && $current_setting['type'] == 'social-icons' ) { - - foreach( $options[$current_setting['id']] as $key => $value ) { - - foreach( $value as $ckey => $cvalue ) { - - ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key ); - - } - - } - - } else { - - ot_wpml_unregister_string( $current_setting['id'] ); - - } - - } - - } - - } - - } - - update_option( ot_settings_id(), $settings ); - $message = 'success'; - - } - - /* redirect */ - wp_redirect( esc_url_raw( add_query_arg( array( 'action' => 'save-settings', 'message' => $message ), $_POST['_wp_http_referer'] ) ) ); - exit; - - } - - return false; - - } - -} - -/** - * Validate the settings array before save. - * - * This function will loop over the settings array as many - * times as it takes to validate every sub setting. - * - * @param array $settings The array of settings. - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_validate_settings_array' ) ) { - - function ot_validate_settings_array( $settings = array() ) { - - /* validate settings */ - if ( count( $settings ) > 0 ) { - - /* fix numeric keys since drag & drop will change them */ - $settings = array_values( $settings ); - - /* loop through settings */ - foreach( $settings as $k => $setting ) { - - - /* remove from array if missing values */ - if ( ( ! isset( $setting['label'] ) && ! isset( $setting['id'] ) ) || ( '' == $setting['label'] && '' == $setting['id'] ) ) { - - unset( $settings[$k] ); - - } else { - - /* validate label */ - if ( '' != $setting['label'] ) { - - $settings[$k]['label'] = wp_kses_post( $setting['label'] ); - - } - - /* missing label set to unfiltered ID */ - if ( ! isset( $setting['label'] ) || '' == $setting['label'] ) { - - $settings[$k]['label'] = $setting['id']; - - /* missing ID set to label */ - } else if ( ! isset( $setting['id'] ) || '' == $setting['id'] ) { - - $setting['id'] = wp_kses_post( $setting['label'] ); - - } - - /* sanitize ID once everything has been checked first */ - $settings[$k]['id'] = ot_sanitize_option_id( wp_kses_post( $setting['id'] ) ); - - } - - /* validate description */ - if ( '' != $setting['desc'] ) { - - $settings[$k]['desc'] = wp_kses_post( $setting['desc'] ); - - } - - /* validate choices */ - if ( isset( $setting['choices'] ) ) { - - /* loop through choices */ - foreach( $setting['choices'] as $ck => $choice ) { - - /* remove from array if missing values */ - if ( ( ! isset( $choice['label'] ) && ! isset( $choice['value'] ) ) || ( '' == $choice['label'] && '' == $choice['value'] ) ) { - - unset( $setting['choices'][$ck] ); - - } else { - - /* missing label set to unfiltered ID */ - if ( ! isset( $choice['label'] ) || '' == $choice['label'] ) { - - $setting['choices'][$ck]['label'] = wp_kses_post( $choice['value'] ); - - /* missing value set to label */ - } else if ( ! isset( $choice['value'] ) || '' == $choice['value'] ) { - - $setting['choices'][$ck]['value'] = ot_sanitize_option_id( wp_kses_post( $choice['label'] ) ); - - } - - } - - } - - /* update keys and push new array values */ - $settings[$k]['choices'] = array_values( $setting['choices'] ); - - } - - /* validate sub settings */ - if ( isset( $setting['settings'] ) ) { - - $settings[$k]['settings'] = ot_validate_settings_array( $setting['settings'] ); - - } - - } - - } - - /* return array but strip those damn slashes out first!!! */ - return ot_stripslashes( $settings ); - - } - -} - -/** - * Save layouts array before the screen is displayed. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_modify_layouts' ) ) { - - function ot_modify_layouts() { - - /* check and verify modify layouts nonce */ - if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) { - - /* previous layouts value */ - $option_tree_layouts = get_option( ot_layouts_id() ); - - /* new layouts value */ - $layouts = isset( $_POST[ot_layouts_id()] ) ? $_POST[ot_layouts_id()] : ''; - - /* rebuild layout array */ - $rebuild = array(); - - /* validate layouts */ - if ( is_array( $layouts ) && ! empty( $layouts ) ) { - - /* setup active layout */ - if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) { - $rebuild['active_layout'] = $layouts['active_layout']; - } - - /* add new and overwrite active layout */ - if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) { - $rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] ); - $rebuild[$rebuild['active_layout']] = ot_encode( serialize( get_option( ot_options_id() ) ) ); - } - - $first_layout = ''; - - /* loop through layouts */ - foreach( $layouts as $key => $layout ) { - - /* skip over active layout key */ - if ( $key == 'active_layout' ) - continue; - - /* check if the key exists then set value */ - if ( isset( $option_tree_layouts[$key] ) && ! empty( $option_tree_layouts[$key] ) ) { - $rebuild[$key] = $option_tree_layouts[$key]; - if ( '' == $first_layout ) { - $first_layout = $key; - } - } - - } - - if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[$rebuild['active_layout']] ) && ! empty( $first_layout ) ) { - $rebuild['active_layout'] = $first_layout; - } - - } - - /* default message */ - $message = 'failed'; - - /* is array: save & show success message */ - if ( count( $rebuild ) > 1 ) { - - /* rebuild the theme options */ - $rebuild_option_tree = unserialize( ot_decode( $rebuild[$rebuild['active_layout']] ) ); - if ( is_array( $rebuild_option_tree ) ) { - - /* execute the action hook and pass the theme options to it */ - do_action( 'ot_before_theme_options_save', $rebuild_option_tree ); - - update_option( ot_options_id(), $rebuild_option_tree ); - - } - - /* rebuild the layouts */ - update_option( ot_layouts_id(), $rebuild ); - - /* change message */ - $message = 'success'; - - } else if ( count( $rebuild ) <= 1 ) { - - /* delete layouts option */ - delete_option( ot_layouts_id() ); - - /* change message */ - $message = 'deleted'; - - } - - /* redirect */ - if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) ) { - $query_args = esc_url_raw( add_query_arg( array( 'settings-updated' => 'layout' ), remove_query_arg( array( 'action', 'message' ), $_POST['_wp_http_referer'] ) ) ); - } else { - $query_args = esc_url_raw( add_query_arg( array( 'action' => 'save-layouts', 'message' => $message ), $_POST['_wp_http_referer'] ) ); - } - wp_redirect( $query_args ); - exit; - - } - - return false; - - } - -} - -/** - * Helper function to display alert messages. - * - * @param array Page array - * @return mixed - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_alert_message' ) ) { - - function ot_alert_message( $page = array() ) { - - if ( empty( $page ) ) - return false; - - $before = apply_filters( 'ot_before_page_messages', '', $page ); - - if ( $before ) { - return $before; - } - - $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : ''; - $message = isset( $_REQUEST['message'] ) ? $_REQUEST['message'] : ''; - $updated = isset( $_REQUEST['settings-updated'] ) ? $_REQUEST['settings-updated'] : ''; - - if ( $action == 'save-settings' ) { - - if ( $message == 'success' ) { - - return '

      ' . __( 'Settings updated.', 'option-tree' ) . '

      '; - - } else if ( $message == 'failed' ) { - - return '

      ' . __( 'Settings could not be saved.', 'option-tree' ) . '

      '; - - } - - } else if ( $action == 'import-xml' || $action == 'import-settings' ) { - - if ( $message == 'success' ) { - - return '

      ' . __( 'Settings Imported.', 'option-tree' ) . '

      '; - - } else if ( $message == 'failed' ) { - - return '

      ' . __( 'Settings could not be imported.', 'option-tree' ) . '

      '; - - } - } else if ( $action == 'import-data' ) { - - if ( $message == 'success' ) { - - return '

      ' . __( 'Data Imported.', 'option-tree' ) . '

      '; - - } else if ( $message == 'failed' ) { - - return '

      ' . __( 'Data could not be imported.', 'option-tree' ) . '

      '; - - } - - } else if ( $action == 'import-layouts' ) { - - if ( $message == 'success' ) { - - return '

      ' . __( 'Layouts Imported.', 'option-tree' ) . '

      '; - - } else if ( $message == 'failed' ) { - - return '

      ' . __( 'Layouts could not be imported.', 'option-tree' ) . '

      '; - - } - - } else if ( $action == 'save-layouts' ) { - - if ( $message == 'success' ) { - - return '

      ' . __( 'Layouts Updated.', 'option-tree' ) . '

      '; - - } else if ( $message == 'failed' ) { - - return '

      ' . __( 'Layouts could not be updated.', 'option-tree' ) . '

      '; - - } else if ( $message == 'deleted' ) { - - return '

      ' . __( 'Layouts have been deleted.', 'option-tree' ) . '

      '; - - } - - } else if ( $updated == 'layout' ) { - - return '

      ' . __( 'Layout activated.', 'option-tree' ) . '

      '; - - } else if ( $action == 'reset' ) { - - return '

      ' . $page['reset_message'] . '

      '; - - } - - do_action( 'ot_custom_page_messages', $page ); - - if ( $updated == 'true' ) { - - return '

      ' . $page['updated_message'] . '

      '; - - } - - return false; - - } - -} - -/** - * Setup the default option types. - * - * The returned option types are filterable so you can add your own. - * This is not a task for a beginner as you'll need to add the function - * that displays the option to the user and validate the saved data. - * - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_option_types_array' ) ) { - - function ot_option_types_array() { - - return apply_filters( 'ot_option_types_array', array( - 'background' => __('Background', 'option-tree'), - 'border' => __('Border', 'option-tree'), - 'box-shadow' => __('Box Shadow', 'option-tree'), - 'category-checkbox' => __('Category Checkbox', 'option-tree'), - 'category-select' => __('Category Select', 'option-tree'), - 'checkbox' => __('Checkbox', 'option-tree'), - 'colorpicker' => __('Colorpicker', 'option-tree'), - 'colorpicker-opacity' => __('Colorpicker Opacity', 'option-tree'), - 'css' => __('CSS', 'option-tree'), - 'custom-post-type-checkbox' => __('Custom Post Type Checkbox', 'option-tree'), - 'custom-post-type-select' => __('Custom Post Type Select', 'option-tree'), - 'date-picker' => __('Date Picker', 'option-tree'), - 'date-time-picker' => __('Date Time Picker', 'option-tree'), - 'dimension' => __('Dimension', 'option-tree'), - 'gallery' => __('Gallery', 'option-tree'), - 'google-fonts' => __('Google Fonts', 'option-tree'), - 'javascript' => __('JavaScript', 'option-tree'), - 'link-color' => __('Link Color', 'option-tree'), - 'list-item' => __('List Item', 'option-tree'), - 'measurement' => __('Measurement', 'option-tree'), - 'numeric-slider' => __('Numeric Slider', 'option-tree'), - 'on-off' => __('On/Off', 'option-tree'), - 'page-checkbox' => __('Page Checkbox', 'option-tree'), - 'page-select' => __('Page Select', 'option-tree'), - 'post-checkbox' => __('Post Checkbox', 'option-tree'), - 'post-select' => __('Post Select', 'option-tree'), - 'radio' => __('Radio', 'option-tree'), - 'radio-image' => __('Radio Image', 'option-tree'), - 'select' => __('Select', 'option-tree'), - 'sidebar-select' => __('Sidebar Select', 'option-tree'), - 'slider' => __('Slider', 'option-tree'), - 'social-links' => __('Social Links', 'option-tree'), - 'spacing' => __('Spacing', 'option-tree'), - 'tab' => __('Tab', 'option-tree'), - 'tag-checkbox' => __('Tag Checkbox', 'option-tree'), - 'tag-select' => __('Tag Select', 'option-tree'), - 'taxonomy-checkbox' => __('Taxonomy Checkbox', 'option-tree'), - 'taxonomy-select' => __('Taxonomy Select', 'option-tree'), - 'text' => __('Text', 'option-tree'), - 'textarea' => __('Textarea', 'option-tree'), - 'textarea-simple' => __('Textarea Simple', 'option-tree'), - 'textblock' => __('Textblock', 'option-tree'), - 'textblock-titled' => __('Textblock Titled', 'option-tree'), - 'typography' => __('Typography', 'option-tree'), - 'upload' => __('Upload', 'option-tree') - ) ); - - } -} - -/** - * Map old option types for rebuilding XML and Table data. - * - * @param string $type The old option type - * @return string The new option type - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_map_old_option_types' ) ) { - - function ot_map_old_option_types( $type = '' ) { - - if ( ! $type ) - return 'text'; - - $types = array( - 'background' => 'background', - 'category' => 'category-select', - 'categories' => 'category-checkbox', - 'checkbox' => 'checkbox', - 'colorpicker' => 'colorpicker', - 'css' => 'css', - 'custom_post' => 'custom-post-type-select', - 'custom_posts' => 'custom-post-type-checkbox', - 'input' => 'text', - 'image' => 'upload', - 'measurement' => 'measurement', - 'page' => 'page-select', - 'pages' => 'page-checkbox', - 'post' => 'post-select', - 'posts' => 'post-checkbox', - 'radio' => 'radio', - 'select' => 'select', - 'slider' => 'slider', - 'tag' => 'tag-select', - 'tags' => 'tag-checkbox', - 'textarea' => 'textarea', - 'textblock' => 'textblock', - 'typography' => 'typography', - 'upload' => 'upload' - ); - - if ( isset( $types[$type] ) ) - return $types[$type]; - - return false; - - } -} - -/** - * Filters the typography font-family to add Google fonts dynamically. - * - * @param array $families An array of all recognized font families. - * @param string $field_id ID of the feild being filtered. - * @return array - * - * @access public - * @since 2.5.0 - */ -function ot_google_font_stack( $families, $field_id ) { - - $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); - $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); - - if ( ! empty( $ot_set_google_fonts ) ) { - foreach( $ot_set_google_fonts as $id => $sets ) { - foreach( $sets as $value ) { - $family = isset( $value['family'] ) ? $value['family'] : ''; - if ( $family && isset( $ot_google_fonts[$family] ) ) { - $spaces = explode(' ', $ot_google_fonts[$family]['family'] ); - $font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[$family]['family'] . '"': $ot_google_fonts[$family]['family']; - $families[$family] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id ); - } - } - } - } - - return $families; -} -add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 ); - -/** - * Recognized font families - * - * Returns an array of all recognized font families. - * Keys are intended to be stored in the database - * while values are ready for display in html. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_font_families' ) ) { - - function ot_recognized_font_families( $field_id = '' ) { - - $families = array( - 'arial' => 'Arial', - 'georgia' => 'Georgia', - 'helvetica' => 'Helvetica', - 'palatino' => 'Palatino', - 'tahoma' => 'Tahoma', - 'times' => '"Times New Roman", sans-serif', - 'trebuchet' => 'Trebuchet', - 'verdana' => 'Verdana' - ); - - return apply_filters( 'ot_recognized_font_families', $families, $field_id ); - - } - -} - -/** - * Recognized font sizes - * - * Returns an array of all recognized font sizes. - * - * @uses apply_filters() - * - * @param string $field_id ID that's passed to the filters. - * @return array - * - * @access public - * @since 2.0.12 - */ -if ( ! function_exists( 'ot_recognized_font_sizes' ) ) { - - function ot_recognized_font_sizes( $field_id ) { - - $range = ot_range( - apply_filters( 'ot_font_size_low_range', 0, $field_id ), - apply_filters( 'ot_font_size_high_range', 150, $field_id ), - apply_filters( 'ot_font_size_range_interval', 1, $field_id ) - ); - - $unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id ); - - foreach( $range as $k => $v ) { - $range[$k] = $v . $unit; - } - - return apply_filters( 'ot_recognized_font_sizes', $range, $field_id ); - } - -} - -/** - * Recognized font styles - * - * Returns an array of all recognized font styles. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_font_styles' ) ) { - - function ot_recognized_font_styles( $field_id = '' ) { - - return apply_filters( 'ot_recognized_font_styles', array( - 'normal' => 'Normal', - 'italic' => 'Italic', - 'oblique' => 'Oblique', - 'inherit' => 'Inherit' - ), $field_id ); - - } - -} - -/** - * Recognized font variants - * - * Returns an array of all recognized font variants. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_font_variants' ) ) { - - function ot_recognized_font_variants( $field_id = '' ) { - - return apply_filters( 'ot_recognized_font_variants', array( - 'normal' => 'Normal', - 'small-caps' => 'Small Caps', - 'inherit' => 'Inherit' - ), $field_id ); - - } - -} - -/** - * Recognized font weights - * - * Returns an array of all recognized font weights. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_font_weights' ) ) { - - function ot_recognized_font_weights( $field_id = '' ) { - - return apply_filters( 'ot_recognized_font_weights', array( - 'normal' => 'Normal', - 'bold' => 'Bold', - 'bolder' => 'Bolder', - 'lighter' => 'Lighter', - '100' => '100', - '200' => '200', - '300' => '300', - '400' => '400', - '500' => '500', - '600' => '600', - '700' => '700', - '800' => '800', - '900' => '900', - 'inherit' => 'Inherit' - ), $field_id ); - - } - -} - -/** - * Recognized letter spacing - * - * Returns an array of all recognized line heights. - * - * @uses apply_filters() - * - * @param string $field_id ID that's passed to the filters. - * @return array - * - * @access public - * @since 2.0.12 - */ -if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) { - - function ot_recognized_letter_spacing( $field_id ) { - - $range = ot_range( - apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ), - apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ), - apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id ) - ); - - $unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id ); - - foreach( $range as $k => $v ) { - $range[$k] = $v . $unit; - } - - return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id ); - } - -} - -/** - * Recognized line heights - * - * Returns an array of all recognized line heights. - * - * @uses apply_filters() - * - * @param string $field_id ID that's passed to the filters. - * @return array - * - * @access public - * @since 2.0.12 - */ -if ( ! function_exists( 'ot_recognized_line_heights' ) ) { - - function ot_recognized_line_heights( $field_id ) { - - $range = ot_range( - apply_filters( 'ot_line_height_low_range', 0, $field_id ), - apply_filters( 'ot_line_height_high_range', 150, $field_id ), - apply_filters( 'ot_line_height_range_interval', 1, $field_id ) - ); - - $unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id ); - - foreach( $range as $k => $v ) { - $range[$k] = $v . $unit; - } - - return apply_filters( 'ot_recognized_line_heights', $range, $field_id ); - } - -} - -/** - * Recognized text decorations - * - * Returns an array of all recognized text decorations. - * Keys are intended to be stored in the database - * while values are ready for display in html. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.0.10 - */ -if ( ! function_exists( 'ot_recognized_text_decorations' ) ) { - - function ot_recognized_text_decorations( $field_id = '' ) { - - return apply_filters( 'ot_recognized_text_decorations', array( - 'blink' => 'Blink', - 'inherit' => 'Inherit', - 'line-through' => 'Line Through', - 'none' => 'None', - 'overline' => 'Overline', - 'underline' => 'Underline' - ), $field_id ); - - } - -} - -/** - * Recognized text transformations - * - * Returns an array of all recognized text transformations. - * Keys are intended to be stored in the database - * while values are ready for display in html. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.0.10 - */ -if ( ! function_exists( 'ot_recognized_text_transformations' ) ) { - - function ot_recognized_text_transformations( $field_id = '' ) { - - return apply_filters( 'ot_recognized_text_transformations', array( - 'capitalize' => 'Capitalize', - 'inherit' => 'Inherit', - 'lowercase' => 'Lowercase', - 'none' => 'None', - 'uppercase' => 'Uppercase' - ), $field_id ); - - } - -} - -/** - * Recognized background repeat - * - * Returns an array of all recognized background repeat values. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_background_repeat' ) ) { - - function ot_recognized_background_repeat( $field_id = '' ) { - - return apply_filters( 'ot_recognized_background_repeat', array( - 'no-repeat' => 'No Repeat', - 'repeat' => 'Repeat All', - 'repeat-x' => 'Repeat Horizontally', - 'repeat-y' => 'Repeat Vertically', - 'inherit' => 'Inherit' - ), $field_id ); - - } - -} - -/** - * Recognized background attachment - * - * Returns an array of all recognized background attachment values. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_background_attachment' ) ) { - - function ot_recognized_background_attachment( $field_id = '' ) { - - return apply_filters( 'ot_recognized_background_attachment', array( - "fixed" => "Fixed", - "scroll" => "Scroll", - "inherit" => "Inherit" - ), $field_id ); - - } - -} - -/** - * Recognized background position - * - * Returns an array of all recognized background position values. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_recognized_background_position' ) ) { - - function ot_recognized_background_position( $field_id = '' ) { - - return apply_filters( 'ot_recognized_background_position', array( - "left top" => "Left Top", - "left center" => "Left Center", - "left bottom" => "Left Bottom", - "center top" => "Center Top", - "center center" => "Center Center", - "center bottom" => "Center Bottom", - "right top" => "Right Top", - "right center" => "Right Center", - "right bottom" => "Right Bottom" - ), $field_id ); - - } - -} - -/** - * Border Styles - * - * Returns an array of all available style types. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_border_style_types' ) ) { - - function ot_recognized_border_style_types( $field_id = '' ) { - - return apply_filters( 'ot_recognized_border_style_types', array( - 'hidden' => 'Hidden', - 'dashed' => 'Dashed', - 'solid' => 'Solid', - 'double' => 'Double', - 'groove' => 'Groove', - 'ridge' => 'Ridge', - 'inset' => 'Inset', - 'outset' => 'Outset', - ), $field_id ); - - } - -} - -/** - * Border Units - * - * Returns an array of all available unit types. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) { - - function ot_recognized_border_unit_types( $field_id = '' ) { - - return apply_filters( 'ot_recognized_border_unit_types', array( - 'px' => 'px', - '%' => '%', - 'em' => 'em', - 'pt' => 'pt' - ), $field_id ); - - } - -} - -/** - * Dimension Units - * - * Returns an array of all available unit types. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) { - - function ot_recognized_dimension_unit_types( $field_id = '' ) { - - return apply_filters( 'ot_recognized_dimension_unit_types', array( - 'px' => 'px', - '%' => '%', - 'em' => 'em', - 'pt' => 'pt' - ), $field_id ); - - } - -} - -/** - * Spacing Units - * - * Returns an array of all available unit types. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) { - - function ot_recognized_spacing_unit_types( $field_id = '' ) { - - return apply_filters( 'ot_recognized_spacing_unit_types', array( - 'px' => 'px', - '%' => '%', - 'em' => 'em', - 'pt' => 'pt' - ), $field_id ); - - } - -} - -/** - * Recognized Google font families - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_google_font_families' ) ) { - - function ot_recognized_google_font_families( $field_id ) { - - $families = array(); - $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); - - // Forces an array rebuild when we sitch themes - if ( empty( $ot_google_fonts ) ) { - $ot_google_fonts = ot_fetch_google_fonts( true, true ); - } - - foreach( (array) $ot_google_fonts as $key => $item ) { - - if ( isset( $item['family'] ) ) { - - $families[ $key ] = $item['family']; - - } - - } - - return apply_filters( 'ot_recognized_google_font_families', $families, $field_id ); - - } - -} - -/** - * Recognized Google font variants - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) { - - function ot_recognized_google_font_variants( $field_id, $family ) { - - $variants = array(); - $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); - - if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) { - - $variants = $ot_google_fonts[ $family ]['variants']; - - } - - return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family ); - - } - -} - -/** - * Recognized Google font subsets - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.5.0 - */ -if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) { - - function ot_recognized_google_font_subsets( $field_id, $family ) { - - $subsets = array(); - $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); - - if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) { - - $subsets = $ot_google_fonts[ $family ]['subsets']; - - } - - return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family ); - - } - -} - -/** - * Measurement Units - * - * Returns an array of all available unit types. - * Renamed in version 2.0 to avoid name collisions. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 1.1.8 - * @updated 2.0 - */ -if ( ! function_exists( 'ot_measurement_unit_types' ) ) { - - function ot_measurement_unit_types( $field_id = '' ) { - - return apply_filters( 'ot_measurement_unit_types', array( - 'px' => 'px', - '%' => '%', - 'em' => 'em', - 'pt' => 'pt' - ), $field_id ); - - } - -} - -/** - * Radio Images default array. - * - * Returns an array of all available radio images. - * You can filter this function to change the images - * on a per option basis. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_radio_images' ) ) { - - function ot_radio_images( $field_id = '' ) { - - return apply_filters( 'ot_radio_images', array( - array( - 'value' => 'left-sidebar', - 'label' => __( 'Left Sidebar', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/left-sidebar.png' - ), - array( - 'value' => 'right-sidebar', - 'label' => __( 'Right Sidebar', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/right-sidebar.png' - ), - array( - 'value' => 'full-width', - 'label' => __( 'Full Width (no sidebar)', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/full-width.png' - ), - array( - 'value' => 'dual-sidebar', - 'label' => __( 'Dual Sidebar', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/dual-sidebar.png' - ), - array( - 'value' => 'left-dual-sidebar', - 'label' => __( 'Left Dual Sidebar', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png' - ), - array( - 'value' => 'right-dual-sidebar', - 'label' => __( 'Right Dual Sidebar', 'option-tree' ), - 'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png' - ) - ), $field_id ); - - } - -} - -/** - * Default List Item Settings array. - * - * Returns an array of the default list item settings. - * You can filter this function to change the settings - * on a per option basis. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_list_item_settings' ) ) { - - function ot_list_item_settings( $id ) { - - $settings = apply_filters( 'ot_list_item_settings', array( - array( - 'id' => 'image', - 'label' => __( 'Image', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'upload', - 'rows' => '', - 'class' => '', - 'post_type' => '', - 'choices' => array() - ), - array( - 'id' => 'link', - 'label' => __( 'Link', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'text', - 'rows' => '', - 'class' => '', - 'post_type' => '', - 'choices' => array() - ), - array( - 'id' => 'description', - 'label' => __( 'Description', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'textarea-simple', - 'rows' => 10, - 'class' => '', - 'post_type' => '', - 'choices' => array() - ) - ), $id ); - - return $settings; - - } - -} - -/** - * Default Slider Settings array. - * - * Returns an array of the default slider settings. - * You can filter this function to change the settings - * on a per option basis. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_slider_settings' ) ) { - - function ot_slider_settings( $id ) { - - $settings = apply_filters( 'image_slider_fields', array( - array( - 'name' => 'image', - 'type' => 'image', - 'label' => __( 'Image', 'option-tree' ), - 'class' => '' - ), - array( - 'name' => 'link', - 'type' => 'text', - 'label' => __( 'Link', 'option-tree' ), - 'class' => '' - ), - array( - 'name' => 'description', - 'type' => 'textarea', - 'label' => __( 'Description', 'option-tree' ), - 'class' => '' - ) - ), $id ); - - /* fix the array keys, values, and just get it 2.0 ready */ - foreach( $settings as $_k => $setting ) { - - foreach( $setting as $s_key => $s_value ) { - - if ( 'name' == $s_key ) { - - $settings[$_k]['id'] = $s_value; - unset($settings[$_k]['name']); - - } else if ( 'type' == $s_key ) { - - if ( 'input' == $s_value ) { - - $settings[$_k]['type'] = 'text'; - - } else if ( 'textarea' == $s_value ) { - - $settings[$_k]['type'] = 'textarea-simple'; - - } else if ( 'image' == $s_value ) { - - $settings[$_k]['type'] = 'upload'; - - } - - } - - } - - } - - return $settings; - - } - +if ( ! defined( 'OT_VERSION' ) ) { + exit( 'No direct script access allowed' ); } -/** - * Default Social Links Settings array. - * - * Returns an array of the default social links settings. - * You can filter this function to change the settings - * on a per option basis. - * - * @uses apply_filters() - * - * @return array - * - * @access public - * @since 2.4.0 - */ -if ( ! function_exists( 'ot_social_links_settings' ) ) { - - function ot_social_links_settings( $id ) { - - $settings = apply_filters( 'ot_social_links_settings', array( - array( - 'id' => 'name', - 'label' => __( 'Name', 'option-tree' ), - 'desc' => __( 'Enter the name of the social website.', 'option-tree' ), - 'std' => '', - 'type' => 'text', - 'class' => 'option-tree-setting-title' - ), - array( - 'id' => 'title', - 'label' => 'Title', - 'desc' => __( 'Enter the text shown in the title attribute of the link.', 'option-tree' ), - 'type' => 'text' - ), - array( - 'id' => 'href', - 'label' => 'Link', - 'desc' => sprintf( __( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' ), 'http://' ), - 'type' => 'text', - ) - ), $id ); - - return $settings; - - } +if ( ! function_exists( 'ot_register_theme_options_page' ) ) { + /** + * Registers the Theme Option page + * + * @uses ot_register_settings() + * + * @access public + * @since 2.1 + */ + function ot_register_theme_options_page() { + + // Get the settings array. + $get_settings = get_option( ot_settings_id() ); + + // Sections array. + $sections = isset( $get_settings['sections'] ) ? $get_settings['sections'] : array(); + + // Settings array. + $settings = isset( $get_settings['settings'] ) ? $get_settings['settings'] : array(); + + // Contexual help array. + $contextual_help = isset( $get_settings['contextual_help'] ) ? $get_settings['contextual_help'] : array(); + + // Build the Theme Options. + if ( function_exists( 'ot_register_settings' ) && OT_USE_THEME_OPTIONS ) { + + $caps = apply_filters( 'ot_theme_options_capability', 'edit_theme_options' ); + + ot_register_settings( + array( + array( + 'id' => ot_options_id(), + 'pages' => array( + array( + 'id' => 'ot_theme_options', + 'parent_slug' => apply_filters( 'ot_theme_options_parent_slug', 'themes.php' ), + 'page_title' => apply_filters( 'ot_theme_options_page_title', esc_html__( 'Theme Options', 'option-tree' ) ), + 'menu_title' => apply_filters( 'ot_theme_options_menu_title', esc_html__( 'Theme Options', 'option-tree' ) ), + 'capability' => $caps, + 'menu_slug' => apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ), + 'icon_url' => apply_filters( 'ot_theme_options_icon_url', null ), + 'position' => apply_filters( 'ot_theme_options_position', null ), + 'updated_message' => apply_filters( 'ot_theme_options_updated_message', esc_html__( 'Theme Options updated.', 'option-tree' ) ), + 'reset_message' => apply_filters( 'ot_theme_options_reset_message', esc_html__( 'Theme Options reset.', 'option-tree' ) ), + 'button_text' => apply_filters( 'ot_theme_options_button_text', esc_html__( 'Save Changes', 'option-tree' ) ), + 'contextual_help' => apply_filters( 'ot_theme_options_contextual_help', $contextual_help ), + 'sections' => apply_filters( 'ot_theme_options_sections', $sections ), + 'settings' => apply_filters( 'ot_theme_options_settings', $settings ), + ), + ), + ), + ) + ); + + // Filters the options.php to add the minimum user capabilities. + add_filter( + 'option_page_capability_' . ot_options_id(), + function() use ( $caps ) { + return $caps; + }, + 999 + ); + + } + + } } -/** - * Inserts CSS with field_id markers. - * - * Inserts CSS into a dynamic.css file, placing it between - * BEGIN and END field_id markers. Replaces existing marked info, - * but still retains surrounding data. - * - * @param string $field_id The CSS option field ID. - * @param array $options The current option_tree array. - * @return bool True on write success, false on failure. - * - * @access public - * @since 1.1.8 - * @updated 2.5.3 - */ -if ( ! function_exists( 'ot_insert_css_with_markers' ) ) { - - function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) { - - /* missing $field_id or $insertion exit early */ - if ( '' == $field_id || '' == $insertion ) - return; - - /* path to the dynamic.css file */ - $filepath = get_stylesheet_directory() . '/dynamic.css'; - if ( is_multisite() ) { - $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css'; - if ( file_exists( $multisite_filepath ) ) { - $filepath = $multisite_filepath; - } - } - - /* allow filter on path */ - $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id ); - - /* grab a copy of the paths array */ - $ot_css_file_paths = get_option( 'ot_css_file_paths', array() ); - if ( is_multisite() ) { - $ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); - } - - /* set the path for this field */ - $ot_css_file_paths[$field_id] = $filepath; - - /* update the paths */ - if ( is_multisite() ) { - update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); - } else { - update_option( 'ot_css_file_paths', $ot_css_file_paths ); - } - - /* insert CSS into file */ - if ( file_exists( $filepath ) ) { - - $insertion = ot_normalize_css( $insertion ); - $regex = "/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/"; - $marker = $field_id; - - /* Match custom CSS */ - preg_match_all( $regex, $insertion, $matches ); - - /* Loop through CSS */ - foreach( $matches[0] as $option ) { - - $value = ''; - $option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) ); - $option_id = isset( $option_array[0] ) ? $option_array[0] : ''; - $option_key = isset( $option_array[1] ) ? $option_array[1] : ''; - $option_type = ot_get_option_type_by_id( $option_id ); - $fallback = ''; - - // Get the meta array value - if ( $meta ) { - global $post; - - $value = get_post_meta( $post->ID, $option_id, true ); - - // Get the options array value - } else { - - $options = get_option( ot_options_id() ); - - if ( isset( $options[$option_id] ) ) { - - $value = $options[$option_id]; - - } - - } - - // This in an array of values - if ( is_array( $value ) ) { - - if ( empty( $option_key ) ) { - - // Measurement - if ( $option_type == 'measurement' ) { - $unit = ! empty( $value[1] ) ? $value[1] : 'px'; - - // Set $value with measurement properties - if ( isset( $value[0] ) && strlen( $value[0] ) > 0 ) - $value = $value[0].$unit; - - // Border - } else if ( $option_type == 'border' ) { - $border = array(); - - $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; - - if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) - $border[] = $value['width'].$unit; - - if ( ! empty( $value['style'] ) ) - $border[] = $value['style']; - - if ( ! empty( $value['color'] ) ) - $border[] = $value['color']; +if ( ! function_exists( 'ot_register_settings_page' ) ) { - /* set $value with border properties or empty string */ - $value = ! empty( $border ) ? implode( ' ', $border ) : ''; + /** + * Registers the Settings page. + * + * @access public + * @since 2.1 + */ + function ot_register_settings_page() { + global $ot_has_custom_theme_options; + + $custom_options = ( true === $ot_has_custom_theme_options || has_action( 'admin_init', 'custom_theme_options' ) || has_action( 'init', 'custom_theme_options' ) ); + + // Display UI Builder admin notice. + if ( true === OT_SHOW_OPTIONS_UI && isset( $_REQUEST['page'] ) && 'ot-settings' === $_REQUEST['page'] && $custom_options ) { // phpcs:ignore + + /** + * Error message for custom theme options. + */ + function ot_has_custom_theme_options() { + echo '

      ' . esc_html__( 'The Theme Options UI Builder is being overridden by a custom file in your theme. Any changes you make via the UI Builder will not be saved.', 'option-tree' ) . '

      '; + } + + add_action( 'admin_notices', 'ot_has_custom_theme_options' ); + } + + // Create the filterable pages array. + $ot_register_pages_array = array( + array( + 'id' => 'ot', + 'page_title' => esc_html__( 'OptionTree', 'option-tree' ), + 'menu_title' => esc_html__( 'OptionTree', 'option-tree' ), + 'capability' => 'edit_theme_options', + 'menu_slug' => 'ot-settings', + 'icon_url' => null, + 'position' => 61, + 'hidden_page' => true, + ), + array( + 'id' => 'settings', + 'parent_slug' => 'ot-settings', + 'page_title' => esc_html__( 'Settings', 'option-tree' ), + 'menu_title' => esc_html__( 'Settings', 'option-tree' ), + 'capability' => 'edit_theme_options', + 'menu_slug' => 'ot-settings', + 'icon_url' => null, + 'position' => null, + 'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ), + 'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ), + 'button_text' => esc_html__( 'Save Settings', 'option-tree' ), + 'show_buttons' => false, + 'sections' => array( + array( + 'id' => 'create_setting', + 'title' => esc_html__( 'Theme Options UI', 'option-tree' ), + ), + array( + 'id' => 'import', + 'title' => esc_html__( 'Import', 'option-tree' ), + ), + array( + 'id' => 'export', + 'title' => esc_html__( 'Export', 'option-tree' ), + ), + array( + 'id' => 'layouts', + 'title' => esc_html__( 'Layouts', 'option-tree' ), + ), + ), + 'settings' => array( + array( + 'id' => 'theme_options_ui_text', + 'label' => esc_html__( 'Theme Options UI Builder', 'option-tree' ), + 'type' => 'theme_options_ui', + 'section' => 'create_setting', + ), + array( + 'id' => 'import_settings_text', + 'label' => esc_html__( 'Settings', 'option-tree' ), + 'type' => 'import-settings', + 'section' => 'import', + ), + array( + 'id' => 'import_data_text', + 'label' => esc_html__( 'Theme Options', 'option-tree' ), + 'type' => 'import-data', + 'section' => 'import', + ), + array( + 'id' => 'import_layouts_text', + 'label' => esc_html__( 'Layouts', 'option-tree' ), + 'type' => 'import-layouts', + 'section' => 'import', + ), + array( + 'id' => 'export_settings_file_text', + 'label' => esc_html__( 'Settings PHP File', 'option-tree' ), + 'type' => 'export-settings-file', + 'section' => 'export', + ), + array( + 'id' => 'export_settings_text', + 'label' => esc_html__( 'Settings', 'option-tree' ), + 'type' => 'export-settings', + 'section' => 'export', + ), + array( + 'id' => 'export_data_text', + 'label' => esc_html__( 'Theme Options', 'option-tree' ), + 'type' => 'export-data', + 'section' => 'export', + ), + array( + 'id' => 'export_layout_text', + 'label' => esc_html__( 'Layouts', 'option-tree' ), + 'type' => 'export-layouts', + 'section' => 'export', + ), + array( + 'id' => 'modify_layouts_text', + 'label' => esc_html__( 'Layout Management', 'option-tree' ), + 'type' => 'modify-layouts', + 'section' => 'layouts', + ), + ), + ), + array( + 'id' => 'documentation', + 'parent_slug' => 'ot-settings', + 'page_title' => esc_html__( 'Documentation', 'option-tree' ), + 'menu_title' => esc_html__( 'Documentation', 'option-tree' ), + 'capability' => 'edit_theme_options', + 'menu_slug' => 'ot-documentation', + 'icon_url' => null, + 'position' => null, + 'updated_message' => esc_html__( 'Theme Options updated.', 'option-tree' ), + 'reset_message' => esc_html__( 'Theme Options reset.', 'option-tree' ), + 'button_text' => esc_html__( 'Save Settings', 'option-tree' ), + 'show_buttons' => false, + 'sections' => array( + array( + 'id' => 'creating_options', + 'title' => esc_html__( 'Creating Options', 'option-tree' ), + ), + array( + 'id' => 'option_types', + 'title' => esc_html__( 'Option Types', 'option-tree' ), + ), + array( + 'id' => 'functions', + 'title' => esc_html__( 'Function References', 'option-tree' ), + ), + array( + 'id' => 'theme_mode', + 'title' => esc_html__( 'Theme Mode', 'option-tree' ), + ), + array( + 'id' => 'meta_boxes', + 'title' => esc_html__( 'Meta Boxes', 'option-tree' ), + ), + array( + 'id' => 'examples', + 'title' => esc_html__( 'Code Examples', 'option-tree' ), + ), + array( + 'id' => 'layouts_overview', + 'title' => esc_html__( 'Layouts Overview', 'option-tree' ), + ), + ), + 'settings' => array( + array( + 'id' => 'creating_options_text', + 'label' => esc_html__( 'Overview of available Theme Option fields.', 'option-tree' ), + 'type' => 'creating-options', + 'section' => 'creating_options', + ), + array( + 'id' => 'option_types_text', + 'label' => esc_html__( 'Option types in alphabetical order & hooks to filter them.', 'option-tree' ), + 'type' => 'option-types', + 'section' => 'option_types', + ), + array( + 'id' => 'functions_ot_get_option', + 'label' => esc_html__( 'Function Reference:ot_get_option()', 'option-tree' ), + 'type' => 'ot-get-option', + 'section' => 'functions', + ), + array( + 'id' => 'functions_get_option_tree', + 'label' => esc_html__( 'Function Reference:get_option_tree()', 'option-tree' ), + 'type' => 'get-option-tree', + 'section' => 'functions', + ), + array( + 'id' => 'theme_mode_text', + 'label' => esc_html__( 'Theme Mode', 'option-tree' ), + 'type' => 'theme-mode', + 'section' => 'theme_mode', + ), + array( + 'id' => 'meta_boxes_text', + 'label' => esc_html__( 'Meta Boxes', 'option-tree' ), + 'type' => 'meta-boxes', + 'section' => 'meta_boxes', + ), + array( + 'id' => 'example_text', + 'label' => esc_html__( 'Code examples for front-end development.', 'option-tree' ), + 'type' => 'examples', + 'section' => 'examples', + ), + array( + 'id' => 'layouts_overview_text', + 'label' => esc_html__( 'What\'s a layout anyhow?', 'option-tree' ), + 'type' => 'layouts-overview', + 'section' => 'layouts_overview', + ), + ), + ), + ); + + // Loop over the settings and remove as needed. + foreach ( $ot_register_pages_array as $key => $page ) { + + // Remove various options from the Settings UI. + if ( 'settings' === $page['id'] ) { + + // Remove the Theme Options UI. + if ( false === OT_SHOW_OPTIONS_UI ) { + + foreach ( $page['sections'] as $section_key => $section ) { + if ( 'create_setting' === $section['id'] ) { + unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] ); + } + } + + foreach ( $page['settings'] as $setting_key => $setting ) { + if ( 'create_setting' === $setting['section'] ) { + unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] ); + } + } + } + + // Remove parts of the Imports UI. + if ( false === OT_SHOW_SETTINGS_IMPORT ) { + + foreach ( $page['settings'] as $setting_key => $setting ) { + if ( 'import' === $setting['section'] && in_array( $setting['id'], array( 'import_xml_text', 'import_settings_text' ), true ) ) { + unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] ); + } + } + } + + // Remove parts of the Export UI. + if ( false === OT_SHOW_SETTINGS_EXPORT ) { + + foreach ( $page['settings'] as $setting_key => $setting ) { + if ( 'export' === $setting['section'] && in_array( $setting['id'], array( 'export_settings_file_text', 'export_settings_text' ), true ) ) { + unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] ); + } + } + } + + // Remove the Layouts UI. + if ( false === OT_SHOW_NEW_LAYOUT ) { + + foreach ( $page['sections'] as $section_key => $section ) { + if ( 'layouts' === $section['id'] ) { + unset( $ot_register_pages_array[ $key ]['sections'][ $section_key ] ); + } + } + + foreach ( $page['settings'] as $setting_key => $setting ) { + if ( 'layouts' === $setting['section'] ) { + unset( $ot_register_pages_array[ $key ]['settings'][ $setting_key ] ); + } + } + } + } + + // Remove the Documentation UI. + if ( false === OT_SHOW_DOCS && 'documentation' === $page['id'] ) { + unset( $ot_register_pages_array[ $key ] ); + } + } + + $ot_register_pages_array = apply_filters( 'ot_register_pages_array', $ot_register_pages_array ); + + // Register the pages. + ot_register_settings( + array( + array( + 'id' => ot_settings_id(), + 'pages' => $ot_register_pages_array, + ), + ) + ); + + } +} - // Box Shadow - } else if ( $option_type == 'box-shadow' ) { +if ( ! function_exists( 'ot_after_theme_options_save' ) ) { - /* set $value with box-shadow properties or empty string */ - $value = ! empty( $value ) ? implode( ' ', $value ) : ''; + /** + * Runs directly after the Theme Options are save. + * + * @access public + * @since 2.0 + */ + function ot_after_theme_options_save() { - // Dimension - } else if ( $option_type == 'dimension' ) { - $dimension = array(); + $page = isset( $_REQUEST['page'] ) ? esc_attr( wp_unslash( $_REQUEST['page'] ) ) : ''; // phpcs:ignore + $updated = isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ); // phpcs:ignore - $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; + // Only execute after the theme options are saved. + if ( apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $page && $updated ) { - if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) - $dimension[] = $value['width'].$unit; + // Grab a copy of the theme options. + $options = get_option( ot_options_id() ); - if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 ) - $dimension[] = $value['height'].$unit; + // Execute the action hook and pass the theme options to it. + do_action( 'ot_after_theme_options_save', $options ); + } + } +} - // Set $value with dimension properties or empty string - $value = ! empty( $dimension ) ? implode( ' ', $dimension ) : ''; +if ( ! function_exists( 'ot_validate_setting' ) ) { - // Spacing - } else if ( $option_type == 'spacing' ) { - $spacing = array(); + /** + * Validate the options by type before saving. + * + * This function will run on only some of the option types + * as all of them don't need to be validated, just the + * ones users are going to input data into; because they + * can't be trusted. + * + * @param mixed $input Setting value. + * @param string $type Setting type. + * @param string $field_id Setting field ID. + * @param string $wmpl_id WPML field ID. + * @return mixed + * + * @access public + * @since 2.0 + */ + function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { - $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; + // Exit early if missing data. + if ( ! $input || ! $type || ! $field_id ) { + return $input; + } - if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 ) - $spacing[] = $value['top'].$unit; + $input = apply_filters( 'ot_validate_setting', $input, $type, $field_id ); - if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 ) - $spacing[] = $value['right'].$unit; + /* translators: %1$s: the input id, %2$s: the field id */ + $string_nums = esc_html__( 'The %1$s input field for %2$s only allows numeric values.', 'option-tree' ); - if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 ) - $spacing[] = $value['bottom'].$unit; + /* translators: %s: the field id */ + $string_color = esc_html__( 'The %s Colorpicker only allows valid hexadecimal or rgba values.', 'option-tree' ); - if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 ) - $spacing[] = $value['left'].$unit; + if ( 'background' === $type ) { - // Set $value with spacing properties or empty string - $value = ! empty( $spacing ) ? implode( ' ', $spacing ) : ''; + $input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id ); - // Typography - } else if ( $option_type == 'typography' ) { - $font = array(); + $input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id ); - if ( ! empty( $value['font-color'] ) ) - $font[] = "color: " . $value['font-color'] . ";"; + // Loop over array and check for values. + foreach ( (array) $input as $key => $value ) { + if ( ! empty( $value ) ) { + $has_value = true; + } + } - if ( ! empty( $value['font-family'] ) ) { - foreach ( ot_recognized_font_families( $marker ) as $key => $v ) { - if ( $key == $value['font-family'] ) { - $font[] = "font-family: " . $v . ";"; - } - } - } + // No value; set to empty. + if ( ! isset( $has_value ) ) { + $input = ''; + } + } elseif ( 'border' === $type ) { - if ( ! empty( $value['font-size'] ) ) - $font[] = "font-size: " . $value['font-size'] . ";"; + // Loop over array and set errors or unset key from array. + foreach ( $input as $key => $value ) { - if ( ! empty( $value['font-style'] ) ) - $font[] = "font-style: " . $value['font-style'] . ";"; + // Validate width. + if ( 'width' === $key && ! empty( $value ) && ! is_numeric( $value ) ) { - if ( ! empty( $value['font-variant'] ) ) - $font[] = "font-variant: " . $value['font-variant'] . ";"; + $input[ $key ] = '0'; - if ( ! empty( $value['font-weight'] ) ) - $font[] = "font-weight: " . $value['font-weight'] . ";"; + add_settings_error( 'option-tree', 'invalid_border_width', sprintf( $string_nums, 'width', '' . $field_id . '' ), 'error' ); - if ( ! empty( $value['letter-spacing'] ) ) - $font[] = "letter-spacing: " . $value['letter-spacing'] . ";"; + } - if ( ! empty( $value['line-height'] ) ) - $font[] = "line-height: " . $value['line-height'] . ";"; + // Validate color. + if ( 'color' === $key && ! empty( $value ) ) { - if ( ! empty( $value['text-decoration'] ) ) - $font[] = "text-decoration: " . $value['text-decoration'] . ";"; + $input[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); - if ( ! empty( $value['text-transform'] ) ) - $font[] = "text-transform: " . $value['text-transform'] . ";"; + } - // Set $value with font properties or empty string - $value = ! empty( $font ) ? implode( "\n", $font ) : ''; + // Unset keys with empty values. + if ( empty( $value ) && 0 === strlen( $value ) ) { + unset( $input[ $key ] ); + } + } - // Background - } else if ( $option_type == 'background' ) { - $bg = array(); + if ( empty( $input ) ) { + $input = ''; + } + } elseif ( 'box-shadow' === $type ) { - if ( ! empty( $value['background-color'] ) ) - $bg[] = $value['background-color']; + // Validate inset. + $input['inset'] = isset( $input['inset'] ) ? 'inset' : ''; - if ( ! empty( $value['background-image'] ) ) { + // Validate offset-x. + $input['offset-x'] = isset( $input['offset-x'] ) ? ot_validate_setting( $input['offset-x'], 'text', $field_id ) : ''; - // If an attachment ID is stored here fetch its URL and replace the value - if ( wp_attachment_is_image( $value['background-image'] ) ) { + // Validate offset-y. + $input['offset-y'] = isset( $input['offset-y'] ) ? ot_validate_setting( $input['offset-y'], 'text', $field_id ) : ''; - $attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' ); + // Validate blur-radius. + $input['blur-radius'] = isset( $input['blur-radius'] ) ? ot_validate_setting( $input['blur-radius'], 'text', $field_id ) : ''; - // Check for attachment data - if ( $attachment_data ) { + // Validate spread-radius. + $input['spread-radius'] = isset( $input['spread-radius'] ) ? ot_validate_setting( $input['spread-radius'], 'text', $field_id ) : ''; - $value['background-image'] = $attachment_data[0]; + // Validate color. + $input['color'] = isset( $input['color'] ) ? ot_validate_setting( $input['color'], 'colorpicker', $field_id ) : ''; - } + // Unset keys with empty values. + foreach ( $input as $key => $value ) { + if ( empty( $value ) && 0 === strlen( $value ) ) { + unset( $input[ $key ] ); + } + } - } + // Set empty array to empty string. + if ( empty( $input ) ) { + $input = ''; + } + } elseif ( 'colorpicker' === $type ) { - $bg[] = 'url("' . $value['background-image'] . '")'; + // Return empty & set error. + if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) { - } + $input = ''; - if ( ! empty( $value['background-repeat'] ) ) - $bg[] = $value['background-repeat']; + add_settings_error( 'option-tree', 'invalid_hex', sprintf( $string_color, '' . $field_id . '' ), 'error' ); - if ( ! empty( $value['background-attachment'] ) ) - $bg[] = $value['background-attachment']; + } + } elseif ( 'colorpicker-opacity' === $type ) { - if ( ! empty( $value['background-position'] ) ) - $bg[] = $value['background-position']; + // Not allowed. + if ( is_array( $input ) ) { + $input = ''; + } - if ( ! empty( $value['background-size'] ) ) - $size = $value['background-size']; + // Validate color. + $input = ot_validate_setting( $input, 'colorpicker', $field_id ); - // Set $value with background properties or empty string - $value = ! empty( $bg ) ? 'background: ' . implode( " ", $bg ) . ';' : ''; + } elseif ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ), true ) ) { - if ( isset( $size ) ) { - if ( ! empty( $bg ) ) { - $value.= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id ); - } - $value.= "background-size: $size;"; - } + if ( ! current_user_can( 'unfiltered_html' ) && false === OT_ALLOW_UNFILTERED_HTML ) { - } + $input = wp_kses_post( $input ); - } else { + } + } elseif ( 'dimension' === $type ) { - $value = $value[$option_key]; + // Loop over array and set error keys or unset key from array. + foreach ( $input as $key => $value ) { + if ( ! empty( $value ) && ! is_numeric( $value ) && 'unit' !== $key ) { + $errors[] = $key; + } + if ( empty( $value ) && 0 === strlen( $value ) ) { + unset( $input[ $key ] ); + } + } - } + // Return 0 & set error. + if ( isset( $errors ) ) { - } + foreach ( $errors as $error ) { - // If an attachment ID is stored here fetch its URL and replace the value - if ( $option_type == 'upload' && wp_attachment_is_image( $value ) ) { + $input[ $error ] = '0'; - $attachment_data = wp_get_attachment_image_src( $value, 'original' ); + add_settings_error( 'option-tree', 'invalid_dimension_' . $error, sprintf( $string_nums, '' . $error . '', '' . $field_id . '' ), 'error' ); - // Check for attachment data - if ( $attachment_data ) { + } + } - $value = $attachment_data[0]; + if ( empty( $input ) ) { + $input = ''; + } + } elseif ( 'google-fonts' === $type ) { - } + unset( $input['%key%'] ); + + // Loop over array and check for values. + if ( is_array( $input ) && ! empty( $input ) ) { + $input = array_values( $input ); + } + + // No value; set to empty. + if ( empty( $input ) ) { + $input = ''; + } + } elseif ( 'link-color' === $type ) { + + // Loop over array and check for values. + if ( is_array( $input ) && ! empty( $input ) ) { + foreach ( $input as $key => $value ) { + if ( ! empty( $value ) ) { + $input[ $key ] = ot_validate_setting( $input[ $key ], 'colorpicker', $field_id . '-' . $key ); + $has_value = true; + } + } + } + + // No value; set to empty. + if ( ! isset( $has_value ) ) { + $input = ''; + } + } elseif ( 'measurement' === $type ) { + + $input[0] = sanitize_text_field( $input[0] ); + + // No value; set to empty. + if ( empty( $input[0] ) && 0 === strlen( $input[0] ) && empty( $input[1] ) ) { + $input = ''; + } + } elseif ( 'spacing' === $type ) { + + // Loop over array and set error keys or unset key from array. + foreach ( $input as $key => $value ) { + if ( ! empty( $value ) && ! is_numeric( $value ) && 'unit' !== $key ) { + $errors[] = $key; + } + if ( empty( $value ) && 0 === strlen( $value ) ) { + unset( $input[ $key ] ); + } + } + + // Return 0 & set error. + if ( isset( $errors ) ) { + + foreach ( $errors as $error ) { + + $input[ $error ] = '0'; + + add_settings_error( 'option-tree', 'invalid_spacing_' . $error, sprintf( $string_nums, '' . $error . '', '' . $field_id . '' ), 'error' ); + } + } + + if ( empty( $input ) ) { + $input = ''; + } + } elseif ( 'typography' === $type && isset( $input['font-color'] ) ) { + + $input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id ); + + // Loop over array and check for values. + foreach ( $input as $key => $value ) { + if ( ! empty( $value ) ) { + $has_value = true; + } + } + + // No value; set to empty. + if ( ! isset( $has_value ) ) { + $input = ''; + } + } elseif ( 'upload' === $type ) { + + if ( filter_var( $input, FILTER_VALIDATE_INT ) === false ) { + $input = esc_url_raw( $input ); + } + } elseif ( 'gallery' === $type ) { + + $input = trim( $input ); + + } elseif ( 'social-links' === $type ) { + + // Loop over array and check for values, plus sanitize the text field. + foreach ( (array) $input as $key => $value ) { + if ( ! empty( $value ) && is_array( $value ) ) { + foreach ( (array) $value as $item_key => $item_value ) { + if ( ! empty( $item_value ) ) { + $has_value = true; + $input[ $key ][ $item_key ] = sanitize_text_field( $item_value ); + } + } + } + } + + // No value; set to empty. + if ( ! isset( $has_value ) ) { + $input = ''; + } + } + + // WPML Register and Unregister strings. + if ( ! empty( $wmpl_id ) ) { + + // Allow filtering on the WPML option types. + $single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ); + + if ( in_array( $type, $single_string_types, true ) ) { + if ( ! empty( $input ) ) { + ot_wpml_register_string( $wmpl_id, $input ); + } else { + ot_wpml_unregister_string( $wmpl_id ); + } + } + } + + $input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id ); + + return $input; + } +} - } +if ( ! function_exists( 'ot_admin_styles' ) ) { - // Attempt to fallback when `$value` is empty - if ( empty( $value ) ) { + /** + * Setup the default admin styles + * + * @access public + * @since 2.0 + */ + function ot_admin_styles() { + global $wp_styles, $post; + + // Execute styles before actions. + do_action( 'ot_admin_styles_before' ); + + // Load WP colorpicker. + wp_enqueue_style( 'wp-color-picker' ); + + // Load admin styles. + wp_enqueue_style( 'ot-admin-css', OT_URL . 'assets/css/ot-admin.css', false, OT_VERSION ); + + // Load the RTL stylesheet. + $wp_styles->add_data( 'ot-admin-css', 'rtl', true ); + + // Remove styles added by the Easy Digital Downloads plugin. + if ( isset( $post->post_type ) && 'post' === $post->post_type ) { + wp_dequeue_style( 'jquery-ui-css' ); + } + + /** + * Filter the screen IDs used to dequeue `jquery-ui-css`. + * + * @since 2.5.0 + * + * @param array $screen_ids An array of screen IDs. + */ + $screen_ids = apply_filters( + 'ot_dequeue_jquery_ui_css_screen_ids', + array( + 'toplevel_page_ot-settings', + 'optiontree_page_ot-documentation', + 'appearance_page_ot-theme-options', + ) + ); + + // Remove styles added by the WP Review plugin and any custom pages added through filtering. + if ( in_array( get_current_screen()->id, $screen_ids, true ) ) { + wp_dequeue_style( 'plugin_name-admin-ui-css' ); + wp_dequeue_style( 'jquery-ui-css' ); + } + + // Execute styles after actions. + do_action( 'ot_admin_styles_after' ); + } +} - // We're trying to access a single array key - if ( ! empty( $option_key ) ) { +if ( ! function_exists( 'ot_admin_scripts' ) ) { - // Link Color `inherit` - if ( $option_type == 'link-color' ) { - $fallback = 'inherit'; - } + /** + * Setup the default admin scripts. + * + * @uses add_thickbox() Include Thickbox for file uploads. + * @uses wp_enqueue_script() Add OptionTree scripts. + * @uses wp_localize_script() Used to include arbitrary Javascript data. + * + * @access public + * @since 2.0 + */ + function ot_admin_scripts() { + + // Execute scripts before actions. + do_action( 'ot_admin_scripts_before' ); + + if ( function_exists( 'wp_enqueue_media' ) ) { + // WP 3.5 Media Uploader. + wp_enqueue_media(); + } else { + // Legacy Thickbox. + add_thickbox(); + } + + // Load jQuery-ui slider. + wp_enqueue_script( 'jquery-ui-slider' ); + + // Load jQuery-ui datepicker. + wp_enqueue_script( 'jquery-ui-datepicker' ); + + // Load WP colorpicker. + wp_enqueue_script( 'wp-color-picker' ); + + // Load Ace Editor for CSS Editing. + wp_enqueue_script( 'ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.3/ace.js', null, '1.1.3', false ); + + // Load jQuery UI timepicker addon. + wp_enqueue_script( 'jquery-ui-timepicker', OT_URL . 'assets/js/vendor/jquery/jquery-ui-timepicker.js', array( 'jquery', 'jquery-ui-slider', 'jquery-ui-datepicker' ), '1.4.3', false ); + + // Load the post formats. + if ( true === OT_META_BOXES && true === OT_POST_FORMATS ) { + wp_enqueue_script( 'ot-postformats', OT_URL . 'assets/js/ot-postformats.js', array( 'jquery' ), '1.0.1', false ); + } + + // Load all the required scripts. + wp_enqueue_script( 'ot-admin-js', OT_URL . 'assets/js/ot-admin.js', array( 'jquery', 'jquery-ui-tabs', 'jquery-ui-sortable', 'jquery-ui-slider', 'wp-color-picker', 'ace-editor', 'jquery-ui-datepicker', 'jquery-ui-timepicker' ), OT_VERSION, false ); + + // Create localized JS array. + $localized_array = array( + 'ajax' => admin_url( 'admin-ajax.php' ), + 'nonce' => wp_create_nonce( 'option_tree' ), + 'upload_text' => apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'option-tree' ) ), + 'remove_media_text' => esc_html__( 'Remove Media', 'option-tree' ), + 'reset_agree' => esc_html__( 'Are you sure you want to reset back to the defaults?', 'option-tree' ), + 'remove_no' => esc_html__( 'You can\'t remove this! But you can edit the values.', 'option-tree' ), + 'remove_agree' => esc_html__( 'Are you sure you want to remove this?', 'option-tree' ), + 'activate_layout_agree' => esc_html__( 'Are you sure you want to activate this layout?', 'option-tree' ), + 'setting_limit' => esc_html__( 'Sorry, you can\'t have settings three levels deep.', 'option-tree' ), + 'delete' => esc_html__( 'Delete Gallery', 'option-tree' ), + 'edit' => esc_html__( 'Edit Gallery', 'option-tree' ), + 'create' => esc_html__( 'Create Gallery', 'option-tree' ), + 'confirm' => esc_html__( 'Are you sure you want to delete this Gallery?', 'option-tree' ), + 'date_current' => esc_html__( 'Today', 'option-tree' ), + 'date_time_current' => esc_html__( 'Now', 'option-tree' ), + 'date_close' => esc_html__( 'Close', 'option-tree' ), + 'replace' => esc_html__( 'Featured Image', 'option-tree' ), + 'with' => esc_html__( 'Image', 'option-tree' ), + ); + + // Localized script attached to 'option_tree'. + wp_localize_script( 'ot-admin-js', 'option_tree', $localized_array ); + + // Execute scripts after actions. + do_action( 'ot_admin_scripts_after' ); + } +} - } else { +if ( ! function_exists( 'ot_get_media_post_ID' ) ) { - // Border - if ( $option_type == 'border' ) { - $fallback = 'inherit'; - } + /** + * Returns the ID of a custom post type by post_title. + * + * @return int + * + * @access public + * @since 2.0 + * @updated 2.7.0 + */ + function ot_get_media_post_ID() { // phpcs:ignore + + // Option ID. + $option_id = 'ot_media_post_ID'; + + // Get the media post ID. + $post_ID = get_option( $option_id, false ); + + // Add $post_ID to the DB. + if ( false === $post_ID || empty( $post_ID ) || ! is_integer( $post_ID ) ) { + global $wpdb; + + // Get the media post ID. + $post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" ); // phpcs:ignore + + // Add to the DB. + if ( null !== $post_ID && 0 < $post_ID ) { + update_option( $option_id, $post_ID ); + } else { + $post_ID = 0; + } + } + + return $post_ID; + } +} - // Box Shadow - if ( $option_type == 'box-shadow' ) { - $fallback = 'none'; - } +if ( ! function_exists( 'ot_create_media_post' ) ) { - // Colorpicker - if ( $option_type == 'colorpicker' ) { - $fallback = 'inherit'; - } + /** + * Register custom post type & create the media post used to attach images. + * + * @access public + * @since 2.0 + */ + function ot_create_media_post() { + + register_post_type( + 'option-tree', + array( + 'labels' => array( 'name' => esc_html__( 'Option Tree', 'option-tree' ) ), + 'public' => false, + 'show_ui' => false, + 'capability_type' => 'post', + 'exclude_from_search' => true, + 'hierarchical' => false, + 'rewrite' => false, + 'supports' => array( 'title', 'editor' ), + 'can_export' => false, + 'show_in_nav_menus' => false, + ) + ); + + // Look for custom page. + $post_id = ot_get_media_post_ID(); + + // No post exists. + if ( 0 === $post_id ) { + + // Insert the post into the database. + wp_insert_post( + array( + 'post_title' => 'Media', + 'post_name' => 'media', + 'post_status' => 'private', + 'post_type' => 'option-tree', + 'comment_status' => 'closed', + 'ping_status' => 'closed', + ) + ); + } + } +} - // Colorpicker Opacity - if ( $option_type == 'colorpicker-opacity' ) { - $fallback = 'inherit'; - } +if ( ! function_exists( 'ot_default_settings' ) ) { - } + /** + * Setup default settings array. + * + * @access public + * @since 2.0 + */ + function ot_default_settings() { + global $wpdb; + + if ( ! get_option( ot_settings_id() ) ) { + + $section_count = 0; + $settings_count = 0; + $settings = array(); + $table_name = $wpdb->prefix . 'option_tree'; + $old_settings = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s ORDER BY item_sort ASC', $table_name ) ); // phpcs:ignore + $find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore + + if ( $old_settings && $find_table === $table_name ) { + + foreach ( $old_settings as $setting ) { + + // Heading is a section now. + if ( 'heading' === $setting->item_type ) { + + // Add section to the sections array. + $settings['sections'][ $section_count ]['id'] = $setting->item_id; + $settings['sections'][ $section_count ]['title'] = $setting->item_title; + + // Ssave the last section id to use in creating settings. + $section = $setting->item_id; + + // Increment the section count. + $section_count++; + + } else { + + // Add setting to the settings array. + $settings['settings'][ $settings_count ]['id'] = $setting->item_id; + $settings['settings'][ $settings_count ]['label'] = $setting->item_title; + $settings['settings'][ $settings_count ]['desc'] = $setting->item_desc; + $settings['settings'][ $settings_count ]['section'] = $section; + $settings['settings'][ $settings_count ]['type'] = ot_map_old_option_types( $setting->item_type ); + $settings['settings'][ $settings_count ]['std'] = ''; + $settings['settings'][ $settings_count ]['class'] = ''; + + // Textarea rows. + $rows = ''; + if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'css', 'javascript', 'textarea' ), true ) ) { + if ( (int) $setting->item_options > 0 ) { + $rows = (int) $setting->item_options; + } else { + $rows = 15; + } + } + $settings['settings'][ $settings_count ]['rows'] = $rows; + + // Post type. + $post_type = ''; + if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'custom-post-type-select', 'custom-post-type-checkbox' ), true ) ) { + if ( '' !== $setting->item_options ) { + $post_type = $setting->item_options; + } else { + $post_type = 'post'; + } + } + $settings['settings'][ $settings_count ]['post_type'] = $post_type; + + // Cchoices. + $choices = array(); + if ( in_array( $settings['settings'][ $settings_count ]['type'], array( 'checkbox', 'radio', 'select' ), true ) ) { + if ( '' !== $setting->item_options ) { + $choices = ot_convert_string_to_array( $setting->item_options ); + } + } + $settings['settings'][ $settings_count ]['choices'] = $choices; + + $settings_count++; + } + } + + // Make sure each setting has a section just in case. + if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) { + foreach ( $settings['settings'] as $k => $setting ) { + if ( '' === $setting['section'] ) { + $settings['settings'][ $k ]['section'] = $settings['sections'][0]['id']; + } + } + } + } + + // If array if not properly formed create fallback settings array. + if ( ! isset( $settings['sections'] ) || ! isset( $settings['settings'] ) ) { + + $settings = array( + 'sections' => array( + array( + 'id' => 'general', + 'title' => esc_html__( 'General', 'option-tree' ), + ), + ), + 'settings' => array( + array( + 'id' => 'sample_text', + 'label' => esc_html__( 'Sample Text Field Label', 'option-tree' ), + 'desc' => esc_html__( 'Description for the sample text field.', 'option-tree' ), + 'section' => 'general', + 'type' => 'text', + 'std' => '', + 'class' => '', + 'rows' => '', + 'post_type' => '', + 'choices' => array(), + ), + ), + ); + } + + // Update the settings array. + update_option( ot_settings_id(), $settings ); + + // Get option tree array. + $options = get_option( ot_options_id() ); + + $options_safe = array(); + + // Validate options. + if ( is_array( $options ) ) { + + foreach ( $settings['settings'] as $setting ) { + if ( isset( $options[ $setting['id'] ] ) ) { + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); + } + } + + // Execute the action hook and pass the theme options to it. + do_action( 'ot_before_theme_options_save', $options_safe ); + + // Update the option tree array. + update_option( ot_options_id(), $options_safe ); + } + } + } +} - /** - * Filter the `dynamic.css` fallback value. - * - * @since 2.5.3 - * - * @param string $fallback The default CSS fallback value. - * @param string $option_id The option ID. - * @param string $option_type The option type. - * @param string $option_key The option array key. - */ - $fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key ); +if ( ! function_exists( 'ot_save_css' ) ) { - } + /** + * Helper function to update the CSS option type after save. + * + * This function is called during the `ot_after_theme_options_save` hook, + * which is passed the currently stored options array. + * + * @param array $options The current stored options array. + * + * @access public + * @since 2.0 + */ + function ot_save_css( $options ) { + + // Grab a copy of the settings. + $settings = get_option( ot_settings_id() ); + + // Has settings. + if ( isset( $settings['settings'] ) ) { + + // Loop through sections and insert CSS when needed. + foreach ( $settings['settings'] as $k => $setting ) { + + // Is the CSS option type. + if ( isset( $setting['type'] ) && 'css' === $setting['type'] ) { + + // Insert CSS into dynamic.css. + if ( isset( $options[ $setting['id'] ] ) && '' !== $options[ $setting['id'] ] ) { + ot_insert_css_with_markers( $setting['id'], $options[ $setting['id'] ] ); + + // Remove old CSS from dynamic.css. + } else { + ot_remove_old_css( $setting['id'] ); + } + } + } + } + } +} - // Let's fallback! - if ( ! empty( $fallback ) ) { - $value = $fallback; - } +if ( ! function_exists( 'ot_import' ) ) { - // Filter the CSS - $value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id ); + /** + * Import before the screen is displayed. + * + * @access public + * @since 2.0 + */ + function ot_import() { + + // Check and verify import settings nonce. + if ( isset( $_POST['import_settings_nonce'] ) && wp_verify_nonce( $_POST['import_settings_nonce'], 'import_settings_form' ) ) { // phpcs:ignore + + // Default message. + $message = 'failed'; + + $decoded = isset( $_POST['import_settings'] ) ? ot_decode( $_POST['import_settings'] ) : ''; // phpcs:ignore + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( $matches ) { + + // Convert the settings to an array. + $settings = maybe_unserialize( $decoded ); + + $settings_safe = ot_validate_settings( $settings ); + + // Save & show success message. + if ( is_array( $settings_safe ) ) { + update_option( ot_settings_id(), $settings_safe ); + $message = 'success'; + } + } + + // Redirect back to self. + wp_safe_redirect( + esc_url_raw( + add_query_arg( + array( + 'action' => 'import-settings', + 'message' => $message, + ), + wp_get_referer() + ) + ) + ); + exit; + } + + // Check and verify import theme options data nonce. + if ( isset( $_POST['import_data_nonce'] ) && wp_verify_nonce( $_POST['import_data_nonce'], 'import_data_form' ) ) { // phpcs:ignore - // Insert CSS, even if the value is empty - $insertion = stripslashes( str_replace( $option, $value, $insertion ) ); + // Default message. + $message = 'failed'; - } + $decoded = isset( $_POST['import_data'] ) ? ot_decode( $_POST['import_data'] ) : ''; // phpcs:ignore + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( $matches ) { + + // Convert the options to an array. + $options = maybe_unserialize( $decoded ); - // Can't write to the file so we error out - if ( ! is_writable( $filepath ) ) { - add_settings_error( 'option-tree', 'dynamic_css', sprintf( __( 'Unable to write to file %s.', 'option-tree' ), '' . $filepath . '' ), 'error' ); - return false; - } + $options_safe = array(); + + // Get settings array. + $settings = get_option( ot_settings_id() ); + + // Has options. + if ( is_array( $options ) ) { - // Create array from the lines of code - $markerdata = explode( "\n", implode( '', file( $filepath ) ) ); + // Validate options. + if ( is_array( $settings ) ) { + foreach ( $settings['settings'] as $setting ) { + if ( isset( $options[ $setting['id'] ] ) ) { + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); + } + } + } - // Can't write to the file return false - if ( ! $f = ot_file_open( $filepath, 'w' ) ) { - return false; - } + // Execute the action hook and pass the theme options to it. + do_action( 'ot_before_theme_options_save', $options_safe ); - $searching = true; - $foundit = false; + // Update the option tree array. + update_option( ot_options_id(), $options_safe ); - // Has array of lines - if ( ! empty( $markerdata ) ) { + $message = 'success'; + } + } + + // Redirect back to self. + wp_safe_redirect( + esc_url_raw( + add_query_arg( + array( + 'action' => 'import-data', + 'message' => $message, + ), + wp_get_referer() + ) + ) + ); + exit; + } + + // Check and verify import layouts nonce. + if ( isset( $_POST['import_layouts_nonce'] ) && wp_verify_nonce( $_POST['import_layouts_nonce'], 'import_layouts_form' ) ) { // phpcs:ignore + + // Default message. + $message = 'failed'; + + $decoded = isset( $_POST['import_layouts'] ) ? ot_decode( $_POST['import_layouts'] ) : ''; // phpcs:ignore + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( $matches ) { + + // Convert the layouts to an array. + $layouts = maybe_unserialize( $decoded ); + + // Get settings array. + $settings = get_option( ot_settings_id() ); + + // Has layouts. + if ( is_array( $layouts ) && ! empty( $layouts ) && ! empty( $layouts['active_layout'] ) ) { + + $layouts_safe = array( + 'active_layout' => esc_attr( $layouts['active_layout'] ), + ); + + // Validate options. + if ( is_array( $settings ) ) { + + foreach ( $layouts as $key => $value ) { + + if ( 'active_layout' === $key ) { + continue; + } + + $decoded = $value ? ot_decode( $value ) : 'YTowOnt9'; // Fallback is an empty encoded array. + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( ! $matches ) { + continue; + } - // Foreach line of code - foreach( $markerdata as $n => $markerline ) { + // Convert the options to an array. + $options = maybe_unserialize( $decoded ); - // Found begining of marker, set $searching to false - if ( $markerline == "/* BEGIN {$marker} */" ) - $searching = false; + $options_safe = array(); + + foreach ( $settings['settings'] as $setting ) { + if ( isset( $options[ $setting['id'] ] ) ) { + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); + } + } + + // Store the sanitized values for later. + if ( $key === $layouts_safe['active_layout'] ) { + $new_options_safe = $options_safe; + } + + $layouts_safe[ $key ] = ot_encode( maybe_serialize( $options_safe ) ); + } + } + + // Update the option tree array with sanitized values. + if ( isset( $new_options_safe ) ) { + + // Execute the action hook and pass the theme options to it. + do_action( 'ot_before_theme_options_save', $new_options_safe ); + + update_option( ot_options_id(), $new_options_safe ); + } + + // Update the option tree layouts array. + update_option( ot_layouts_id(), $layouts_safe ); + + $message = 'success'; + } + } + + // Redirect back to self. + wp_safe_redirect( + esc_url_raw( + add_query_arg( + array( + 'action' => 'import-layouts', + 'message' => $message, + ), + wp_get_referer() + ) + ) + ); + exit; + } - // Keep searching each line of CSS - if ( $searching == true ) { - if ( $n + 1 < count( $markerdata ) ) - ot_file_write( $f, "{$markerline}\n" ); - else - ot_file_write( $f, "{$markerline}" ); - } + return false; + } +} - // Found end marker write code - if ( $markerline == "/* END {$marker} */" ) { - ot_file_write( $f, "/* BEGIN {$marker} */\n" ); - ot_file_write( $f, "{$insertion}\n" ); - ot_file_write( $f, "/* END {$marker} */\n" ); - $searching = true; - $foundit = true; - } - - } - - } - - // Nothing inserted, write code. DO IT, DO IT! - if ( ! $foundit ) { - ot_file_write( $f, "/* BEGIN {$marker} */\n" ); - ot_file_write( $f, "{$insertion}\n" ); - ot_file_write( $f, "/* END {$marker} */\n" ); - } - - // Close file - ot_file_close( $f ); - return true; - } - - return false; - - } +if ( ! function_exists( 'ot_export' ) ) { + /** + * Export before the screen is displayed. + * + * @return void + * + * @access public + * @since 2.0.8 + */ + function ot_export() { + + // Check and verify export settings file nonce. + if ( isset( $_POST['export_settings_file_nonce'] ) && wp_verify_nonce( $_POST['export_settings_file_nonce'], 'export_settings_file_form' ) ) { // phpcs:ignore + ot_export_php_settings_array(); + } + } } +if ( ! function_exists( 'ot_export_php_settings_array' ) ) { + + /** + * Export the Theme Mode theme-options.php + * + * @access public + * @since 2.0.8 + */ + function ot_export_php_settings_array() { + + $content = ''; + $build_settings = ''; + $contextual_help = ''; + $sections = ''; + $settings = ''; + $option_tree_settings = get_option( ot_settings_id(), array() ); + + /** + * Domain string helper. + * + * @param string $string A string. + * @return string + */ + function ot_i18n_string( $string ) { + if ( ! empty( $string ) && isset( $_POST['domain'] ) && ! empty( $_POST['domain'] ) ) { // phpcs:ignore + $domain = str_replace( ' ', '-', trim( sanitize_text_field( wp_unslash( $_POST['domain'] ) ) ) ); // phpcs:ignore + return "esc_html__( '$string', '$domain' )"; + } + return "'$string'"; + } + + header( 'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0' ); + header( 'Pragma: no-cache ' ); + header( 'Content-Description: File Transfer' ); + header( 'Content-Disposition: attachment; filename="theme-options.php"' ); + header( 'Content-Type: application/octet-stream' ); + header( 'Content-Transfer-Encoding: binary' ); + + // Build contextual help content. + if ( isset( $option_tree_settings['contextual_help']['content'] ) ) { + $help = ''; + foreach ( $option_tree_settings['contextual_help']['content'] as $value ) { + $_id = isset( $value['id'] ) ? $value['id'] : ''; + $_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' ); + $_content = ot_i18n_string( isset( $value['content'] ) ? html_entity_decode( str_replace( "'", "\'", $value['content'] ) ) : '' ); + $help .= " + array( + 'id' => '$_id', + 'title' => $_title, + 'content' => $_content, + ),"; + } + $contextual_help = " + 'content' => array($help + ),"; + } + + // Build contextual help sidebar. + if ( isset( $option_tree_settings['contextual_help']['sidebar'] ) ) { + $_sidebar = ot_i18n_string( html_entity_decode( str_replace( "'", "\'", $option_tree_settings['contextual_help']['sidebar'] ) ) ); + $contextual_help .= " + 'sidebar' => $_sidebar,"; + } + + // Check that $contexual_help has a value and add to $build_settings. + if ( '' !== $contextual_help ) { + $build_settings .= " + 'contextual_help' => array($contextual_help + ),"; + } + + // Build sections. + if ( isset( $option_tree_settings['sections'] ) ) { + foreach ( $option_tree_settings['sections'] as $value ) { + $_id = isset( $value['id'] ) ? $value['id'] : ''; + $_title = ot_i18n_string( isset( $value['title'] ) ? str_replace( "'", "\'", $value['title'] ) : '' ); + $sections .= " + array( + 'id' => '$_id', + 'title' => $_title, + ),"; + } + } + + // Check that $sections has a value and add to $build_settings. + if ( '' !== $sections ) { + $build_settings .= " + 'sections' => array($sections + )"; + } + + /* build settings */ + if ( isset( $option_tree_settings['settings'] ) ) { + foreach ( $option_tree_settings['settings'] as $value ) { + $_id = isset( $value['id'] ) ? $value['id'] : ''; + $_label = ot_i18n_string( isset( $value['label'] ) ? str_replace( "'", "\'", $value['label'] ) : '' ); + $_desc = ot_i18n_string( isset( $value['desc'] ) ? str_replace( "'", "\'", $value['desc'] ) : '' ); + $_std = isset( $value['std'] ) ? str_replace( "'", "\'", $value['std'] ) : ''; + $_type = isset( $value['type'] ) ? $value['type'] : ''; + $_section = isset( $value['section'] ) ? $value['section'] : ''; + $_rows = isset( $value['rows'] ) ? $value['rows'] : ''; + $_post_type = isset( $value['post_type'] ) ? $value['post_type'] : ''; + $_taxonomy = isset( $value['taxonomy'] ) ? $value['taxonomy'] : ''; + $_min_max_step = isset( $value['min_max_step'] ) ? $value['min_max_step'] : ''; + $_class = isset( $value['class'] ) ? $value['class'] : ''; + $_condition = isset( $value['condition'] ) ? $value['condition'] : ''; + $_operator = isset( $value['operator'] ) ? $value['operator'] : ''; + + $choices = ''; + if ( isset( $value['choices'] ) && ! empty( $value['choices'] ) ) { + foreach ( $value['choices'] as $choice ) { + $_choice_value = isset( $choice['value'] ) ? str_replace( "'", "\'", $choice['value'] ) : ''; + $_choice_label = ot_i18n_string( isset( $choice['label'] ) ? str_replace( "'", "\'", $choice['label'] ) : '' ); + $_choice_src = isset( $choice['src'] ) ? str_replace( "'", "\'", $choice['src'] ) : ''; + $choices .= " + array( + 'value' => '$_choice_value', + 'label' => $_choice_label, + 'src' => '$_choice_src', + ),"; + } + $choices = " + 'choices' => array($choices + ),"; + } + + $std = "'$_std'"; + if ( is_array( $_std ) ) { + $std_array = array(); + foreach ( $_std as $_sk => $_sv ) { + $std_array[] = "'$_sk' => '$_sv',"; + } + $std = 'array( +' . implode( ",\n", $std_array ) . ' + )'; + } + + $setting_settings = ''; + if ( isset( $value['settings'] ) && ! empty( $value['settings'] ) ) { + foreach ( $value['settings'] as $setting ) { + $_setting_id = isset( $setting['id'] ) ? $setting['id'] : ''; + $_setting_label = ot_i18n_string( isset( $setting['label'] ) ? str_replace( "'", "\'", $setting['label'] ) : '' ); + $_setting_desc = ot_i18n_string( isset( $setting['desc'] ) ? str_replace( "'", "\'", $setting['desc'] ) : '' ); + $_setting_std = isset( $setting['std'] ) ? $setting['std'] : ''; + $_setting_type = isset( $setting['type'] ) ? $setting['type'] : ''; + $_setting_rows = isset( $setting['rows'] ) ? $setting['rows'] : ''; + $_setting_post_type = isset( $setting['post_type'] ) ? $setting['post_type'] : ''; + $_setting_taxonomy = isset( $setting['taxonomy'] ) ? $setting['taxonomy'] : ''; + $_setting_min_max_step = isset( $setting['min_max_step'] ) ? $setting['min_max_step'] : ''; + $_setting_class = isset( $setting['class'] ) ? $setting['class'] : ''; + $_setting_condition = isset( $setting['condition'] ) ? $setting['condition'] : ''; + $_setting_operator = isset( $setting['operator'] ) ? $setting['operator'] : ''; + + $setting_choices = ''; + if ( isset( $setting['choices'] ) && ! empty( $setting['choices'] ) ) { + foreach ( $setting['choices'] as $setting_choice ) { + $_setting_choice_value = isset( $setting_choice['value'] ) ? $setting_choice['value'] : ''; + $_setting_choice_label = ot_i18n_string( isset( $setting_choice['label'] ) ? str_replace( "'", "\'", $setting_choice['label'] ) : '' ); + $_setting_choice_src = isset( $setting_choice['src'] ) ? str_replace( "'", "\'", $setting_choice['src'] ) : ''; + $setting_choices .= " + array( + 'value' => '$_setting_choice_value', + 'label' => $_setting_choice_label, + 'src' => '$_setting_choice_src', + ),"; + } + $setting_choices = " + 'choices' => array($setting_choices + ),"; + } + + $setting_std = "'$_setting_std'"; + if ( is_array( $_setting_std ) ) { + $setting_std_array = array(); + foreach ( $_setting_std as $_ssk => $_ssv ) { + $setting_std_array[] = "'$_ssk' => '$_ssv'"; + } + $setting_std = 'array( +' . implode( ",\n", $setting_std_array ) . ' + )'; + } + + $setting_settings .= " + array( + 'id' => '$_setting_id', + 'label' => $_setting_label, + 'desc' => $_setting_desc, + 'std' => $setting_std, + 'type' => '$_setting_type', + 'rows' => '$_setting_rows', + 'post_type' => '$_setting_post_type', + 'taxonomy' => '$_setting_taxonomy', + 'min_max_step' => '$_setting_min_max_step', + 'class' => '$_setting_class', + 'condition' => '$_setting_condition', + 'operator' => '$_setting_operator',$setting_choices + ),"; + } + $setting_settings = " + 'settings' => array( $setting_settings + ),"; + } + $settings .= " + array( + 'id' => '$_id', + 'label' => $_label, + 'desc' => $_desc, + 'std' => $std, + 'type' => '$_type', + 'section' => '$_section', + 'rows' => '$_rows', + 'post_type' => '$_post_type', + 'taxonomy' => '$_taxonomy', + 'min_max_step' => '$_min_max_step', + 'class' => '$_class', + 'condition' => '$_condition', + 'operator' => '$_operator',$choices$setting_settings + ),"; + } + } + + // Check that $sections has a value and add to $build_settings. + if ( '' !== $settings ) { + $build_settings .= ", + 'settings' => array($settings + )"; + } + + $content .= " $markerline ) { - - /* found begining of marker, set $searching to false */ - if ( $markerline == "/* BEGIN {$field_id} */" ) - $searching = false; - - /* $searching is true, keep rewrite each line of CSS */ - if ( $searching == true ) { - if ( $n + 1 < count( $markerdata ) ) - ot_file_write( $f, "{$markerline}\n" ); - else - ot_file_write( $f, "{$markerline}" ); - } - - /* found end marker delete old CSS */ - if ( $markerline == "/* END {$field_id} */" ) { - ot_file_write( $f, "" ); - $searching = true; - } - - } - - } - - /* close file */ - ot_file_close( $f ); - return true; - - } - - return false; - - } - -} +add_action( 'init', 'custom_theme_options' ); /** - * Normalize CSS - * - * Normalize & Convert all line-endings to UNIX format. - * - * @param string $css - * @return string - * - * @access public - * @since 1.1.8 - * @updated 2.0 + * Build the custom settings & update OptionTree. */ -if ( ! function_exists( 'ot_normalize_css' ) ) { - - function ot_normalize_css( $css ) { - - /* Normalize & Convert */ - $css = str_replace( "\r\n", "\n", $css ); - $css = str_replace( "\r", "\n", $css ); - - /* Don't allow out-of-control blank lines */ - $css = preg_replace( "/\n{2,}/", "\n\n", $css ); - - return $css; - } +function custom_theme_options() { -} + // OptionTree is not loaded yet, or this is not an admin request. + if ( ! function_exists( 'ot_settings_id' ) || ! is_admin() ) { + return false; + } -/** - * Helper function to loop over the option types. - * - * @param array $type The current option type. - * - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_loop_through_option_types' ) ) { + // Get a copy of the saved settings array. + \$saved_settings = get_option( ot_settings_id(), array() ); - function ot_loop_through_option_types( $type = '', $child = false ) { - - $content = ''; - $types = ot_option_types_array(); - - if ( $child ) - unset($types['list-item']); - - foreach( $types as $key => $value ) - $content.= ''; - - return $content; - - } - -} + // Custom settings array that will eventually be passes to the OptionTree Settings API Class. + \$custom_settings = array($build_settings + ); -/** - * Helper function to loop over choices. - * - * @param string $name The form element name. - * @param array $choices The array of choices. - * - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_loop_through_choices' ) ) { + // Allow settings to be filtered before saving. + \$custom_settings = apply_filters( ot_settings_id() . '_args', \$custom_settings ); - function ot_loop_through_choices( $name, $choices = array() ) { - - $content = ''; - - foreach( (array) $choices as $key => $choice ) - $content.= '
    • ' . ot_choices_view( $name, $key, $choice ) . '
    • '; - - return $content; - } - -} + // Settings are not the same update the DB. + if ( \$saved_settings !== \$custom_settings ) { + update_option( ot_settings_id(), \$custom_settings ); + } -/** - * Helper function to loop over sub settings. - * - * @param string $name The form element name. - * @param array $settings The array of settings. - * - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) { + // Lets OptionTree know the UI Builder is being overridden. + global \$ot_has_custom_theme_options; + \$ot_has_custom_theme_options = true; +} +"; - function ot_loop_through_sub_settings( $name, $settings = array() ) { - - $content = ''; - - foreach( $settings as $key => $setting ) - $content.= '
    • ' . ot_settings_view( $name, $key, $setting ) . '
    • '; - - return $content; - } - + echo $content; // phpcs:ignore + die(); + } } -/** - * Helper function to display sections. - * - * This function is used in AJAX to add a new section - * and when section have already been added and saved. - * - * @param int $key The array key for the current element. - * @param array An array of values for the current section. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_sections_view' ) ) { +if ( ! function_exists( 'ot_save_settings' ) ) { - function ot_sections_view( $name, $key, $section = array() ) { - - return ' -
      -
      ' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( $key + 1 ) ) . '
      - -
      -
      -
      -
      ' . __( 'Section Title: Displayed as a menu item on the Theme Options page.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Section ID: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      '; - - } + /** + * Save settings array before the screen is displayed. + * + * @return bool Redirects on save, false on failure. + * + * @access public + * @since 2.0 + */ + function ot_save_settings() { + + // Check and verify import settings nonce. + if ( isset( $_POST['option_tree_settings_nonce'] ) && wp_verify_nonce( $_POST['option_tree_settings_nonce'], 'option_tree_settings_form' ) ) { // phpcs:ignore + + // Settings value. + $settings = isset( $_POST[ ot_settings_id() ] ) ? wp_unslash( $_POST[ ot_settings_id() ] ) : array(); // phpcs:ignore + + $settings_safe = ot_validate_settings( $settings ); + + // Default message. + $message = 'failed'; + + // Save & show success message. + if ( ! empty( $settings_safe ) ) { + ot_wpml_unregister( $settings_safe ); + + update_option( ot_settings_id(), $settings_safe ); + $message = 'success'; + } + + // Redirect. + wp_safe_redirect( + esc_url_raw( + add_query_arg( + array( + 'action' => 'save-settings', + 'message' => $message, + ), + wp_get_referer() + ) + ) + ); + exit; + } + + return false; + } +} +if ( ! function_exists( 'ot_wpml_unregister' ) ) { + + /** + * Unregister WPML strings based on settings changing. + * + * @param array $settings The array of settings. + * + * @access public + * @since 2.7.0 + */ + function ot_wpml_unregister( $settings = array() ) { + + // WPML unregister ID's that have been removed. + if ( function_exists( 'icl_unregister_string' ) ) { + + $current = get_option( ot_settings_id() ); + $options = get_option( ot_options_id() ); + + if ( isset( $current['settings'] ) ) { + + // Empty ID array. + $new_ids = array(); + + // Build the WPML IDs array. + foreach ( $settings['settings'] as $setting ) { + if ( $setting['id'] ) { + $new_ids[] = $setting['id']; + } + } + + // Remove missing IDs from WPML. + foreach ( $current['settings'] as $current_setting ) { + if ( ! in_array( $current_setting['id'], $new_ids, true ) ) { + if ( ! empty( $options[ $current_setting['id'] ] ) && in_array( $current_setting['type'], array( 'list-item', 'slider' ), true ) ) { + foreach ( $options[ $current_setting['id'] ] as $key => $value ) { + foreach ( $value as $ckey => $cvalue ) { + ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key ); + } + } + } elseif ( ! empty( $options[ $current_setting['id'] ] ) && 'social-icons' === $current_setting['type'] ) { + foreach ( $options[ $current_setting['id'] ] as $key => $value ) { + foreach ( $value as $ckey => $cvalue ) { + ot_wpml_unregister_string( $current_setting['id'] . '_' . $ckey . '_' . $key ); + } + } + } else { + ot_wpml_unregister_string( $current_setting['id'] ); + } + } + } + } + } + } } -/** - * Helper function to display settings. - * - * This function is used in AJAX to add a new setting - * and when settings have already been added and saved. - * - * @param int $key The array key for the current element. - * @param array An array of values for the current section. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_settings_view' ) ) { +if ( ! function_exists( 'ot_validate_settings' ) ) { - function ot_settings_view( $name, $key, $setting = array() ) { - - $child = ( strpos( $name, '][settings]') !== false ) ? true : false; - $type = isset( $setting['type'] ) ? $setting['type'] : ''; - $std = isset( $setting['std'] ) ? $setting['std'] : ''; - $operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and'; - - // Serialize the standard value just incase - if ( is_array( $std ) ) { - $std = maybe_serialize( $std ); - } - - if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ) ) ) { - $std_form_element = ''; - } else { - $std_form_element = ''; - } - - return ' -
      -
      ' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( $key + 1 ) ) . '
      - -
      -
      -
      -
      ' . __( 'Label: Displayed as the label of a form element on the Theme Options page.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'ID: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Type: Choose one of the available option types from the dropdown.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Description: Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Choices: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ) . '
      -
      -
        - ' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . ' -
      - ' . __( 'Add Choice', 'option-tree' ) . ' -
      -
      -
      -
      -
      -
      ' . __( 'Settings: This will only affect the List Item option type.', 'option-tree' ) . '
      -
      -
        - ' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . ' -
      - ' . __( 'Add Setting', 'option-tree' ) . ' -
      -
      -
      -
      -
      -
      ' . __( 'Standard: Setting the standard value for your option only works for some option types. Read the OptionTree->Documentation for more information on which ones.', 'option-tree' ) . '
      -
      - ' . $std_form_element . ' -
      -
      -
      -
      -
      -
      ' . __( 'Rows: Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Post Type: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Taxonomy: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Min, Max, & Step: Add a comma separated list of options in the following format 0,100,1 (slide from 0-100 in intervals of 1). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'CSS Class: Add and optional class to this option type.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . sprintf( __( 'Condition: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, value is a placeholder for your condition, which can be in the form of %s.', 'option-tree' ), 'field_id:is(value), field_id:not(value), field_id:contains(value), field_id:less_than(value), field_id:less_than_or_equal_to(value), field_id:greater_than(value), or field_id:greater_than_or_equal_to(value)' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Operator: Choose the logical operator to compute the result of the conditions.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      - ' . ( ! $child ? '' : '' ); - - } + /** + * Helper function to validate all settings. + * + * This includes the `sections`, `settings`, and `contextual_help` arrays. + * + * @param array $settings The array of settings. + * + * @return array + * + * @access public + * @since 2.7.0 + */ + function ot_validate_settings( $settings = array() ) { -} + // Store the validated settings. + $settings_safe = array(); -/** - * Helper function to display setting choices. - * - * This function is used in AJAX to add a new choice - * and when choices have already been added and saved. - * - * @param string $name The form element name. - * @param array $key The array key for the current element. - * @param array An array of values for the current choice. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_choices_view' ) ) { + // Validate sections. + if ( isset( $settings['sections'] ) ) { - function ot_choices_view( $name, $key, $choice = array() ) { - - return ' -
      -
      ' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( $key + 1 ) ) . '
      - -
      -
      -
      -
      ' . __( 'Label', 'option-tree' ) . '
      -
      -
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Value', 'option-tree' ) . '
      -
      -
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Image Source (Radio Image only)', 'option-tree' ) . '
      -
      -
      -
      - -
      -
      -
      -
      '; - - } + // Fix numeric keys since drag & drop will change them. + $settings['sections'] = array_values( $settings['sections'] ); -} + // Loop through sections. + foreach ( $settings['sections'] as $k => $section ) { -/** - * Helper function to display sections. - * - * This function is used in AJAX to add a new section - * and when section have already been added and saved. - * - * @param int $key The array key for the current element. - * @param array An array of values for the current section. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_contextual_help_view' ) ) { + // Skip if missing values. + if ( ( ! isset( $section['title'] ) && ! isset( $section['id'] ) ) || ( '' === $section['title'] && '' === $section['id'] ) ) { + continue; + } - function ot_contextual_help_view( $name, $key, $content = array() ) { - - return ' -
      -
      ' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( $key + 1 ) ) . '
      - -
      -
      -
      -
      ' . __( 'Title: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'ID: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      -
      ' . __( 'Content: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' ) . '
      -
      - -
      -
      -
      -
      -
      '; - - } + // Validate label. + if ( '' !== $section['title'] ) { + $settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['title'] ); + } -} + // Missing title set to unfiltered ID. + if ( ! isset( $section['title'] ) || '' === $section['title'] ) { -/** - * Helper function to display sections. - * - * @param string $key - * @param string $data - * @param string $active_layout - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_layout_view' ) ) { + $settings_safe['sections'][ $k ]['title'] = wp_kses_post( $section['id'] ); - function ot_layout_view( $key, $data = '', $active_layout = '' ) { - - return ' -
      -
      ' . ( isset( $key ) ? esc_attr( $key ) : __( 'Layout', 'option-tree' ) ) . '
      - - -
      '; - - } + // Missing ID set to title. + } elseif ( ! isset( $section['id'] ) || '' === $section['id'] ) { -} + $settings_safe['id'] = wp_kses_post( $section['title'] ); + } -/** - * Helper function to display list items. - * - * This function is used in AJAX to add a new list items - * and when they have already been added and saved. - * - * @param string $name The form field name. - * @param int $key The array key for the current element. - * @param array An array of values for the current list item. - * - * @return void - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_list_item_view' ) ) { + // Sanitize ID once everything has been checked first. + $settings_safe['sections'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $section['id'] ) ); + } + } - function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) { - - /* required title setting */ - $required_setting = array( - array( - 'id' => 'title', - 'label' => __( 'Title', 'option-tree' ), - 'desc' => '', - 'std' => '', - 'type' => 'text', - 'rows' => '', - 'class' => 'option-tree-setting-title', - 'post_type' => '', - 'choices' => array() - ) - ); - - /* load the old filterable slider settings */ - if ( 'slider' == $type ) { - - $settings = ot_slider_settings( $name ); - - } - - /* if no settings array load the filterable list item settings */ - if ( empty( $settings ) ) { - - $settings = ot_list_item_settings( $name ); - - } - - /* merge the two settings array */ - $settings = array_merge( $required_setting, $settings ); - - echo ' -
      -
      ' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '
      - -
      '; - - foreach( $settings as $field ) { - - // Set field value - $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : ''; - - /* set default to standard value */ - if ( isset( $field['std'] ) ) { - $field_value = ot_filter_std_value( $field_value, $field['std'] ); - } - - // filter the title label and description - if ( $field['id'] == 'title' ) { - - // filter the label - $field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name ); - - // filter the description - $field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name ); - - } - - /* make life easier */ - $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name; - - /* build the arguments array */ - $_args = array( - 'type' => $field['type'], - 'field_id' => $name . '_' . $field['id'] . '_' . $key, - 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', - 'field_value' => $field_value, - 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', - 'field_std' => isset( $field['std'] ) ? $field['std'] : '', - 'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10, - 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', - 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', - 'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', - 'field_class' => isset( $field['class'] ) ? $field['class'] : '', - 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', - 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', - 'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(), - 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), - 'post_id' => $post_id, - 'get_option' => $get_option - ); - - $conditions = ''; - - /* setup the conditions */ - if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { - - /* doing magic on the conditions so they work in a list item */ - $conditionals = explode( ',', $field['condition'] ); - foreach( $conditionals as $condition ) { - $parts = explode( ':', $condition ); - if ( isset( $parts[0] ) ) { - $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] ); - } - } - - $conditions = ' data-condition="' . $field['condition'] . '"'; - $conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : ''; - - } - - // Build the setting CSS class - if ( ! empty( $_args['field_class'] ) ) { - - $classes = explode( ' ', $_args['field_class'] ); - - foreach( $classes as $_key => $value ) { - - $classes[$_key] = $value . '-wrap'; - - } - - $class = 'format-settings ' . implode( ' ', $classes ); - - } else { - - $class = 'format-settings'; - - } - - /* option label */ - echo '
      '; - - /* don't show title with textblocks */ - if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) { - echo '
      '; - echo '

      ' . esc_attr( $field['label'] ) . '

      '; - echo '
      '; - } - - /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */ - if ( apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) == false && $_args['type'] == 'textarea' ) - $_args['type'] = 'textarea-simple'; - - /* option body, list-item is not allowed inside another list-item */ - if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' ) { - echo ot_display_by_type( $_args ); - } - - echo '
      '; - - } - - echo '
      '; - - echo '
      '; - - } - -} + // Validate settings by looping over array as many times as it takes. + if ( isset( $settings['settings'] ) ) { + $settings_safe['settings'] = ot_validate_settings_array( $settings['settings'] ); + } -/** - * Helper function to display social links. - * - * This function is used in AJAX to add a new list items - * and when they have already been added and saved. - * - * @param string $name The form field name. - * @param int $key The array key for the current element. - * @param array An array of values for the current list item. - * - * @return void - * - * @access public - * @since 2.4.0 - */ -if ( ! function_exists( 'ot_social_links_view' ) ) { + // Validate contextual_help. + if ( isset( $settings['contextual_help']['content'] ) ) { - function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) { - - /* if no settings array load the filterable social links settings */ - if ( empty( $settings ) ) { - - $settings = ot_social_links_settings( $name ); - - } - - echo ' -
      -
      ' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '
      - -
      '; - - foreach( $settings as $field ) { - - // Set field value - $field_value = isset( $list_item[$field['id']] ) ? $list_item[$field['id']] : ''; - - /* set default to standard value */ - if ( isset( $field['std'] ) ) { - $field_value = ot_filter_std_value( $field_value, $field['std'] ); - } - - /* make life easier */ - $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name; - - /* build the arguments array */ - $_args = array( - 'type' => $field['type'], - 'field_id' => $name . '_' . $field['id'] . '_' . $key, - 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', - 'field_value' => $field_value, - 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', - 'field_std' => isset( $field['std'] ) ? $field['std'] : '', - 'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10, - 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', - 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', - 'field_min_max_step'=> isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', - 'field_class' => isset( $field['class'] ) ? $field['class'] : '', - 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', - 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', - 'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(), - 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), - 'post_id' => $post_id, - 'get_option' => $get_option - ); - - $conditions = ''; - - /* setup the conditions */ - if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { - - /* doing magic on the conditions so they work in a list item */ - $conditionals = explode( ',', $field['condition'] ); - foreach( $conditionals as $condition ) { - $parts = explode( ':', $condition ); - if ( isset( $parts[0] ) ) { - $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] ); - } - } - - $conditions = ' data-condition="' . $field['condition'] . '"'; - $conditions.= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ) ) ? ' data-operator="' . $field['operator'] . '"' : ''; - - } - - /* option label */ - echo '
      '; - - /* don't show title with textblocks */ - if ( $_args['type'] != 'textblock' && ! empty( $field['label'] ) ) { - echo '
      '; - echo '

      ' . esc_attr( $field['label'] ) . '

      '; - echo '
      '; - } - - /* only allow simple textarea inside a list-item due to known DOM issues with wp_editor() */ - if ( $_args['type'] == 'textarea' ) - $_args['type'] = 'textarea-simple'; - - /* option body, list-item is not allowed inside another list-item */ - if ( $_args['type'] !== 'list-item' && $_args['type'] !== 'slider' && $_args['type'] !== 'social-links' ) { - echo ot_display_by_type( $_args ); - } - - echo '
      '; - - } - - echo '
      '; - - echo '
      '; - - } - -} + // Fix numeric keys since drag & drop will change them. + $settings['contextual_help']['content'] = array_values( $settings['contextual_help']['content'] ); -/** - * Helper function to display Theme Options layouts form. - * - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) { + // Loop through content. + foreach ( $settings['contextual_help']['content'] as $k => $content ) { - function ot_theme_options_layouts_form( $active = false ) { - - echo '
      '; - - /* form nonce */ - wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' ); - - /* get the saved layouts */ - $layouts = get_option( ot_layouts_id() ); - - /* set active layout */ - $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : ''; - - if ( is_array( $layouts ) && count( $layouts ) > 1 ) { - - $active_layout = esc_attr( $layouts['active_layout'] ); - - echo ''; - - echo '
      '; - - echo ''; - - echo '
      '; - - foreach( $layouts as $key => $data ) { - - if ( $key == 'active_layout' ) - continue; - - echo ''; - - } - - } - - /* new layout wrapper */ - echo '
      '; - - /* add new layout */ - echo ''; - - echo ''; - - echo '
      '; - - echo '
      '; - - } + // Skip if missing values. + if ( ( ! isset( $content['title'] ) && ! isset( $content['id'] ) ) || ( '' === $content['title'] && '' === $content['id'] ) ) { + continue; + } -} + // Validate label. + if ( '' !== $content['title'] ) { + $settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['title'] ); + } -/** - * Helper function to validate option ID's - * - * @param string $input The string to sanitize. - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_sanitize_option_id' ) ) { + // Missing title set to unfiltered ID. + if ( ! isset( $content['title'] ) || '' === $content['title'] ) { - function ot_sanitize_option_id( $input ) { - - return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) ); - - } + $settings_safe['contextual_help']['content'][ $k ]['title'] = wp_kses_post( $content['id'] ); -} + // Missing ID set to title. + } elseif ( ! isset( $content['id'] ) || '' === $content['id'] ) { -/** - * Helper function to validate layout ID's - * - * @param string $input The string to sanitize. - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_sanitize_layout_id' ) ) { + $content['id'] = wp_kses_post( $content['title'] ); + } - function ot_sanitize_layout_id( $input ) { - - return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) ); - - } + // Sanitize ID once everything has been checked first. + $settings_safe['contextual_help']['content'][ $k ]['id'] = ot_sanitize_option_id( wp_kses_post( $content['id'] ) ); -} + // Validate textarea description. + if ( isset( $content['content'] ) ) { + $settings_safe['contextual_help']['content'][ $k ]['content'] = wp_kses_post( $content['content'] ); + } + } + } -/** - * Convert choices array to string - * - * @return string - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_convert_array_to_string' ) ) { + // Validate contextual_help sidebar. + if ( isset( $settings['contextual_help']['sidebar'] ) ) { + $settings_safe['contextual_help']['sidebar'] = wp_kses_post( $settings['contextual_help']['sidebar'] ); + } - function ot_convert_array_to_string( $input ) { - - if ( is_array( $input ) ) { - - foreach( $input as $k => $choice ) { - $choices[$k] = $choice['value'] . '|' . $choice['label']; - - if ( isset( $choice['src'] ) ) - $choices[$k].= '|' . $choice['src']; - - } - - return implode( ',', $choices ); - } - - return false; - } + return $settings_safe; + } } -/** - * Convert choices string to array - * - * @return array - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_convert_string_to_array' ) ) { +if ( ! function_exists( 'ot_validate_settings_array' ) ) { - function ot_convert_string_to_array( $input ) { - - if ( '' !== $input ) { - - /* empty choices array */ - $choices = array(); - - /* exlode the string into an array */ - foreach( explode( ',', $input ) as $k => $choice ) { - - /* if ":" is splitting the string go deeper */ - if ( preg_match( '/\|/', $choice ) ) { - $split = explode( '|', $choice ); - $choices[$k]['value'] = trim( $split[0] ); - $choices[$k]['label'] = trim( $split[1] ); - - /* if radio image there are three values */ - if ( isset( $split[2] ) ) - $choices[$k]['src'] = trim( $split[2] ); - - } else { - $choices[$k]['value'] = trim( $choice ); - $choices[$k]['label'] = trim( $choice ); - } - - } - - /* return a formated choices array */ - return $choices; - - } - - return false; - - } + /** + * Validate a settings array before save. + * + * This function will loop over a settings array as many + * times as it takes to validate every sub setting. + * + * @param array $settings The array of settings. + * @return array + * + * @access public + * @since 2.0 + * @updated 2.7.0 + */ + function ot_validate_settings_array( $settings = array() ) { + + // Field types mapped to their sanitize function. + $field_types = array( + 'label' => 'wp_kses_post', + 'id' => 'ot_sanitize_option_id', + 'type' => 'sanitize_text_field', + 'desc' => 'wp_kses_post', + 'settings' => 'ot_validate_settings_array', + 'choices' => array( + 'label' => 'wp_kses_post', + 'value' => 'sanitize_text_field', + 'src' => 'sanitize_text_field', + ), + 'std' => 'sanitize_text_field', + 'rows' => 'absint', + 'post_type' => 'sanitize_text_field', + 'taxonomy' => 'sanitize_text_field', + 'min_max_step' => 'sanitize_text_field', + 'class' => 'sanitize_text_field', + 'condition' => 'sanitize_text_field', + 'operator' => 'sanitize_text_field', + 'section' => 'sanitize_text_field', + ); + + // Store the validated settings. + $settings_safe = array(); + + // Validate settings. + if ( 0 < count( $settings ) ) { + + // Fix numeric keys since drag & drop will change them. + $settings = array_values( $settings ); + + // Loop through settings. + foreach ( $settings as $sk => $setting ) { + foreach ( $setting as $fk => $field ) { + if ( isset( $field_types[ $fk ] ) ) { + if ( 'choices' === $fk ) { + foreach ( $field as $ck => $choice ) { + foreach ( $choice as $vk => $value ) { + $settings_safe[ $sk ][ $fk ][ $ck ][ $vk ] = $field_types[ $fk ][ $vk ]( $value ); + } + } + } elseif ( 'std' === $fk && is_array( $field ) ) { + + // This is only for validating an array of standard values coming from a theme-options.php file. + foreach ( $field as $dk => $std ) { + $settings_safe[ $sk ][ $fk ][ $dk ] = $field_types[ $fk ]( $std ); + } + } else { + $sanitized = $field_types[ $fk ]( $field ); + if ( 'rows' === $fk && 0 === $sanitized ) { + $sanitized = ''; + } + $settings_safe[ $sk ][ $fk ] = $sanitized; + } + } + } + } + } + + return $settings_safe; + } } -/** - * Helper function - strpos() with arrays. - * - * @param string $haystack - * @param array $needles - * @return bool - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_strpos_array' ) ) { - - function ot_strpos_array( $haystack, $needles = array() ) { - - foreach( $needles as $needle ) { - $pos = strpos( $haystack, $needle ); - if ( $pos !== false ) { - return true; - } - } - - return false; - } +if ( ! function_exists( 'ot_modify_layouts' ) ) { -} + /** + * Save layouts array before the screen is displayed. + * + * @return bool Returns false or redirects. + * + * @access public + * @since 2.0 + */ + function ot_modify_layouts() { -/** - * Helper function - strpos() with arrays. - * - * @param string $haystack - * @param array $needles - * @return bool - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_array_keys_exists' ) ) { - - function ot_array_keys_exists( $array, $keys ) { - - foreach($keys as $k) { - if ( isset($array[$k]) ) { - return true; - } - } - - return false; - } - + // Check and verify modify layouts nonce. + if ( isset( $_POST['option_tree_modify_layouts_nonce'] ) && wp_verify_nonce( $_POST['option_tree_modify_layouts_nonce'], 'option_tree_modify_layouts_form' ) ) { // phpcs:ignore + + // Previous layouts value. + $option_tree_layouts = get_option( ot_layouts_id() ); + + // New layouts value. + $layouts = isset( $_POST[ ot_layouts_id() ] ) ? array_filter( $_POST[ ot_layouts_id() ], 'sanitize_text_field' ) : ''; // phpcs:ignore + + // Rebuild layout array. + $rebuild = array(); + + // Validate layouts. + if ( is_array( $layouts ) && ! empty( $layouts ) ) { + + // Setup active layout. + if ( isset( $layouts['active_layout'] ) && ! empty( $layouts['active_layout'] ) ) { + $rebuild['active_layout'] = $layouts['active_layout']; + } + + /* add new and overwrite active layout */ + if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) { + $rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] ); + $rebuild[ $rebuild['active_layout'] ] = ot_encode( maybe_serialize( get_option( ot_options_id() ) ) ); + } + + $first_layout = ''; + + // Loop through layouts. + foreach ( $layouts as $key => $layout ) { + + // Skip over active layout key. + if ( 'active_layout' === $key ) { + continue; + } + + // Check if the key exists then set value. + if ( isset( $option_tree_layouts[ $key ] ) && ! empty( $option_tree_layouts[ $key ] ) ) { + $rebuild[ $key ] = $option_tree_layouts[ $key ]; + if ( '' === $first_layout ) { + $first_layout = $key; + } + } + } + + if ( isset( $rebuild['active_layout'] ) && ! isset( $rebuild[ $rebuild['active_layout'] ] ) && ! empty( $first_layout ) ) { + $rebuild['active_layout'] = $first_layout; + } + } + + // Default message. + $message = 'failed'; + + // Save & show success message. + if ( is_array( $rebuild ) && 1 < count( $rebuild ) ) { + + $decoded = ot_decode( $rebuild[ $rebuild['active_layout'] ] ); + + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( $matches ) { + + // Rebuild the theme options. + $rebuild_option_tree = maybe_unserialize( $decoded ); + + if ( is_array( $rebuild_option_tree ) ) { + + // Execute the action hook and pass the theme options to it. + do_action( 'ot_before_theme_options_save', $rebuild_option_tree ); + + update_option( ot_options_id(), $rebuild_option_tree ); + } + } + + // Rebuild the layouts. + update_option( ot_layouts_id(), $rebuild ); + + // Change message. + $message = 'success'; + } elseif ( 1 >= count( $rebuild ) ) { + + // Delete layouts option. + delete_option( ot_layouts_id() ); + + // Change message. + $message = 'deleted'; + } + + // Redirect. + if ( isset( $_REQUEST['page'] ) && apply_filters( 'ot_theme_options_menu_slug', 'ot-theme-options' ) === $_REQUEST['page'] ) { + $query_args = esc_url_raw( + add_query_arg( + array( + 'settings-updated' => 'layout', + ), + remove_query_arg( + array( + 'action', + 'message', + ), + wp_get_referer() + ) + ) + ); + } else { + $query_args = esc_url_raw( + add_query_arg( + array( + 'action' => 'save-layouts', + 'message' => $message, + ), + wp_get_referer() + ) + ); + } + wp_safe_redirect( $query_args ); + exit; + } + + return false; + } } -/** - * Custom stripslashes from single value or array. - * - * @param mixed $input - * @return mixed - * - * @access public - * @since 2.0 - */ -if ( ! function_exists( 'ot_stripslashes' ) ) { +if ( ! function_exists( 'ot_alert_message' ) ) { - function ot_stripslashes( $input ) { - - if ( is_array( $input ) ) { - - foreach( $input as &$val ) { - - if ( is_array( $val ) ) { - - $val = ot_stripslashes( $val ); - - } else { - - $val = stripslashes( trim( $val ) ); - - } - - } - - } else { - - $input = stripslashes( trim( $input ) ); - - } - - return $input; - - } + /** + * Helper function to display alert messages. + * + * @param array $page Page array. + * @return mixed + * + * @access public + * @since 2.0 + */ + function ot_alert_message( $page = array() ) { -} + if ( empty( $page ) ) { + return false; + } -/** - * Reverse wpautop. - * - * @param string $string The string to be filtered - * @return string - * - * @access public - * @since 2.0.9 - */ -if ( ! function_exists( 'ot_reverse_wpautop' ) ) { + $before = apply_filters( 'ot_before_page_messages', '', $page ); - function ot_reverse_wpautop( $string = '' ) { - - /* return if string is empty */ - if ( trim( $string ) === '' ) - return ''; - - /* remove all new lines &

      tags */ - $string = str_replace( array( "\n", "

      " ), "", $string ); - - /* replace
      with \r */ - $string = str_replace( array( "
      ", "
      ", "
      " ), "\r", $string ); - - /* replace

      with \r\n */ - $string = str_replace( "

      ", "\r\n", $string ); - - /* return clean string */ - return trim( $string ); - - } + if ( $before ) { + return $before; + } -} + $action = isset( $_REQUEST['action'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) : ''; // phpcs:ignore + $message = isset( $_REQUEST['message'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['message'] ) ) : ''; // phpcs:ignore + $updated = isset( $_REQUEST['settings-updated'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings-updated'] ) ) : ''; // phpcs:ignore -/** - * Returns an array of elements from start to limit, inclusive. - * - * Occasionally zero will be some impossibly large number to - * the "E" power when creating a range from negative to positive. - * This function attempts to fix that by setting that number back to "0". - * - * @param string $start First value of the sequence. - * @param string $limit The sequence is ended upon reaching the limit value. - * @param string $step If a step value is given, it will be used as the increment - * between elements in the sequence. step should be given as a - * positive number. If not specified, step will default to 1. - * @return array - * - * @access public - * @since 2.0.12 - */ -function ot_range( $start, $limit, $step = 1 ) { - - if ( $step < 0 ) - $step = 1; - - $range = range( $start, $limit, $step ); - - foreach( $range as $k => $v ) { - if ( strpos( $v, 'E' ) ) { - $range[$k] = 0; - } - } - - return $range; -} + if ( 'save-settings' === $action ) { -/** - * Helper function to return encoded strings - * - * @return string - * - * @access public - * @since 2.0.13 - */ -function ot_encode( $value ) { + if ( 'success' === $message ) { - $func = 'base64' . '_encode'; - return $func( $value ); - -} + return '

      ' . esc_html__( 'Settings updated.', 'option-tree' ) . '

      '; -/** - * Helper function to return decoded strings - * - * @return string - * - * @access public - * @since 2.0.13 - */ -function ot_decode( $value ) { + } elseif ( 'failed' === $message ) { - $func = 'base64' . '_decode'; - return $func( $value ); - -} + return '

      ' . esc_html__( 'Settings could not be saved.', 'option-tree' ) . '

      '; -/** - * Helper function to open a file - * - * @access public - * @since 2.0.13 - */ -function ot_file_open( $handle, $mode ) { + } + } elseif ( 'import-xml' === $action || 'import-settings' === $action ) { - $func = 'f' . 'open'; - return @$func( $handle, $mode ); - -} + if ( 'success' === $message ) { -/** - * Helper function to close a file - * - * @access public - * @since 2.0.13 - */ -function ot_file_close( $handle ) { + return '

      ' . esc_html__( 'Settings Imported.', 'option-tree' ) . '

      '; - $func = 'f' . 'close'; - return $func( $handle ); - -} + } elseif ( 'failed' === $message ) { -/** - * Helper function to write to an open file - * - * @access public - * @since 2.0.13 - */ -function ot_file_write( $handle, $string ) { + return '

      ' . esc_html__( 'Settings could not be imported.', 'option-tree' ) . '

      '; - $func = 'f' . 'write'; - return $func( $handle, $string ); - -} + } + } elseif ( 'import-data' === $action ) { -/** - * Helper function to filter standard option values. - * - * @param mixed $value Saved string or array value - * @param mixed $std Standard string or array value - * @return mixed String or array - * - * @access public - * @since 2.0.15 - */ -function ot_filter_std_value( $value = '', $std = '' ) { - - $std = maybe_unserialize( $std ); - - if ( is_array( $value ) && is_array( $std ) ) { - - foreach( $value as $k => $v ) { - - if ( '' == $value[$k] && isset( $std[$k] ) ) { - - $value[$k] = $std[$k]; - - } - - } - - } else if ( '' == $value && ! empty( $std ) ) { - - $value = $std; - - } + if ( 'success' === $message ) { - return $value; - -} + return '

      ' . esc_html__( 'Data Imported.', 'option-tree' ) . '

      '; -/** - * Helper function to set the Google fonts array. - * - * @param string $id The option ID. - * @param bool $value The option value - * @return void - * - * @access public - * @since 2.5.0 - */ -function ot_set_google_fonts( $id = '', $value = '' ) { + } elseif ( 'failed' === $message ) { - $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + return '

      ' . esc_html__( 'Data could not be imported.', 'option-tree' ) . '

      '; - if ( is_array( $value ) && ! empty( $value ) ) { - $ot_set_google_fonts[$id] = $value; - } else if ( isset( $ot_set_google_fonts[$id] ) ) { - unset( $ot_set_google_fonts[$id] ); - } + } + } elseif ( 'import-layouts' === $action ) { - set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts ); + if ( 'success' === $message ) { -} + return '

      ' . esc_html__( 'Layouts Imported.', 'option-tree' ) . '

      '; -/** - * Helper function to remove unused options from the Google fonts array. - * - * @param array $options The array of saved options. - * @return array - * - * @access public - * @since 2.5.0 - */ -function ot_update_google_fonts_after_save( $options ) { + } elseif ( 'failed' === $message ) { - $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + return '

      ' . esc_html__( 'Layouts could not be imported.', 'option-tree' ) . '

      '; - foreach( $ot_set_google_fonts as $key => $set ) { - if ( ! isset( $options[$key] ) ) { - unset( $ot_set_google_fonts[$key] ); - } - } - set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts ); + } + } elseif ( 'save-layouts' === $action ) { -} -add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 ); + if ( 'success' === $message ) { -/** - * Helper function to fetch the Google fonts array. - * - * @param bool $normalize Whether or not to return a normalized array. Default 'true'. - * @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'. - * @return array - * - * @access public - * @since 2.5.0 - */ -function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) { + return '

      ' . esc_html__( 'Layouts Updated.', 'option-tree' ) . '

      '; - /* Google Fonts cache key */ - $ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' ); + } elseif ( 'failed' === $message ) { - /* get the fonts from cache */ - $ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) ); + return '

      ' . esc_html__( 'Layouts could not be updated.', 'option-tree' ) . '

      '; - if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) { + } elseif ( 'deleted' === $message ) { - $ot_google_fonts = array(); + return '

      ' . esc_html__( 'Layouts have been deleted.', 'option-tree' ) . '

      '; - // API url and key. - $ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' ); - $ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', false ); + } + } elseif ( 'layout' === $updated ) { - if ( false === $ot_google_fonts_api_key ) { - return array(); - } + return '

      ' . esc_html__( 'Layout activated.', 'option-tree' ) . '

      '; - /* API arguments */ - $ot_google_fonts_fields = apply_filters( 'ot_google_fonts_fields', array( 'family', 'variants', 'subsets' ) ); - $ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' ); + } elseif ( 'reset' === $action ) { - /* Initiate API request */ - $ot_google_fonts_query_args = array( - 'key' => $ot_google_fonts_api_key, - 'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', - 'sort' => $ot_google_fonts_sort, - ); + return '

      ' . $page['reset_message'] . '

      '; - /* Build and make the request */ - $ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) ); - $ot_google_fonts_response = wp_safe_remote_get( $ot_google_fonts_query, array( 'sslverify' => false, 'timeout' => 15 ) ); + } - /* continue if we got a valid response */ - if ( 200 == wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) { + do_action( 'ot_custom_page_messages', $page ); - if ( $response_body = wp_remote_retrieve_body( $ot_google_fonts_response ) ) { + if ( 'true' === $updated || true === $updated ) { + return '

      ' . $page['updated_message'] . '

      '; + } + + return false; + } +} - /* JSON decode the response body and cache the result */ - $ot_google_fonts_data = json_decode( trim( $response_body ), true ); +if ( ! function_exists( 'ot_option_types_array' ) ) { - if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) { + /** + * Setup the default option types. + * + * The returned option types are filterable so you can add your own. + * This is not a task for a beginner as you'll need to add the function + * that displays the option to the user and validate the saved data. + * + * @return array + * + * @access public + * @since 2.0 + */ + function ot_option_types_array() { + + return apply_filters( + 'ot_option_types_array', + array( + 'background' => esc_html__( 'Background', 'option-tree' ), + 'border' => esc_html__( 'Border', 'option-tree' ), + 'box-shadow' => esc_html__( 'Box Shadow', 'option-tree' ), + 'category-checkbox' => esc_html__( 'Category Checkbox', 'option-tree' ), + 'category-select' => esc_html__( 'Category Select', 'option-tree' ), + 'checkbox' => esc_html__( 'Checkbox', 'option-tree' ), + 'colorpicker' => esc_html__( 'Colorpicker', 'option-tree' ), + 'colorpicker-opacity' => esc_html__( 'Colorpicker Opacity', 'option-tree' ), + 'css' => esc_html__( 'CSS', 'option-tree' ), + 'custom-post-type-checkbox' => esc_html__( 'Custom Post Type Checkbox', 'option-tree' ), + 'custom-post-type-select' => esc_html__( 'Custom Post Type Select', 'option-tree' ), + 'date-picker' => esc_html__( 'Date Picker', 'option-tree' ), + 'date-time-picker' => esc_html__( 'Date Time Picker', 'option-tree' ), + 'dimension' => esc_html__( 'Dimension', 'option-tree' ), + 'gallery' => esc_html__( 'Gallery', 'option-tree' ), + 'google-fonts' => esc_html__( 'Google Fonts', 'option-tree' ), + 'javascript' => esc_html__( 'JavaScript', 'option-tree' ), + 'link-color' => esc_html__( 'Link Color', 'option-tree' ), + 'list-item' => esc_html__( 'List Item', 'option-tree' ), + 'measurement' => esc_html__( 'Measurement', 'option-tree' ), + 'numeric-slider' => esc_html__( 'Numeric Slider', 'option-tree' ), + 'on-off' => esc_html__( 'On/Off', 'option-tree' ), + 'page-checkbox' => esc_html__( 'Page Checkbox', 'option-tree' ), + 'page-select' => esc_html__( 'Page Select', 'option-tree' ), + 'post-checkbox' => esc_html__( 'Post Checkbox', 'option-tree' ), + 'post-select' => esc_html__( 'Post Select', 'option-tree' ), + 'radio' => esc_html__( 'Radio', 'option-tree' ), + 'radio-image' => esc_html__( 'Radio Image', 'option-tree' ), + 'select' => esc_html__( 'Select', 'option-tree' ), + 'sidebar-select' => esc_html__( 'Sidebar Select', 'option-tree' ), + 'slider' => esc_html__( 'Slider', 'option-tree' ), + 'social-links' => esc_html__( 'Social Links', 'option-tree' ), + 'spacing' => esc_html__( 'Spacing', 'option-tree' ), + 'tab' => esc_html__( 'Tab', 'option-tree' ), + 'tag-checkbox' => esc_html__( 'Tag Checkbox', 'option-tree' ), + 'tag-select' => esc_html__( 'Tag Select', 'option-tree' ), + 'taxonomy-checkbox' => esc_html__( 'Taxonomy Checkbox', 'option-tree' ), + 'taxonomy-select' => esc_html__( 'Taxonomy Select', 'option-tree' ), + 'text' => esc_html__( 'Text', 'option-tree' ), + 'textarea' => esc_html__( 'Textarea', 'option-tree' ), + 'textarea-simple' => esc_html__( 'Textarea Simple', 'option-tree' ), + 'textblock' => esc_html__( 'Textblock', 'option-tree' ), + 'textblock-titled' => esc_html__( 'Textblock Titled', 'option-tree' ), + 'typography' => esc_html__( 'Typography', 'option-tree' ), + 'upload' => esc_html__( 'Upload', 'option-tree' ), + ) + ); + } +} - $ot_google_fonts = $ot_google_fonts_data['items']; - - // Normalize the array key - $ot_google_fonts_tmp = array(); - foreach( $ot_google_fonts as $key => $value ) { - $id = remove_accents( $value['family'] ); - $id = strtolower( $id ); - $id = preg_replace( '/[^a-z0-9_\-]/', '', $id ); - $ot_google_fonts_tmp[$id] = $value; - } - - $ot_google_fonts = $ot_google_fonts_tmp; - set_theme_mod( 'ot_google_fonts', $ot_google_fonts ); - set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS ); +if ( ! function_exists( 'ot_map_old_option_types' ) ) { - } + /** + * Map old option types for rebuilding XML and Table data. + * + * @param string $type The old option type. + * @return string The new option type + * + * @access public + * @since 2.0 + */ + function ot_map_old_option_types( $type = '' ) { + + if ( empty( $type ) ) { + return 'text'; + } + + $types = array( + 'background' => 'background', + 'category' => 'category-select', + 'categories' => 'category-checkbox', + 'checkbox' => 'checkbox', + 'colorpicker' => 'colorpicker', + 'css' => 'css', + 'custom_post' => 'custom-post-type-select', + 'custom_posts' => 'custom-post-type-checkbox', + 'input' => 'text', + 'image' => 'upload', + 'measurement' => 'measurement', + 'page' => 'page-select', + 'pages' => 'page-checkbox', + 'post' => 'post-select', + 'posts' => 'post-checkbox', + 'radio' => 'radio', + 'select' => 'select', + 'slider' => 'slider', + 'tag' => 'tag-select', + 'tags' => 'tag-checkbox', + 'textarea' => 'textarea', + 'textblock' => 'textblock', + 'typography' => 'typography', + 'upload' => 'upload', + ); + + if ( isset( $types[ $type ] ) ) { + return $types[ $type ]; + } + + return false; + } +} - } +if ( ! function_exists( 'ot_google_font_stack' ) ) { + + /** + * Filters the typography font-family to add Google fonts dynamically. + * + * @param array $families An array of all recognized font families. + * @param string $field_id ID of the field being filtered. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_google_font_stack( $families, $field_id ) { + + if ( ! is_array( $families ) ) { + return array(); + } + + $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); + $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + + if ( ! empty( $ot_set_google_fonts ) ) { + foreach ( $ot_set_google_fonts as $id => $sets ) { + foreach ( $sets as $value ) { + $family = isset( $value['family'] ) ? $value['family'] : ''; + if ( $family && isset( $ot_google_fonts[ $family ] ) ) { + $spaces = explode( ' ', $ot_google_fonts[ $family ]['family'] ); + $font_stack = count( $spaces ) > 1 ? '"' . $ot_google_fonts[ $family ]['family'] . '"' : $ot_google_fonts[ $family ]['family']; + $families[ $family ] = apply_filters( 'ot_google_font_stack', $font_stack, $family, $field_id ); + } + } + } + } + + return $families; + } + + add_filter( 'ot_recognized_font_families', 'ot_google_font_stack', 1, 2 ); +} - } +if ( ! function_exists( 'ot_recognized_font_families' ) ) { - } + /** + * Recognized font families + * + * Returns an array of all recognized font families. + * Keys are intended to be stored in the database + * while values are ready for display in html. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_font_families( $field_id ) { + + $families = array( + 'arial' => 'Arial', + 'georgia' => 'Georgia', + 'helvetica' => 'Helvetica', + 'palatino' => 'Palatino', + 'tahoma' => 'Tahoma', + 'times' => '"Times New Roman", sans-serif', + 'trebuchet' => 'Trebuchet', + 'verdana' => 'Verdana', + ); + + return apply_filters( 'ot_recognized_font_families', $families, $field_id ); + } +} - return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts; +if ( ! function_exists( 'ot_recognized_font_sizes' ) ) { + /** + * Recognized font sizes + * + * Returns an array of all recognized font sizes. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0.12 + */ + function ot_recognized_font_sizes( $field_id ) { + + $range = ot_range( + apply_filters( 'ot_font_size_low_range', 0, $field_id ), + apply_filters( 'ot_font_size_high_range', 150, $field_id ), + apply_filters( 'ot_font_size_range_interval', 1, $field_id ) + ); + + $unit = apply_filters( 'ot_font_size_unit_type', 'px', $field_id ); + + foreach ( $range as $k => $v ) { + $range[ $k ] = $v . $unit; + } + + return apply_filters( 'ot_recognized_font_sizes', $range, $field_id ); + } } -/** - * Helper function to normalize the Google fonts array. - * - * @param array $google_fonts An array of fonts to nrmalize. - * @return array - * - * @access public - * @since 2.5.0 - */ -function ot_normalize_google_fonts( $google_fonts ) { +if ( ! function_exists( 'ot_recognized_font_styles' ) ) { - $ot_normalized_google_fonts = array(); + /** + * Recognized font styles + * + * Returns an array of all recognized font styles. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_font_styles( $field_id ) { + + return apply_filters( + 'ot_recognized_font_styles', + array( + 'normal' => 'Normal', + 'italic' => 'Italic', + 'oblique' => 'Oblique', + 'inherit' => 'Inherit', + ), + $field_id + ); + } +} - if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) { +if ( ! function_exists( 'ot_recognized_font_variants' ) ) { - foreach( $google_fonts as $google_font ) { + /** + * Recognized font variants + * + * Returns an array of all recognized font variants. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_font_variants( $field_id ) { + + return apply_filters( + 'ot_recognized_font_variants', + array( + 'normal' => 'Normal', + 'small-caps' => 'Small Caps', + 'inherit' => 'Inherit', + ), + $field_id + ); + } +} - if( isset( $google_font['family'] ) ) { +if ( ! function_exists( 'ot_recognized_font_weights' ) ) { - $id = str_replace( ' ', '+', $google_font['family'] ); + /** + * Recognized font weights + * + * Returns an array of all recognized font weights. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_font_weights( $field_id ) { + + return apply_filters( + 'ot_recognized_font_weights', + array( + 'normal' => 'Normal', + 'bold' => 'Bold', + 'bolder' => 'Bolder', + 'lighter' => 'Lighter', + '100' => '100', + '200' => '200', + '300' => '300', + '400' => '400', + '500' => '500', + '600' => '600', + '700' => '700', + '800' => '800', + '900' => '900', + 'inherit' => 'Inherit', + ), + $field_id + ); + } +} - $ot_normalized_google_fonts[ $id ] = array( - 'family' => $google_font['family'] - ); +if ( ! function_exists( 'ot_recognized_letter_spacing' ) ) { - if( isset( $google_font['variants'] ) ) { + /** + * Recognized letter spacing + * + * Returns an array of all recognized line heights. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0.12 + */ + function ot_recognized_letter_spacing( $field_id ) { + + $range = ot_range( + apply_filters( 'ot_letter_spacing_low_range', -0.1, $field_id ), + apply_filters( 'ot_letter_spacing_high_range', 0.1, $field_id ), + apply_filters( 'ot_letter_spacing_range_interval', 0.01, $field_id ) + ); + + $unit = apply_filters( 'ot_letter_spacing_unit_type', 'em', $field_id ); + + foreach ( $range as $k => $v ) { + $range[ $k ] = $v . $unit; + } + + return apply_filters( 'ot_recognized_letter_spacing', $range, $field_id ); + } +} - $ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants']; +if ( ! function_exists( 'ot_recognized_line_heights' ) ) { - } + /** + * Recognized line heights + * + * Returns an array of all recognized line heights. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0.12 + */ + function ot_recognized_line_heights( $field_id ) { + + $range = ot_range( + apply_filters( 'ot_line_height_low_range', 0, $field_id ), + apply_filters( 'ot_line_height_high_range', 150, $field_id ), + apply_filters( 'ot_line_height_range_interval', 1, $field_id ) + ); + + $unit = apply_filters( 'ot_line_height_unit_type', 'px', $field_id ); + + foreach ( $range as $k => $v ) { + $range[ $k ] = $v . $unit; + } + + return apply_filters( 'ot_recognized_line_heights', $range, $field_id ); + } +} - if( isset( $google_font['subsets'] ) ) { +if ( ! function_exists( 'ot_recognized_text_decorations' ) ) { - $ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets']; + /** + * Recognized text decorations + * + * Returns an array of all recognized text decorations. + * Keys are intended to be stored in the database + * while values are ready for display in html. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0.10 + */ + function ot_recognized_text_decorations( $field_id ) { + + return apply_filters( + 'ot_recognized_text_decorations', + array( + 'blink' => 'Blink', + 'inherit' => 'Inherit', + 'line-through' => 'Line Through', + 'none' => 'None', + 'overline' => 'Overline', + 'underline' => 'Underline', + ), + $field_id + ); + } +} - } +if ( ! function_exists( 'ot_recognized_text_transformations' ) ) { - } + /** + * Recognized text transformations + * + * Returns an array of all recognized text transformations. + * Keys are intended to be stored in the database + * while values are ready for display in html. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0.10 + */ + function ot_recognized_text_transformations( $field_id ) { + + return apply_filters( + 'ot_recognized_text_transformations', + array( + 'capitalize' => 'Capitalize', + 'inherit' => 'Inherit', + 'lowercase' => 'Lowercase', + 'none' => 'None', + 'uppercase' => 'Uppercase', + ), + $field_id + ); + } +} - } +if ( ! function_exists( 'ot_recognized_background_repeat' ) ) { - } + /** + * Recognized background repeat + * + * Returns an array of all recognized background repeat values. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_background_repeat( $field_id ) { + + return apply_filters( + 'ot_recognized_background_repeat', + array( + 'no-repeat' => 'No Repeat', + 'repeat' => 'Repeat All', + 'repeat-x' => 'Repeat Horizontally', + 'repeat-y' => 'Repeat Vertically', + 'inherit' => 'Inherit', + ), + $field_id + ); + } +} - return $ot_normalized_google_fonts; +if ( ! function_exists( 'ot_recognized_background_attachment' ) ) { + /** + * Recognized background attachment + * + * Returns an array of all recognized background attachment values. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_background_attachment( $field_id ) { + + return apply_filters( + 'ot_recognized_background_attachment', + array( + 'fixed' => 'Fixed', + 'scroll' => 'Scroll', + 'inherit' => 'Inherit', + ), + $field_id + ); + } } -/** - * Helper function to register a WPML string - * - * @access public - * @since 2.1 - */ -function ot_wpml_register_string( $id, $value ) { +if ( ! function_exists( 'ot_recognized_background_position' ) ) { - if ( function_exists( 'icl_register_string' ) ) { - - icl_register_string( 'Theme Options', $id, $value ); - - } - + /** + * Recognized background position + * + * Returns an array of all recognized background position values. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_recognized_background_position( $field_id ) { + + return apply_filters( + 'ot_recognized_background_position', + array( + 'left top' => 'Left Top', + 'left center' => 'Left Center', + 'left bottom' => 'Left Bottom', + 'center top' => 'Center Top', + 'center center' => 'Center Center', + 'center bottom' => 'Center Bottom', + 'right top' => 'Right Top', + 'right center' => 'Right Center', + 'right bottom' => 'Right Bottom', + ), + $field_id + ); + + } } -/** - * Helper function to unregister a WPML string - * - * @access public - * @since 2.1 - */ -function ot_wpml_unregister_string( $id ) { +if ( ! function_exists( 'ot_recognized_border_style_types' ) ) { - if ( function_exists( 'icl_unregister_string' ) ) { - - icl_unregister_string( 'Theme Options', $id ); - - } - + /** + * Returns an array of all available border style types. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_border_style_types( $field_id ) { + + return apply_filters( + 'ot_recognized_border_style_types', + array( + 'hidden' => 'Hidden', + 'dashed' => 'Dashed', + 'solid' => 'Solid', + 'double' => 'Double', + 'groove' => 'Groove', + 'ridge' => 'Ridge', + 'inset' => 'Inset', + 'outset' => 'Outset', + ), + $field_id + ); + + } } -/** - * Maybe migrate Settings - * - * @return void - * - * @access public - * @since 2.3.3 - */ -if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) { +if ( ! function_exists( 'ot_recognized_border_unit_types' ) ) { - function ot_maybe_migrate_settings() { - - // Filter the ID to migrate from - $settings_id = apply_filters( 'ot_migrate_settings_id', '' ); - - // Attempt to migrate Settings - if ( ! empty( $settings_id ) && get_option( ot_settings_id() ) === false && ot_settings_id() !== $settings_id ) { - - // Old settings - $settings = get_option( $settings_id ); - - // Check for array keys - if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) { - - update_option( ot_settings_id(), $settings ); - - } - - } - - } - + /** + * Returns an array of all available border unit types. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_border_unit_types( $field_id ) { + + return apply_filters( + 'ot_recognized_border_unit_types', + array( + 'px' => 'px', + '%' => '%', + 'em' => 'em', + 'pt' => 'pt', + ), + $field_id + ); + } } -/** - * Maybe migrate Option - * - * @return void - * - * @access public - * @since 2.3.3 - */ -if ( ! function_exists( 'ot_maybe_migrate_options' ) ) { +if ( ! function_exists( 'ot_recognized_dimension_unit_types' ) ) { - function ot_maybe_migrate_options() { - - // Filter the ID to migrate from - $options_id = apply_filters( 'ot_migrate_options_id', '' ); - - // Attempt to migrate Theme Options - if ( ! empty( $options_id ) && get_option( ot_options_id() ) === false && ot_options_id() !== $options_id ) { - - // Old options - $options = get_option( $options_id ); - - // Migrate to new ID - update_option( ot_options_id(), $options ); - - } - - } - + /** + * Returns an array of all available dimension unit types. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_dimension_unit_types( $field_id = '' ) { + + return apply_filters( + 'ot_recognized_dimension_unit_types', + array( + 'px' => 'px', + '%' => '%', + 'em' => 'em', + 'pt' => 'pt', + ), + $field_id + ); + } } -/** - * Maybe migrate Layouts - * - * @return void - * - * @access public - * @since 2.3.3 - */ -if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) { +if ( ! function_exists( 'ot_recognized_spacing_unit_types' ) ) { + + /** + * Returns an array of all available spacing unit types. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_spacing_unit_types( $field_id ) { + + return apply_filters( + 'ot_recognized_spacing_unit_types', + array( + 'px' => 'px', + '%' => '%', + 'em' => 'em', + 'pt' => 'pt', + ), + $field_id + ); + + } +} - function ot_maybe_migrate_layouts() { - - // Filter the ID to migrate from - $layouts_id = apply_filters( 'ot_migrate_layouts_id', '' ); - - // Attempt to migrate Layouts - if ( ! empty( $layouts_id ) && get_option( ot_layouts_id() ) === false && ot_layouts_id() !== $layouts_id ) { - - // Old options - $layouts = get_option( $layouts_id ); - - // Migrate to new ID - update_option( ot_layouts_id(), $layouts ); - - } - - } +if ( ! function_exists( 'ot_recognized_google_font_families' ) ) { + /** + * Recognized Google font families + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_google_font_families( $field_id ) { + + $families = array(); + $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); + + // Forces an array rebuild when we switch themes. + if ( empty( $ot_google_fonts ) ) { + $ot_google_fonts = ot_fetch_google_fonts( true, true ); + } + + foreach ( (array) $ot_google_fonts as $key => $item ) { + + if ( isset( $item['family'] ) ) { + $families[ $key ] = $item['family']; + } + } + + return apply_filters( 'ot_recognized_google_font_families', $families, $field_id ); + } } -/** - * Returns an array with the post format gallery meta box. - * - * @param mixed $pages Excepts a comma separated string or array of - * post_types and is what tells the metabox where to - * display. Default 'post'. - * @return array - * - * @access public - * @since 2.4.0 - */ -function ot_meta_box_post_format_gallery( $pages = 'post' ) { +if ( ! function_exists( 'ot_recognized_google_font_variants' ) ) { - if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ) ) ) - return false; - - if ( is_string( $pages ) ) - $pages = explode( ',', $pages ); - - return apply_filters( 'ot_meta_box_post_format_gallery', array( - 'id' => 'ot-post-format-gallery', - 'title' => __( 'Gallery', 'option-tree' ), - 'desc' => '', - 'pages' => $pages, - 'context' => 'side', - 'priority' => 'low', - 'fields' => array( - array( - 'id' => '_format_gallery', - 'label' => '', - 'desc' => '', - 'std' => '', - 'type' => 'gallery', - 'class' => 'ot-gallery-shortcode' - ) - ) - ), $pages ); + /** + * Recognized Google font variants + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * @param string $family The font family. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_google_font_variants( $field_id, $family ) { + + $variants = array(); + $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); + + if ( isset( $ot_google_fonts[ $family ]['variants'] ) ) { + $variants = $ot_google_fonts[ $family ]['variants']; + } + + return apply_filters( 'ot_recognized_google_font_variants', $variants, $field_id, $family ); + } +} + +if ( ! function_exists( 'ot_recognized_google_font_subsets' ) ) { + /** + * Recognized Google font subsets + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * @param string $family The font family. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_recognized_google_font_subsets( $field_id, $family ) { + + $subsets = array(); + $ot_google_fonts = get_theme_mod( 'ot_google_fonts', array() ); + + if ( isset( $ot_google_fonts[ $family ]['subsets'] ) ) { + $subsets = $ot_google_fonts[ $family ]['subsets']; + } + + return apply_filters( 'ot_recognized_google_font_subsets', $subsets, $field_id, $family ); + } } -/** - * Returns an array with the post format link metabox. - * - * @param mixed $pages Excepts a comma separated string or array of - * post_types and is what tells the metabox where to - * display. Default 'post'. - * @return array - * - * @access public - * @since 2.4.0 - */ -function ot_meta_box_post_format_link( $pages = 'post' ) { - - if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ) ) ) - return false; - - if ( is_string( $pages ) ) - $pages = explode( ',', $pages ); - - return apply_filters( 'ot_meta_box_post_format_link', array( - 'id' => 'ot-post-format-link', - 'title' => __( 'Link', 'option-tree' ), - 'desc' => '', - 'pages' => $pages, - 'context' => 'side', - 'priority' => 'low', - 'fields' => array( - array( - 'id' => '_format_link_url', - 'label' => '', - 'desc' => __( 'Link URL', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ), - array( - 'id' => '_format_link_title', - 'label' => '', - 'desc' => __( 'Link Title', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ) - ) - ), $pages ); +if ( ! function_exists( 'ot_measurement_unit_types' ) ) { + /** + * Measurement Units + * + * Returns an array of all available unit types. + * Renamed in version 2.0 to avoid name collisions. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 1.1.8 + * @since 2.0 + */ + function ot_measurement_unit_types( $field_id = '' ) { + + return apply_filters( + 'ot_measurement_unit_types', + array( + 'px' => 'px', + '%' => '%', + 'em' => 'em', + 'pt' => 'pt', + ), + $field_id + ); + + } } -/** - * Returns an array with the post format quote metabox. - * - * @param mixed $pages Excepts a comma separated string or array of - * post_types and is what tells the metabox where to - * display. Default 'post'. - * @return array - * - * @access public - * @since 2.4.0 - */ -function ot_meta_box_post_format_quote( $pages = 'post' ) { - - if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ) ) ) - return false; - - if ( is_string( $pages ) ) - $pages = explode( ',', $pages ); - - return apply_filters( 'ot_meta_box_post_format_quote', array( - 'id' => 'ot-post-format-quote', - 'title' => __( 'Quote', 'option-tree' ), - 'desc' => '', - 'pages' => $pages, - 'context' => 'side', - 'priority' => 'low', - 'fields' => array( - array( - 'id' => '_format_quote_source_name', - 'label' => '', - 'desc' => __( 'Source Name (ex. author, singer, actor)', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ), - array( - 'id' => '_format_quote_source_url', - 'label' => '', - 'desc' => __( 'Source URL', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ), - array( - 'id' => '_format_quote_source_title', - 'label' => '', - 'desc' => __( 'Source Title (ex. book, song, movie)', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ), - array( - 'id' => '_format_quote_source_date', - 'label' => '', - 'desc' => __( 'Source Date', 'option-tree' ), - 'std' => '', - 'type' => 'text' - ) - ) - ), $pages ); +if ( ! function_exists( 'ot_radio_images' ) ) { + /** + * Radio Images default array. + * + * Returns an array of all available radio images. + * You can filter this function to change the images + * on a per option basis. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0 + */ + function ot_radio_images( $field_id ) { + + return apply_filters( + 'ot_radio_images', + array( + array( + 'value' => 'left-sidebar', + 'label' => esc_html__( 'Left Sidebar', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/left-sidebar.png', + ), + array( + 'value' => 'right-sidebar', + 'label' => esc_html__( 'Right Sidebar', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/right-sidebar.png', + ), + array( + 'value' => 'full-width', + 'label' => esc_html__( 'Full Width (no sidebar)', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/full-width.png', + ), + array( + 'value' => 'dual-sidebar', + 'label' => esc_html__( 'Dual Sidebar', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/dual-sidebar.png', + ), + array( + 'value' => 'left-dual-sidebar', + 'label' => esc_html__( 'Left Dual Sidebar', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/left-dual-sidebar.png', + ), + array( + 'value' => 'right-dual-sidebar', + 'label' => esc_html__( 'Right Dual Sidebar', 'option-tree' ), + 'src' => OT_URL . 'assets/images/layout/right-dual-sidebar.png', + ), + ), + $field_id + ); + + } } -/** - * Returns an array with the post format video metabox. - * - * @param mixed $pages Excepts a comma separated string or array of - * post_types and is what tells the metabox where to - * display. Default 'post'. - * @return array - * - * @access public - * @since 2.4.0 - */ -function ot_meta_box_post_format_video( $pages = 'post' ) { - - if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ) ) ) - return false; - - if ( is_string( $pages ) ) - $pages = explode( ',', $pages ); - - return apply_filters( 'ot_meta_box_post_format_video', array( - 'id' => 'ot-post-format-video', - 'title' => __( 'Video', 'option-tree' ), - 'desc' => '', - 'pages' => $pages, - 'context' => 'side', - 'priority' => 'low', - 'fields' => array( - array( - 'id' => '_format_video_embed', - 'label' => '', - 'desc' => sprintf( __( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '' . __( 'Wordpress Codex', 'option-tree' ) .'', '[video]' ), - 'std' => '', - 'type' => 'textarea' - ) - ) - ), $pages ); +if ( ! function_exists( 'ot_list_item_settings' ) ) { + /** + * Default List Item Settings array. + * + * Returns an array of the default list item settings. + * You can filter this function to change the settings + * on a per option basis. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0 + */ + function ot_list_item_settings( $field_id ) { + + $settings = apply_filters( + 'ot_list_item_settings', + array( + array( + 'id' => 'image', + 'label' => esc_html__( 'Image', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'upload', + 'rows' => '', + 'class' => '', + 'post_type' => '', + 'choices' => array(), + ), + array( + 'id' => 'link', + 'label' => esc_html__( 'Link', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'text', + 'rows' => '', + 'class' => '', + 'post_type' => '', + 'choices' => array(), + ), + array( + 'id' => 'description', + 'label' => esc_html__( 'Description', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'textarea-simple', + 'rows' => 10, + 'class' => '', + 'post_type' => '', + 'choices' => array(), + ), + ), + $field_id + ); + + return $settings; + } } -/** - * Returns an array with the post format audio metabox. - * - * @param mixed $pages Excepts a comma separated string or array of - * post_types and is what tells the metabox where to - * display. Default 'post'. - * @return array - * - * @access public - * @since 2.4.0 - */ -function ot_meta_box_post_format_audio( $pages = 'post' ) { - - if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ) ) ) - return false; - - if ( is_string( $pages ) ) - $pages = explode( ',', $pages ); - - return apply_filters( 'ot_meta_box_post_format_audio', array( - 'id' => 'ot-post-format-audio', - 'title' => __( 'Audio', 'option-tree' ), - 'desc' => '', - 'pages' => $pages, - 'context' => 'side', - 'priority' => 'low', - 'fields' => array( - array( - 'id' => '_format_audio_embed', - 'label' => '', - 'desc' => sprintf( __( 'Embed audio from services like SoundCloud and Rdio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ), '' . __( 'Wordpress Codex', 'option-tree' ) .'', '[audio]' ), - 'std' => '', - 'type' => 'textarea' - ) - ) - ), $pages ); +if ( ! function_exists( 'ot_slider_settings' ) ) { + /** + * Default Slider Settings array. + * + * Returns an array of the default slider settings. + * You can filter this function to change the settings + * on a per option basis. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.0 + */ + function ot_slider_settings( $field_id ) { + + $settings = apply_filters( + 'image_slider_fields', + array( + array( + 'name' => 'image', + 'type' => 'image', + 'label' => esc_html__( 'Image', 'option-tree' ), + 'class' => '', + ), + array( + 'name' => 'link', + 'type' => 'text', + 'label' => esc_html__( 'Link', 'option-tree' ), + 'class' => '', + ), + array( + 'name' => 'description', + 'type' => 'textarea', + 'label' => esc_html__( 'Description', 'option-tree' ), + 'class' => '', + ), + ), + $field_id + ); + + // Fix the array keys, values, and just get it 2.0 ready. + foreach ( $settings as $_k => $setting ) { + + foreach ( $setting as $s_key => $s_value ) { + + if ( 'name' === $s_key ) { + + $settings[ $_k ]['id'] = $s_value; + unset( $settings[ $_k ]['name'] ); + } elseif ( 'type' === $s_key ) { + + if ( 'input' === $s_value ) { + + $settings[ $_k ]['type'] = 'text'; + } elseif ( 'textarea' === $s_value ) { + + $settings[ $_k ]['type'] = 'textarea-simple'; + } elseif ( 'image' === $s_value ) { + + $settings[ $_k ]['type'] = 'upload'; + } + } + } + } + + return $settings; + } } -/** - * Returns the option type by ID. - * - * @param string $option_id The option ID - * @return string $settings_id The settings array ID - * @return string The option type. - * - * @access public - * @since 2.4.2 - */ -if ( ! function_exists( 'ot_get_option_type_by_id' ) ) { +if ( ! function_exists( 'ot_social_links_settings' ) ) { - function ot_get_option_type_by_id( $option_id, $settings_id = '' ) { - - if ( empty( $settings_id ) ) { - - $settings_id = ot_settings_id(); - - } - - $settings = get_option( $settings_id, array() ); - - if ( isset( $settings['settings'] ) ) { - - foreach( $settings['settings'] as $value ) { - - if ( $option_id == $value['id'] && isset( $value['type'] ) ) { - - return $value['type']; - - } - - } - - } - - return false; - - } - + /** + * Default Social Links Settings array. + * + * Returns an array of the default social links settings. + * You can filter this function to change the settings + * on a per option basis. + * + * @uses apply_filters() + * + * @param string $field_id ID that's passed to the filter. + * + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_social_links_settings( $field_id ) { + + /* translators: %s: the http protocol */ + $string = esc_html__( 'Enter a link to the profile or page on the social website. Remember to add the %s part to the front of the link.', 'option-tree' ); + $settings = apply_filters( + 'ot_social_links_settings', + array( + array( + 'id' => 'name', + 'label' => esc_html__( 'Name', 'option-tree' ), + 'desc' => esc_html__( 'Enter the name of the social website.', 'option-tree' ), + 'std' => '', + 'type' => 'text', + 'class' => 'option-tree-setting-title', + ), + array( + 'id' => 'title', + 'label' => 'Title', + 'desc' => esc_html__( 'Enter the text shown in the title attribute of the link.', 'option-tree' ), + 'type' => 'text', + ), + array( + 'id' => 'href', + 'label' => 'Link', + 'desc' => sprintf( $string, 'http:// or https://' ), + 'type' => 'text', + ), + ), + $field_id + ); + + return $settings; + } } -/** - * Build an array of potential Theme Options that could share terms - * - * @return array - * - * @access private - * @since 2.5.4 - */ -function _ot_settings_potential_shared_terms() { +if ( ! function_exists( 'ot_insert_css_with_markers' ) ) { + + /** + * Inserts CSS with field_id markers. + * + * Inserts CSS into a dynamic.css file, placing it between + * BEGIN and END field_id markers. Replaces existing marked info, + * but still retains surrounding data. + * + * @param string $field_id The CSS option field ID. + * @param string $insertion The current option_tree array. + * @param bool $meta Whether or not the value is stored in meta. + * @return bool True on write success, false on failure. + * + * @access public + * @since 1.1.8 + * @updated 2.5.3 + */ + function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = false ) { + + // Missing $field_id or $insertion exit early. + if ( '' === $field_id || '' === $insertion ) { + return; + } + + // Path to the dynamic.css file. + $filepath = get_stylesheet_directory() . '/dynamic.css'; + if ( is_multisite() ) { + $multisite_filepath = get_stylesheet_directory() . '/dynamic-' . get_current_blog_id() . '.css'; + if ( file_exists( $multisite_filepath ) ) { + $filepath = $multisite_filepath; + } + } + + // Allow filter on path. + $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id ); + + // Grab a copy of the paths array. + $ot_css_file_paths = get_option( 'ot_css_file_paths', array() ); + if ( is_multisite() ) { + $ot_css_file_paths = get_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); + } + + // Set the path for this field. + $ot_css_file_paths[ $field_id ] = $filepath; + + /* update the paths */ + if ( is_multisite() ) { + update_blog_option( get_current_blog_id(), 'ot_css_file_paths', $ot_css_file_paths ); + } else { + update_option( 'ot_css_file_paths', $ot_css_file_paths ); + } + + // Remove CSS from file, but ensure the file is actually CSS first. + if ( is_writeable( $filepath ) && 'css' === end( explode( '.', basename( $filepath ) ) ) ) { + + $insertion = ot_normalize_css( $insertion ); + $regex = '/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/'; + $marker = $field_id; + + // Match custom CSS. + preg_match_all( $regex, $insertion, $matches ); + + // Loop through CSS. + foreach ( $matches[0] as $option ) { + + $value = ''; + $option_array = explode( '|', str_replace( array( '{{', '}}' ), '', $option ) ); + $option_id = isset( $option_array[0] ) ? $option_array[0] : ''; + $option_key = isset( $option_array[1] ) ? $option_array[1] : ''; + $option_type = ot_get_option_type_by_id( $option_id ); + $fallback = ''; + + // Get the meta array value. + if ( $meta ) { + global $post; + + $value = get_post_meta( $post->ID, $option_id, true ); + + // Get the options array value. + } else { + $options = get_option( ot_options_id() ); + + if ( isset( $options[ $option_id ] ) ) { + $value = $options[ $option_id ]; + } + } + + // This in an array of values. + if ( is_array( $value ) ) { + + if ( empty( $option_key ) ) { + + // Measurement. + if ( 'measurement' === $option_type ) { + $unit = ! empty( $value[1] ) ? $value[1] : 'px'; + + // Set $value with measurement properties. + if ( isset( $value[0] ) && strlen( $value[0] ) > 0 ) { + $value = $value[0] . $unit; + } + + // Border. + } elseif ( 'border' === $option_type ) { + $border = array(); + + $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; + + if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) { + $border[] = $value['width'] . $unit; + } + + if ( ! empty( $value['style'] ) ) { + $border[] = $value['style']; + } - $options = array(); - $settings = get_option( ot_settings_id(), array() ); - $option_types = array( - 'category-checkbox', - 'category-select', - 'tag-checkbox', - 'tag-select', - 'taxonomy-checkbox', - 'taxonomy-select' - ); + if ( ! empty( $value['color'] ) ) { + $border[] = $value['color']; + } - if ( isset( $settings['settings'] ) ) { + // Set $value with border properties or empty string. + $value = ! empty( $border ) ? implode( ' ', $border ) : ''; - foreach( $settings['settings'] as $value ) { + // Box Shadow. + } elseif ( 'box-shadow' === $option_type ) { - if ( isset( $value['type'] ) ) { + // Set $value with box-shadow properties or empty string. + $value = ! empty( $value ) ? implode( ' ', $value ) : ''; - if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) { + // Dimension. + } elseif ( 'dimension' === $option_type ) { + $dimension = array(); - $saved = ot_get_option( $value['id'] ); + $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; - foreach( $value['settings'] as $item ) { + if ( isset( $value['width'] ) && strlen( $value['width'] ) > 0 ) { + $dimension[] = $value['width'] . $unit; + } - if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types ) ) { - $sub_options = array(); + if ( isset( $value['height'] ) && strlen( $value['height'] ) > 0 ) { + $dimension[] = $value['height'] . $unit; + } - foreach( $saved as $sub_key => $sub_value ) { - if ( isset( $sub_value[$item['id']] ) ) { - $sub_options[$sub_key] = $sub_value[$item['id']]; - } - } + // Set $value with dimension properties or empty string. + $value = ! empty( $dimension ) ? implode( ' ', $dimension ) : ''; - if ( ! empty( $sub_options ) ) { - $options[] = array( - 'id' => $item['id'], - 'taxonomy' => $value['taxonomy'], - 'parent' => $value['id'], - 'value' => $sub_options - ); - } - } + // Spacing. + } elseif ( 'spacing' === $option_type ) { + $spacing = array(); - } + $unit = ! empty( $value['unit'] ) ? $value['unit'] : 'px'; - } + if ( isset( $value['top'] ) && strlen( $value['top'] ) > 0 ) { + $spacing[] = $value['top'] . $unit; + } - if ( in_array( $value['type'], $option_types ) ) { - $saved = ot_get_option( $value['id'] ); - if ( ! empty( $saved ) ) { - $options[] = array( - 'id' => $value['id'], - 'taxonomy' => $value['taxonomy'], - 'value' => $saved - ); - } - } + if ( isset( $value['right'] ) && strlen( $value['right'] ) > 0 ) { + $spacing[] = $value['right'] . $unit; + } - } + if ( isset( $value['bottom'] ) && strlen( $value['bottom'] ) > 0 ) { + $spacing[] = $value['bottom'] . $unit; + } - } + if ( isset( $value['left'] ) && strlen( $value['left'] ) > 0 ) { + $spacing[] = $value['left'] . $unit; + } - } + // Set $value with spacing properties or empty string. + $value = ! empty( $spacing ) ? implode( ' ', $spacing ) : ''; - return $options; + // Typography. + } elseif ( 'typography' === $option_type ) { + $font = array(); + if ( ! empty( $value['font-color'] ) ) { + $font[] = 'color: ' . $value['font-color'] . ';'; + } + + if ( ! empty( $value['font-family'] ) ) { + foreach ( ot_recognized_font_families( $marker ) as $key => $v ) { + if ( $key === $value['font-family'] ) { + $font[] = 'font-family: ' . $v . ';'; + } + } + } + + if ( ! empty( $value['font-size'] ) ) { + $font[] = 'font-size: ' . $value['font-size'] . ';'; + } + + if ( ! empty( $value['font-style'] ) ) { + $font[] = 'font-style: ' . $value['font-style'] . ';'; + } + + if ( ! empty( $value['font-variant'] ) ) { + $font[] = 'font-variant: ' . $value['font-variant'] . ';'; + } + + if ( ! empty( $value['font-weight'] ) ) { + $font[] = 'font-weight: ' . $value['font-weight'] . ';'; + } + + if ( ! empty( $value['letter-spacing'] ) ) { + $font[] = 'letter-spacing: ' . $value['letter-spacing'] . ';'; + } + + if ( ! empty( $value['line-height'] ) ) { + $font[] = 'line-height: ' . $value['line-height'] . ';'; + } + + if ( ! empty( $value['text-decoration'] ) ) { + $font[] = 'text-decoration: ' . $value['text-decoration'] . ';'; + } + + if ( ! empty( $value['text-transform'] ) ) { + $font[] = 'text-transform: ' . $value['text-transform'] . ';'; + } + + // Set $value with font properties or empty string. + $value = ! empty( $font ) ? implode( "\n", $font ) : ''; + + // Background. + } elseif ( 'background' === $option_type ) { + $bg = array(); + + if ( ! empty( $value['background-color'] ) ) { + $bg[] = $value['background-color']; + } + + if ( ! empty( $value['background-image'] ) ) { + + // If an attachment ID is stored here fetch its URL and replace the value. + if ( wp_attachment_is_image( $value['background-image'] ) ) { + + $attachment_data = wp_get_attachment_image_src( $value['background-image'], 'original' ); + + // Check for attachment data. + if ( $attachment_data ) { + $value['background-image'] = $attachment_data[0]; + } + } + + $bg[] = 'url("' . $value['background-image'] . '")'; + } + + if ( ! empty( $value['background-repeat'] ) ) { + $bg[] = $value['background-repeat']; + } + + if ( ! empty( $value['background-attachment'] ) ) { + $bg[] = $value['background-attachment']; + } + + if ( ! empty( $value['background-position'] ) ) { + $bg[] = $value['background-position']; + } + + if ( ! empty( $value['background-size'] ) ) { + $size = $value['background-size']; + } + + // Set $value with background properties or empty string. + $value = ! empty( $bg ) ? 'background: ' . implode( ' ', $bg ) . ';' : ''; + + if ( isset( $size ) ) { + if ( ! empty( $bg ) ) { + $value .= apply_filters( 'ot_insert_css_with_markers_bg_size_white_space', "\n\x20\x20", $option_id ); + } + $value .= "background-size: $size;"; + } + } + } else { + $value = $value[ $option_key ]; + } + } + + // If an attachment ID is stored here fetch its URL and replace the value. + if ( 'upload' === $option_type && wp_attachment_is_image( $value ) ) { + + $attachment_data = wp_get_attachment_image_src( $value, 'original' ); + + // Check for attachment data. + if ( $attachment_data ) { + $value = $attachment_data[0]; + } + } + + // Attempt to fallback when `$value` is empty. + if ( empty( $value ) ) { + + // We're trying to access a single array key. + if ( ! empty( $option_key ) ) { + + // Link Color `inherit`. + if ( 'link-color' === $option_type ) { + $fallback = 'inherit'; + } + } else { + + // Border. + if ( 'border' === $option_type ) { + $fallback = 'inherit'; + } + + // Box Shadow. + if ( 'box-shadow' === $option_type ) { + $fallback = 'none'; + } + + // Colorpicker. + if ( 'colorpicker' === $option_type ) { + $fallback = 'inherit'; + } + + // Colorpicker Opacity. + if ( 'colorpicker-opacity' === $option_type ) { + $fallback = 'inherit'; + } + } + + /** + * Filter the `dynamic.css` fallback value. + * + * @since 2.5.3 + * + * @param string $fallback The default CSS fallback value. + * @param string $option_id The option ID. + * @param string $option_type The option type. + * @param string $option_key The option array key. + */ + $fallback = apply_filters( 'ot_insert_css_with_markers_fallback', $fallback, $option_id, $option_type, $option_key ); + } + + // Let's fallback! + if ( ! empty( $fallback ) ) { + $value = $fallback; + } + + // Filter the CSS. + $value = apply_filters( 'ot_insert_css_with_markers_value', $value, $option_id ); + + // Insert CSS, even if the value is empty. + $insertion = stripslashes( str_replace( $option, $value, $insertion ) ); + } + + // Can't write to the file so we error out. + if ( ! is_writable( $filepath ) ) { + /* translators: %s: file path */ + $string = esc_html__( 'Unable to write to file %s.', 'option-tree' ); + add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '' . $filepath . '' ), 'error' ); + return false; + } + + // Open file. + $f = @fopen( $filepath, 'w' ); // phpcs:ignore + + // Can't write to the file return false. + if ( ! $f ) { + /* translators: %s: file path */ + $string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' ); + add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '' . $filepath . '' ), 'error' ); + return false; + } + + // Create array from the lines of code. + $markerdata = explode( "\n", implode( '', file( $filepath ) ) ); + + $searching = true; + $foundit = false; + + // Has array of lines. + if ( ! empty( $markerdata ) ) { + + // Foreach line of code. + foreach ( $markerdata as $n => $markerline ) { + + // Found begining of marker, set $searching to false. + if ( "/* BEGIN {$marker} */" === $markerline ) { + $searching = false; + } + + // Keep searching each line of CSS. + if ( true === $searching ) { + if ( $n + 1 < count( $markerdata ) ) { + fwrite( $f, "{$markerline}\n" ); // phpcs:ignore + } else { + fwrite( $f, "{$markerline}" ); // phpcs:ignore + } + } + + // Found end marker write code. + if ( "/* END {$marker} */" === $markerline ) { + fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore + fwrite( $f, "{$insertion}\n" ); // phpcs:ignore + fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore + $searching = true; + $foundit = true; + } + } + } + + // Nothing inserted, write code. DO IT, DO IT! + if ( ! $foundit ) { + fwrite( $f, "/* BEGIN {$marker} */\n" ); // phpcs:ignore + fwrite( $f, "{$insertion}\n" ); // phpcs:ignore + fwrite( $f, "/* END {$marker} */\n" ); // phpcs:ignore + } + + // Close file. + fclose( $f ); // phpcs:ignore + return true; + } + + return false; + } } -/** - * Build an array of potential Meta Box options that could share terms - * - * @return array - * - * @access private - * @since 2.5.4 - */ -function _ot_meta_box_potential_shared_terms() { - global $ot_meta_boxes; +if ( ! function_exists( 'ot_remove_old_css' ) ) { - $options = array(); - $settings = $ot_meta_boxes; - $option_types = array( - 'category-checkbox', - 'category-select', - 'tag-checkbox', - 'tag-select', - 'taxonomy-checkbox', - 'taxonomy-select' - ); + /** + * Remove old CSS. + * + * Removes CSS when the textarea is empty, but still retains surrounding styles. + * + * @param string $field_id The CSS option field ID. + * @return bool True on write success, false on failure. + * + * @access public + * @since 2.0 + */ + function ot_remove_old_css( $field_id = '' ) { + + // Missing $field_id string. + if ( '' === $field_id ) { + return false; + } + + // Path to the dynamic.css file. + $filepath = get_stylesheet_directory() . '/dynamic.css'; + + // Allow filter on path. + $filepath = apply_filters( 'css_option_file_path', $filepath, $field_id ); + + // Remove CSS from file, but ensure the file is actually CSS first. + if ( is_writeable( $filepath ) && 'css' === end( explode( '.', basename( $filepath ) ) ) ) { + + // Open the file. + $f = @fopen( $filepath, 'w' ); // phpcs:ignore + + // Can't write to the file return false. + if ( ! $f ) { + /* translators: %s: file path */ + $string = esc_html__( 'Unable to open the %s file in write mode.', 'option-tree' ); + add_settings_error( 'option-tree', 'dynamic_css', sprintf( $string, '' . $filepath . '' ), 'error' ); + return false; + } + + // Get each line in the file. + $markerdata = explode( "\n", implode( '', file( $filepath ) ) ); + + $searching = true; + + // Has array of lines. + if ( ! empty( $markerdata ) ) { + + // Foreach line of code. + foreach ( $markerdata as $n => $markerline ) { + + // Found beginning of marker, set $searching to false. + if ( "/* BEGIN {$field_id} */" === $markerline ) { + $searching = false; + } + + // Searching is true, keep writing each line of CSS. + if ( true === $searching ) { + if ( $n + 1 < count( $markerdata ) ) { + fwrite( $f, "{$markerline}\n" ); // phpcs:ignore + } else { + fwrite( $f, "{$markerline}" ); // phpcs:ignore + } + } + + // Found end marker delete old CSS. + if ( "/* END {$field_id} */" === $markerline ) { + fwrite( $f, '' ); // phpcs:ignore + $searching = true; + } + } + } + + // Close file. + fclose( $f ); // phpcs:ignore + return true; + } + + return false; + } +} + +if ( ! function_exists( 'ot_normalize_css' ) ) { - foreach( $settings as $setting ) { + /** + * Normalize CSS + * + * Normalize & Convert all line-endings to UNIX format. + * + * @param string $css The CSS styles. + * + * @return string + * + * @access public + * @since 1.1.8 + * @updated 2.0 + */ + function ot_normalize_css( $css ) { + + // Normalize & Convert. + $css = str_replace( "\r\n", "\n", $css ); + $css = str_replace( "\r", "\n", $css ); + + // Don't allow out-of-control blank lines . + $css = preg_replace( "/\n{2,}/", "\n\n", $css ); + + return $css; + } +} - if ( isset( $setting['fields'] ) ) { +if ( ! function_exists( 'ot_loop_through_option_types' ) ) { - foreach( $setting['fields'] as $value ) { + /** + * Helper function to loop over the option types. + * + * @param string $type The current option type. + * @param bool $child Whether of not there are children elements. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_loop_through_option_types( $type = '', $child = false ) { + + $content = ''; + $types = ot_option_types_array(); + + if ( $child ) { + unset( $types['list-item'] ); + } + + foreach ( $types as $key => $value ) { + $content .= ''; + } + + return $content; + + } +} - if ( isset( $value['type'] ) ) { +if ( ! function_exists( 'ot_loop_through_choices' ) ) { - if ( $value['type'] == 'list-item' && isset( $value['settings'] ) ) { + /** + * Helper function to loop over choices. + * + * @param string $name The form element name. + * @param array $choices The array of choices. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_loop_through_choices( $name, $choices = array() ) { + + $content = ''; + + foreach ( (array) $choices as $key => $choice ) { + if ( is_array( $choice ) ) { + $content .= '
    • ' . ot_choices_view( $name, $key, $choice ) . '
    • '; + } + } + + return $content; + } +} - $children = array(); +if ( ! function_exists( 'ot_loop_through_sub_settings' ) ) { - foreach( $value['settings'] as $item ) { + /** + * Helper function to loop over sub settings. + * + * @param string $name The form element name. + * @param array $settings The array of settings. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_loop_through_sub_settings( $name, $settings = array() ) { + + $content = ''; + + foreach ( $settings as $key => $setting ) { + if ( is_array( $setting ) ) { + $content .= '
    • ' . ot_settings_view( $name, $key, $setting ) . '
    • '; + } + } + + return $content; + } +} - if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types ) ) { +if ( ! function_exists( 'ot_sections_view' ) ) { - $children[$value['id']][] = $item['id']; + /** + * Helper function to display sections. + * + * This function is used in AJAX to add a new section + * and when section have already been added and saved. + * + * @param string $name The form element name. + * @param int $key The array key for the current element. + * @param array $section An array of values for the current section. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_sections_view( $name, $key, $section = array() ) { + + /* translators: %s: Section Title emphasized */ + $str_title = esc_html__( '%s: Displayed as a menu item on the Theme Options page.', 'option-tree' ); + + /* translators: %s: Section ID emphasized */ + $str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ); + + return ' +
      +
      ' . ( isset( $section['title'] ) ? esc_attr( $section['title'] ) : 'Section ' . ( absint( $key ) + 1 ) ) . '
      + +
      +
      +
      +
      ' . sprintf( $str_title, '' . esc_html__( 'Section Title', 'option-tree' ) . '', 'option-tree' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_id, '' . esc_html__( 'Section ID', 'option-tree' ) . '', 'option-tree' ) . '
      +
      + +
      +
      +
      +
      +
      '; + } +} - } +if ( ! function_exists( 'ot_settings_view' ) ) { - } - - if ( ! empty( $children[$value['id']] ) ) { - $options[] = array( - 'id' => $value['id'], - 'children' => $children[$value['id']], - 'taxonomy' => $value['taxonomy'], - ); - } + /** + * Helper function to display settings. + * + * This function is used in AJAX to add a new setting + * and when settings have already been added and saved. + * + * @param string $name The form element name. + * @param int $key The array key for the current element. + * @param array $setting An array of values for the current setting. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_settings_view( $name, $key, $setting = array() ) { + + $child = ( false !== strpos( $name, '][settings]' ) ) ? true : false; + $type = isset( $setting['type'] ) ? $setting['type'] : ''; + $std = isset( $setting['std'] ) ? $setting['std'] : ''; + $operator = isset( $setting['operator'] ) ? esc_attr( $setting['operator'] ) : 'and'; + + // Serialize the standard value just in case. + if ( is_array( $std ) ) { + $std = maybe_serialize( $std ); + } + + if ( in_array( $type, array( 'css', 'javascript', 'textarea', 'textarea-simple' ), true ) ) { + $std_form_element = ''; + } else { + $std_form_element = ''; + } + + /* translators: %s: Label emphasized */ + $str_label = esc_html__( '%s: Displayed as the label of a form element on the Theme Options page.', 'option-tree' ); + + /* translators: %s: ID emphasized */ + $str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ); + + /* translators: %s: Type emphasized */ + $str_type = esc_html__( '%s: Choose one of the available option types from the dropdown.', 'option-tree' ); + + /* translators: %s: Description emphasized */ + $str_desc = esc_html__( '%s: Enter a detailed description for the users to read on the Theme Options page, HTML is allowed. This is also where you enter content for both the Textblock & Textblock Titled option types.', 'option-tree' ); + + /* translators: %s: Choices emphasized */ + $str_choices = esc_html__( '%s: This will only affect the following option types: Checkbox, Radio, Select & Select Image.', 'option-tree' ); + + /* translators: %s: Settings emphasized */ + $str_settings = esc_html__( '%s: This will only affect the List Item option type.', 'option-tree' ); + + /* translators: %1$s: Standard emphasized, %2$s: visual path to documentation */ + $str_standard = esc_html__( '%1$s: Setting the standard value for your option only works for some option types. Read the %2$s for more information on which ones.', 'option-tree' ); + + /* translators: %s: Rows emphasized */ + $str_rows = esc_html__( '%s: Enter a numeric value for the number of rows in your textarea. This will only affect the following option types: CSS, Textarea, & Textarea Simple.', 'option-tree' ); + + /* translators: %s: Post Type emphasized */ + $str_post_type = esc_html__( '%s: Add a comma separated list of post type like \'post,page\'. This will only affect the following option types: Custom Post Type Checkbox, & Custom Post Type Select.', 'option-tree' ); + + /* translators: %s: Taxonomy emphasized */ + $str_taxonomy = esc_html__( '%s: Add a comma separated list of any registered taxonomy like \'category,post_tag\'. This will only affect the following option types: Taxonomy Checkbox, & Taxonomy Select.', 'option-tree' ); + + /* translators: %1$s: Min, Max, & Step emphasized, %2$s: format, %3$s: range, %4$s: minimum interval */ + $str_min_max_step = esc_html__( '%1$s: Add a comma separated list of options in the following format %2$s (slide from %3$s in intervals of %4$s). The three values represent the minimum, maximum, and step options and will only affect the Numeric Slider option type.', 'option-tree' ); + + /* translators: %s: CSS Class emphasized */ + $str_css_class = esc_html__( '%s: Add and optional class to this option type.', 'option-tree' ); + + /* translators: %1$s: Condition emphasized, %2$s: example value, %3$s: list of valid conditions */ + $str_condition = esc_html__( '%1$s: Add a comma separated list (no spaces) of conditions in which the field will be visible, leave this setting empty to always show the field. In these examples, %2$s is a placeholder for your condition, which can be in the form of %3$s.', 'option-tree' ); + + /* translators: %s: Operator emphasized */ + $str_operator = esc_html__( '%s: Choose the logical operator to compute the result of the conditions.', 'option-tree' ); + + return ' +
      +
      ' . ( isset( $setting['label'] ) ? esc_attr( $setting['label'] ) : 'Setting ' . ( absint( $key ) + 1 ) ) . '
      + +
      +
      +
      +
      ' . sprintf( $str_label, '' . esc_html__( 'Label', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_id, '' . esc_html__( 'ID', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_type, '' . esc_html__( 'Type', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_desc, '' . esc_html__( 'Description', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_choices, '' . esc_html__( 'Choices', 'option-tree' ) . '' ) . '
      +
      +
        + ' . ( isset( $setting['choices'] ) ? ot_loop_through_choices( $name . '[' . $key . ']', $setting['choices'] ) : '' ) . ' +
      + ' . esc_html__( 'Add Choice', 'option-tree' ) . ' +
      +
      +
      +
      +
      +
      ' . sprintf( $str_settings, '' . esc_html__( 'Settings', 'option-tree' ) . '' ) . '
      +
      +
        + ' . ( isset( $setting['settings'] ) ? ot_loop_through_sub_settings( $name . '[' . $key . '][settings]', $setting['settings'] ) : '' ) . ' +
      + ' . esc_html__( 'Add Setting', 'option-tree' ) . ' +
      +
      +
      +
      +
      +
      ' . sprintf( $str_standard, '' . esc_html__( 'Standard', 'option-tree' ) . '', '' . esc_html__( 'OptionTree->Documentation', 'option-tree' ) . '' ) . '
      +
      + ' . $std_form_element . ' +
      +
      +
      +
      +
      +
      ' . sprintf( $str_rows, '' . esc_html__( 'Rows', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_post_type, '' . esc_html__( 'Post Type', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_taxonomy, '' . esc_html__( 'Taxonomy', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_min_max_step, '' . esc_html__( 'Min, Max, & Step', 'option-tree' ) . '', '0,100,1', '0-100', '1' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_css_class, '' . esc_html__( 'CSS Class', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_condition, '' . esc_html__( 'Condition', 'option-tree' ) . '', 'value', 'field_id:is(value), field_id:not(value), field_id:contains(value), field_id:less_than(value), field_id:less_than_or_equal_to(value), field_id:greater_than(value), or field_id:greater_than_or_equal_to(value)' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_operator, '' . esc_html__( 'Operator', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      + ' . ( ! $child ? '' : '' ); + } +} - } +if ( ! function_exists( 'ot_choices_view' ) ) { - if ( in_array( $value['type'], $option_types ) ) { + /** + * Helper function to display setting choices. + * + * This function is used in AJAX to add a new choice + * and when choices have already been added and saved. + * + * @param string $name The form element name. + * @param int $key The array key for the current element. + * @param array $choice An array of values for the current choice. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_choices_view( $name, $key, $choice = array() ) { + + return ' +
      +
      ' . ( isset( $choice['label'] ) ? esc_attr( $choice['label'] ) : 'Choice ' . ( absint( $key ) + 1 ) ) . '
      + +
      +
      +
      +
      ' . esc_html__( 'Label', 'option-tree' ) . '
      +
      +
      +
      + +
      +
      +
      +
      +
      +
      ' . esc_html__( 'Value', 'option-tree' ) . '
      +
      +
      +
      + +
      +
      +
      +
      +
      +
      ' . esc_html__( 'Image Source (Radio Image only)', 'option-tree' ) . '
      +
      +
      +
      + +
      +
      +
      +
      +
      '; + + } +} - $options[] = array( - 'id' => $value['id'], - 'taxonomy' => $value['taxonomy'], - ); +if ( ! function_exists( 'ot_contextual_help_view' ) ) { - } + /** + * Helper function to display sections. + * + * This function is used in AJAX to add a new section + * and when section have already been added and saved. + * + * @param string $name The name/ID of the help page. + * @param int $key The array key for the current element. + * @param array $content An array of values for the current section. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_contextual_help_view( $name, $key, $content = array() ) { + + /* translators: %s: Title emphasized */ + $str_title = esc_html__( '%s: Displayed as a contextual help menu item on the Theme Options page.', 'option-tree' ); + + /* translators: %s: ID emphasized */ + $str_id = esc_html__( '%s: A unique lower case alphanumeric string, underscores allowed.', 'option-tree' ); + + /* translators: %s: Content emphasized */ + $str_content = esc_html__( '%s: Enter the HTML content about this contextual help item displayed on the Theme Option page for end users to read.', 'option-tree' ); + + return ' +
      +
      ' . ( isset( $content['title'] ) ? esc_attr( $content['title'] ) : 'Content ' . ( absint( $key ) + 1 ) ) . '
      + +
      +
      +
      +
      ' . sprintf( $str_title, '' . esc_html__( 'Title', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_id, '' . esc_html__( 'ID', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      +
      ' . sprintf( $str_content, '' . esc_html__( 'Content', 'option-tree' ) . '' ) . '
      +
      + +
      +
      +
      +
      +
      '; + + } +} - } +if ( ! function_exists( 'ot_layout_view' ) ) { - } + /** + * Helper function to display sections. + * + * @param string $key Layout ID. + * @param string $data Layout encoded value. + * @param string $active_layout Active layout ID. + * + * @return string + * + * @access public + * @since 2.0 + */ + function ot_layout_view( $key, $data = '', $active_layout = '' ) { + + return ' +
      +
      ' . ( isset( $key ) ? esc_attr( $key ) : esc_html__( 'Layout', 'option-tree' ) ) . '
      + + +
      '; + } +} - } +if ( ! function_exists( 'ot_list_item_view' ) ) { - } + /** + * Helper function to display list items. + * + * This function is used in AJAX to add a new list items + * and when they have already been added and saved. + * + * @param string $name The form field name. + * @param int $key The array key for the current element. + * @param array $list_item An array of values for the current list item. + * @param int $post_id The post ID. + * @param string $get_option The option page ID. + * @param array $settings The settings. + * @param string $type The list type. + * + * @access public + * @since 2.0 + */ + function ot_list_item_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array(), $type = '' ) { + + // Required title setting. + $required_setting = array( + array( + 'id' => 'title', + 'label' => __( 'Title', 'option-tree' ), + 'desc' => '', + 'std' => '', + 'type' => 'text', + 'rows' => '', + 'class' => 'option-tree-setting-title', + 'post_type' => '', + 'choices' => array(), + ), + ); + + // Load the old filterable slider settings. + if ( 'slider' === $type ) { + $settings = ot_slider_settings( $name ); + } + + // If no settings array load the filterable list item settings. + if ( empty( $settings ) ) { + $settings = ot_list_item_settings( $name ); + } + + // Merge the two settings array. + $settings = array_merge( $required_setting, $settings ); + + echo ' +
      +
      ' . ( isset( $list_item['title'] ) ? esc_attr( $list_item['title'] ) : '' ) . '
      + +
      + '; + + foreach ( $settings as $field ) { + + // Set field value. + $field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : ''; + + // Set default to standard value. + if ( isset( $field['std'] ) ) { + $field_value = ot_filter_std_value( $field_value, $field['std'] ); + } + + // filter the title label and description. + if ( 'title' === $field['id'] ) { + + // filter the label. + $field['label'] = apply_filters( 'ot_list_item_title_label', $field['label'], $name ); + + // filter the description. + $field['desc'] = apply_filters( 'ot_list_item_title_desc', $field['desc'], $name ); + } + + // Make life easier. + $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name; + + // Build the arguments array. + $_args = array( + 'type' => $field['type'], + 'field_id' => $name . '_' . $field['id'] . '_' . $key, + 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', + 'field_value' => $field_value, + 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', + 'field_std' => isset( $field['std'] ) ? $field['std'] : '', + 'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10, + 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', + 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', + 'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', + 'field_class' => isset( $field['class'] ) ? $field['class'] : '', + 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', + 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', + 'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(), + 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), + 'post_id' => $post_id, + 'get_option' => $get_option, + ); + + $conditions = ''; + + // Setup the conditions. + if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { + + /* doing magic on the conditions so they work in a list item */ + $conditionals = explode( ',', $field['condition'] ); + foreach ( $conditionals as $condition ) { + $parts = explode( ':', $condition ); + if ( isset( $parts[0] ) ) { + $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] ); + } + } + + $conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"'; + $conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : ''; + } + + // Build the setting CSS class. + if ( ! empty( $_args['field_class'] ) ) { + $classes = explode( ' ', $_args['field_class'] ); + + foreach ( $classes as $_key => $value ) { + $classes[ $_key ] = $value . '-wrap'; + } + + $class = 'format-settings ' . implode( ' ', $classes ); + } else { + $class = 'format-settings'; + } + + // Option label. + echo '
      '; // phpcs:ignore + + // Don't show title with textblocks. + if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) { + echo '
      '; + echo '

      ' . esc_attr( $field['label'] ) . '

      '; + echo '
      '; + } + + // Only allow simple textarea inside a list-item due to known DOM issues with wp_editor(). + if ( false === apply_filters( 'ot_override_forced_textarea_simple', false, $field['id'] ) && 'textarea' === $_args['type'] ) { + $_args['type'] = 'textarea-simple'; + } + + // Option body, list-item is not allowed inside another list-item. + if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] ) { + echo ot_display_by_type( $_args ); // phpcs:ignore + } + + echo '
      '; + } + + echo '
      '; + + echo '
      '; + } +} - return $options; +if ( ! function_exists( 'ot_social_links_view' ) ) { + /** + * Helper function to display social links. + * + * This function is used in AJAX to add a new list items + * and when they have already been added and saved. + * + * @param string $name The form field name. + * @param int $key The array key for the current element. + * @param array $list_item An array of values for the current list item. + * @param int $post_id The post ID. + * @param string $get_option The option page ID. + * @param array $settings The settings. + * + * @access public + * @since 2.4.0 + */ + function ot_social_links_view( $name, $key, $list_item = array(), $post_id = 0, $get_option = '', $settings = array() ) { + + // If no settings array load the filterable social links settings. + if ( empty( $settings ) ) { + $settings = ot_social_links_settings( $name ); + } + + echo ' +
      +
      ' . ( isset( $list_item['name'] ) ? esc_attr( $list_item['name'] ) : '' ) . '
      + +
      + '; + + foreach ( $settings as $field ) { + + // Set field value. + $field_value = isset( $list_item[ $field['id'] ] ) ? $list_item[ $field['id'] ] : ''; + + // Set default to standard value. + if ( isset( $field['std'] ) ) { + $field_value = ot_filter_std_value( $field_value, $field['std'] ); + } + + // Make life easier. + $_field_name = $get_option ? $get_option . '[' . $name . ']' : $name; + + // Build the arguments array. + $_args = array( + 'type' => $field['type'], + 'field_id' => $name . '_' . $field['id'] . '_' . $key, + 'field_name' => $_field_name . '[' . $key . '][' . $field['id'] . ']', + 'field_value' => $field_value, + 'field_desc' => isset( $field['desc'] ) ? $field['desc'] : '', + 'field_std' => isset( $field['std'] ) ? $field['std'] : '', + 'field_rows' => isset( $field['rows'] ) ? $field['rows'] : 10, + 'field_post_type' => isset( $field['post_type'] ) && ! empty( $field['post_type'] ) ? $field['post_type'] : 'post', + 'field_taxonomy' => isset( $field['taxonomy'] ) && ! empty( $field['taxonomy'] ) ? $field['taxonomy'] : 'category', + 'field_min_max_step' => isset( $field['min_max_step'] ) && ! empty( $field['min_max_step'] ) ? $field['min_max_step'] : '0,100,1', + 'field_class' => isset( $field['class'] ) ? $field['class'] : '', + 'field_condition' => isset( $field['condition'] ) ? $field['condition'] : '', + 'field_operator' => isset( $field['operator'] ) ? $field['operator'] : 'and', + 'field_choices' => isset( $field['choices'] ) && ! empty( $field['choices'] ) ? $field['choices'] : array(), + 'field_settings' => isset( $field['settings'] ) && ! empty( $field['settings'] ) ? $field['settings'] : array(), + 'post_id' => $post_id, + 'get_option' => $get_option, + ); + + $conditions = ''; + + // Setup the conditions. + if ( isset( $field['condition'] ) && ! empty( $field['condition'] ) ) { + + // Doing magic on the conditions so they work in a list item. + $conditionals = explode( ',', $field['condition'] ); + foreach ( $conditionals as $condition ) { + $parts = explode( ':', $condition ); + if ( isset( $parts[0] ) ) { + $field['condition'] = str_replace( $condition, $name . '_' . $parts[0] . '_' . $key . ':' . $parts[1], $field['condition'] ); + } + } + + $conditions = ' data-condition="' . esc_attr( $field['condition'] ) . '"'; + $conditions .= isset( $field['operator'] ) && in_array( $field['operator'], array( 'and', 'AND', 'or', 'OR' ), true ) ? ' data-operator="' . esc_attr( $field['operator'] ) . '"' : ''; + } + + // Option label. + echo '
      '; // phpcs:ignore + + // Don't show title with textblocks. + if ( 'textblock' !== $_args['type'] && ! empty( $field['label'] ) ) { + echo '
      '; + echo '

      ' . esc_attr( $field['label'] ) . '

      '; + echo '
      '; + } + + // Only allow simple textarea inside a list-item due to known DOM issues with wp_editor(). + if ( 'textarea' === $_args['type'] ) { + $_args['type'] = 'textarea-simple'; + } + + // Option body, list-item is not allowed inside another list-item. + if ( 'list-item' !== $_args['type'] && 'slider' !== $_args['type'] && 'social-links' !== $_args['type'] ) { + echo ot_display_by_type( $_args ); // phpcs:ignore + } + + echo '
      '; + } + + echo '
      '; + + echo '
      '; + } } -/** - * Update terms when a term gets split. - * - * @param int $term_id ID of the formerly shared term. - * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. - * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. - * @param string $taxonomy Taxonomy for the split term. - * @return void - * - * @access public - * @since 2.5.4 - */ -function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { +if ( ! function_exists( 'ot_theme_options_layouts_form' ) ) { + + /** + * Helper function to display Theme Options layouts form. + * + * @access public + * @since 2.0 + */ + function ot_theme_options_layouts_form() { + + echo '
      '; + + // Form nonce. + wp_nonce_field( 'option_tree_modify_layouts_form', 'option_tree_modify_layouts_nonce' ); + + // Get the saved layouts. + $layouts = get_option( ot_layouts_id() ); - // Process the Theme Options - $settings = _ot_settings_potential_shared_terms(); - $old_options = get_option( ot_options_id(), array() ); - $new_options = $old_options; + // Set active layout. + $active_layout = isset( $layouts['active_layout'] ) ? $layouts['active_layout'] : ''; - // Process the saved settings - if ( ! empty( $settings ) && ! empty( $old_options ) ) { + if ( is_array( $layouts ) && 1 < count( $layouts ) ) { - // Loop over the Theme Options - foreach( $settings as $option ) { + $active_layout = $layouts['active_layout']; - if ( ! is_array( $option['taxonomy'] ) ) { - $option['taxonomy'] = explode( ',', $option['taxonomy'] ); - } + echo ''; - if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) { - continue; - } + echo '
      '; - // The option ID was found - if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) { + echo ''; + } - if ( $sub_value == $term_id ) { + echo ''; - unset( $new_options[$option['parent']][$key][$option['id']][$sub_key] ); - $new_options[$option['parent']][$key][$option['id']][$new_term_id] = $new_term_id; + echo '
      '; - } + echo $hidden_safe; // phpcs:ignore + } - } + /* new layout wrapper */ + echo '
      '; - } else if ( $value == $term_id ) { + /* add new layout */ + echo ''; - unset( $new_options[$option['parent']][$key][$option['id']] ); - $new_options[$option['parent']][$key][$option['id']] = $new_term_id; + echo ''; - } + echo '
      '; - } + echo '
      '; + } +} + +if ( ! function_exists( 'ot_sanitize_option_id' ) ) { - } else { + /** + * Helper function to sanitize the option ID's. + * + * @param string $input The string to sanitize. + * @return string + * + * @access public + * @since 2.0 + */ + function ot_sanitize_option_id( $input ) { + return preg_replace( '/[^a-z0-9]/', '_', trim( strtolower( $input ) ) ); + } +} - // The value is an array of IDs - if ( is_array( $option['value'] ) ) { +if ( ! function_exists( 'ot_sanitize_layout_id' ) ) { - // Loop over the array - foreach( $option['value'] as $key => $value ) { + /** + * Helper function to sanitize the layout ID's. + * + * @param string $input The string to sanitize. + * @return string + * + * @access public + * @since 2.0 + */ + function ot_sanitize_layout_id( $input ) { + return preg_replace( '/[^a-z0-9]/', '-', trim( strtolower( $input ) ) ); + } +} - // It's a single value, just replace it - if ( $value == $term_id ) { +if ( ! function_exists( 'ot_convert_array_to_string' ) ) { - unset( $new_options[$option['id']][$key] ); - $new_options[$option['id']][$new_term_id] = $new_term_id; + /** + * Convert choices array to string. + * + * @param array $input The array to convert to a string. + * + * @return bool|string + * + * @access public + * @since 2.0 + */ + function ot_convert_array_to_string( $input ) { + + if ( is_array( $input ) ) { + + foreach ( $input as $k => $choice ) { + $choices[ $k ] = $choice['value'] . '|' . $choice['label']; + + if ( isset( $choice['src'] ) ) { + $choices[ $k ] .= '|' . $choice['src']; + } + } + + return implode( ',', $choices ); + } + + return false; + } +} - } +if ( ! function_exists( 'ot_convert_string_to_array' ) ) { - } + /** + * Convert choices string to array. + * + * @param string $input The string to convert to an array. + * + * @return bool|array + * + * @access public + * @since 2.0 + */ + function ot_convert_string_to_array( $input ) { + + if ( '' !== $input ) { + + // Empty choices array. + $choices = array(); + + // Exlode the string into an array. + foreach ( explode( ',', $input ) as $k => $choice ) { + + // If ":" is splitting the string go deeper. + if ( preg_match( '/\|/', $choice ) ) { + $split = explode( '|', $choice ); + + if ( 2 > count( $split ) ) { + continue; + } + + $choices[ $k ]['value'] = trim( $split[0] ); + $choices[ $k ]['label'] = trim( $split[1] ); + + // If radio image there are three values. + if ( isset( $split[2] ) ) { + $choices[ $k ]['src'] = trim( $split[2] ); + } + } else { + $choices[ $k ]['value'] = trim( $choice ); + $choices[ $k ]['label'] = trim( $choice ); + } + } + + // Return a formatted choices array. + return $choices; + } + + return false; + } +} - // It's a single value, just replace it - } else if ( $option['value'] == $term_id ) { +if ( ! function_exists( 'ot_strpos_array' ) ) { - $new_options[$option['id']] = $new_term_id; + /** + * Helper function - strpos() in array recursively. + * + * @param string $haystack The string to search in. + * @param array $needles Keys to search for. + * @return bool + * + * @access public + * @since 2.0 + */ + function ot_strpos_array( $haystack, $needles = array() ) { + + foreach ( $needles as $needle ) { + if ( false !== strpos( $haystack, $needle ) ) { + return true; + } + } + + return false; + } +} - } +if ( ! function_exists( 'ot_array_keys_exists' ) ) { - } + /** + * Helper function - array_key_exists() recursively. + * + * @param array $haystack The array to search in. + * @param array $needles Keys to search for. + * @return bool + * + * @access public + * @since 2.0 + */ + function ot_array_keys_exists( $haystack, $needles = array() ) { + + foreach ( $needles as $k ) { + if ( isset( $haystack[ $k ] ) ) { + return true; + } + } + + return false; + } +} - } +if ( ! function_exists( 'ot_stripslashes' ) ) { - } + /** + * Custom stripslashes from single value or array. + * + * @param mixed $input The string or array to stripslashes from. + * @return mixed + * + * @access public + * @since 2.0 + */ + function ot_stripslashes( $input ) { + + if ( is_array( $input ) ) { + + foreach ( $input as &$val ) { + + if ( is_array( $val ) ) { + $val = ot_stripslashes( $val ); + } else { + $val = stripslashes( trim( $val ) ); + } + } + } else { + $input = stripslashes( trim( $input ) ); + } + + return $input; + } +} - } +if ( ! function_exists( 'ot_reverse_wpautop' ) ) { - // Options need to be updated - if ( $old_options !== $new_options ) { - update_option( ot_options_id(), $new_options ); - } + /** + * Reverse wpautop. + * + * @param string $string The string to be filtered. + * @return string + * + * @access public + * @since 2.0.9 + */ + function ot_reverse_wpautop( $string = '' ) { + + // Return if string is empty. + if ( '' === trim( $string ) ) { + return ''; + } + + // Remove all new lines &

      tags. + $string = str_replace( array( "\n", '

      ' ), '', $string ); + + // Replace
      with \r. + $string = str_replace( array( '
      ', '
      ', '
      ' ), "\r", $string ); + + // Replace

      with \r\n. + $string = str_replace( '

      ', "\r\n", $string ); + + // Return clean string. + return trim( $string ); + } +} - // Process the Meta Boxes - $meta_settings = _ot_meta_box_potential_shared_terms(); - $option_types = array( - 'category-checkbox', - 'category-select', - 'tag-checkbox', - 'tag-select', - 'taxonomy-checkbox', - 'taxonomy-select' - ); +if ( ! function_exists( 'ot_range' ) ) { + + /** + * Returns an array of elements from start to limit, inclusive. + * + * Occasionally zero will be some impossibly large number to + * the "E" power when creating a range from negative to positive. + * This function attempts to fix that by setting that number back to "0". + * + * @param string $start First value of the sequence. + * @param string $limit The sequence is ended upon reaching the limit value. + * @param int $step If a step value is given, it will be used as the increment + * between elements in the sequence. step should be given as a + * positive number. If not specified, step will default to 1. + * + * @return array + * + * @access public + * @since 2.0.12 + */ + function ot_range( $start, $limit, $step = 1 ) { + + if ( $step < 0 ) { + $step = 1; + } + + $range = range( $start, $limit, $step ); + + foreach ( $range as $k => $v ) { + if ( strpos( $v, 'E' ) ) { + $range[ $k ] = 0; + } + } + + return $range; + } +} - if ( ! empty( $meta_settings ) ) { - $old_meta = array(); - - foreach( $meta_settings as $option ) { +if ( ! function_exists( 'ot_encode' ) ) { + + /** + * Helper function to return encoded strings. + * + * @param array $value The array to encode. + * + * @return string + * + * @access public + * @since 2.0.13 + */ + function ot_encode( $value ) { + $func = 'base64' . '_encode'; // phpcs:ignore + return $func( $value ); + } +} - if ( ! is_array( $option['taxonomy'] ) ) { - $option['taxonomy'] = explode( ',', $option['taxonomy'] ); - } - - if ( ! in_array( $taxonomy, $option['taxonomy'] ) ) { - continue; - } +if ( ! function_exists( 'ot_decode' ) ) { + + /** + * Helper function to return decoded arrays. + * + * @param string $value Encoded serialized array. + * + * @return array + * + * @access public + * @since 2.0.13 + */ + function ot_decode( $value ) { + $func = 'base64' . '_decode'; // phpcs:ignore + return $func( $value ); + } +} - if ( isset( $option['children'] ) ) { - $post_ids = get_posts( array( - 'fields' => 'ids', - 'meta_key' => $option['id'], - ) ); +if ( ! function_exists( 'ot_filter_std_value' ) ) { + + /** + * Helper function to filter standard option values. + * + * @param mixed $value Saved string or array value. + * @param mixed $std Standard string or array value. + * + * @return mixed String or array. + * + * @access public + * @since 2.0.15 + */ + function ot_filter_std_value( $value = '', $std = '' ) { + + if ( is_string( $std ) && ! empty( $std ) ) { + preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $std, $matches, PREG_SET_ORDER ); + + // Prevent object injection. + if ( $matches ) { + $std = maybe_unserialize( $std ); + } + } + + if ( is_array( $value ) && is_array( $std ) ) { + foreach ( $value as $k => $v ) { + if ( '' === $value[ $k ] && isset( $std[ $k ] ) ) { + $value[ $k ] = $std[ $k ]; + } + } + } elseif ( '' === $value && ! empty( $std ) ) { + $value = $std; + } + + return $value; + } +} - if ( $post_ids ) { +if ( ! function_exists( 'ot_set_google_fonts' ) ) { + + /** + * Helper function to set the Google fonts array. + * + * @param string $id The option ID. + * @param bool $value The option value. + * + * @access public + * @since 2.5.0 + */ + function ot_set_google_fonts( $id = '', $value = '' ) { + + $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + + if ( is_array( $value ) && ! empty( $value ) ) { + $ot_set_google_fonts[ $id ] = $value; + } elseif ( isset( $ot_set_google_fonts[ $id ] ) ) { + unset( $ot_set_google_fonts[ $id ] ); + } + + set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts ); + } +} - foreach( $post_ids as $post_id ) { +if ( ! function_exists( 'ot_update_google_fonts_after_save' ) ) { + + /** + * Helper function to remove unused options from the Google fonts array. + * + * @param array $options The array of saved options. + * + * @access public + * @since 2.5.0 + */ + function ot_update_google_fonts_after_save( $options = array() ) { + + $ot_set_google_fonts = get_theme_mod( 'ot_set_google_fonts', array() ); + + foreach ( $ot_set_google_fonts as $key => $set ) { + if ( ! isset( $options[ $key ] ) ) { + unset( $ot_set_google_fonts[ $key ] ); + } + } + set_theme_mod( 'ot_set_google_fonts', $ot_set_google_fonts ); + } + + add_action( 'ot_after_theme_options_save', 'ot_update_google_fonts_after_save', 1 ); +} - // Get the meta - $old_meta = get_post_meta( $post_id, $option['id'], true ); - $new_meta = $old_meta; +if ( ! function_exists( 'ot_fetch_google_fonts' ) ) { + + /** + * Helper function to fetch the Google fonts array. + * + * @param bool $normalize Whether or not to return a normalized array. Default 'true'. + * @param bool $force_rebuild Whether or not to force the array to be rebuilt. Default 'false'. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_fetch_google_fonts( $normalize = true, $force_rebuild = false ) { + + // Google Fonts cache key. + $ot_google_fonts_cache_key = apply_filters( 'ot_google_fonts_cache_key', 'ot_google_fonts_cache' ); + + // Get the fonts from cache. + $ot_google_fonts = apply_filters( 'ot_google_fonts_cache', get_transient( $ot_google_fonts_cache_key ) ); + + if ( $force_rebuild || ! is_array( $ot_google_fonts ) || empty( $ot_google_fonts ) ) { + + $ot_google_fonts = array(); + + // API url and key. + $ot_google_fonts_api_url = apply_filters( 'ot_google_fonts_api_url', 'https://www.googleapis.com/webfonts/v1/webfonts' ); + $ot_google_fonts_api_key = apply_filters( 'ot_google_fonts_api_key', false ); + + if ( false === $ot_google_fonts_api_key ) { + return array(); + } + + // API arguments. + $ot_google_fonts_fields = apply_filters( + 'ot_google_fonts_fields', + array( + 'family', + 'variants', + 'subsets', + ) + ); + $ot_google_fonts_sort = apply_filters( 'ot_google_fonts_sort', 'alpha' ); + + // Initiate API request. + $ot_google_fonts_query_args = array( + 'key' => $ot_google_fonts_api_key, + 'fields' => 'items(' . implode( ',', $ot_google_fonts_fields ) . ')', + 'sort' => $ot_google_fonts_sort, + ); + + // Build and make the request. + $ot_google_fonts_query = esc_url_raw( add_query_arg( $ot_google_fonts_query_args, $ot_google_fonts_api_url ) ); + $ot_google_fonts_response = wp_safe_remote_get( + $ot_google_fonts_query, + array( + 'sslverify' => false, + 'timeout' => 15, + ) + ); + + // Continue if we got a valid response. + if ( 200 === wp_remote_retrieve_response_code( $ot_google_fonts_response ) ) { + + $response_body = wp_remote_retrieve_body( $ot_google_fonts_response ); + + if ( $response_body ) { + + // JSON decode the response body and cache the result. + $ot_google_fonts_data = json_decode( trim( $response_body ), true ); + + if ( is_array( $ot_google_fonts_data ) && isset( $ot_google_fonts_data['items'] ) ) { + + $ot_google_fonts = $ot_google_fonts_data['items']; + + // Normalize the array key. + $ot_google_fonts_tmp = array(); + foreach ( $ot_google_fonts as $key => $value ) { + if ( ! isset( $value['family'] ) ) { + continue; + } + + $id = preg_replace( '/[^a-z0-9_\-]/', '', strtolower( remove_accents( $value['family'] ) ) ); + + if ( $id ) { + $ot_google_fonts_tmp[ $id ] = $value; + } + } + + $ot_google_fonts = $ot_google_fonts_tmp; + set_theme_mod( 'ot_google_fonts', $ot_google_fonts ); + set_transient( $ot_google_fonts_cache_key, $ot_google_fonts, WEEK_IN_SECONDS ); + } + } + } + } + + return $normalize ? ot_normalize_google_fonts( $ot_google_fonts ) : $ot_google_fonts; + } +} - // Has a saved value - if ( ! empty( $old_meta ) && is_array( $old_meta ) ) { +if ( ! function_exists( 'ot_normalize_google_fonts' ) ) { - // Loop over the array - foreach( $old_meta as $key => $value ) { + /** + * Helper function to normalize the Google fonts array. + * + * @param array $google_fonts An array of fonts to normalize. + * + * @return array + * + * @access public + * @since 2.5.0 + */ + function ot_normalize_google_fonts( $google_fonts ) { - foreach( $value as $sub_key => $sub_value ) { + $ot_normalized_google_fonts = array(); - if ( in_array( $sub_key, $option['children'] ) ) { + if ( is_array( $google_fonts ) && ! empty( $google_fonts ) ) { - // The value is an array of IDs - if ( is_array( $sub_value ) ) { + foreach ( $google_fonts as $google_font ) { - // Loop over the array - foreach( $sub_value as $sub_sub_key => $sub_sub_value ) { + if ( isset( $google_font['family'] ) ) { - // It's a single value, just replace it - if ( $sub_sub_value == $term_id ) { + $id = str_replace( ' ', '+', $google_font['family'] ); - unset( $new_meta[$key][$sub_key][$sub_sub_key] ); - $new_meta[$key][$sub_key][$new_term_id] = $new_term_id; + $ot_normalized_google_fonts[ $id ] = array( + 'family' => $google_font['family'], + ); - } + if ( isset( $google_font['variants'] ) ) { + $ot_normalized_google_fonts[ $id ]['variants'] = $google_font['variants']; + } - } + if ( isset( $google_font['subsets'] ) ) { + $ot_normalized_google_fonts[ $id ]['subsets'] = $google_font['subsets']; + } + } + } + } - // It's a single value, just replace it - } else if ( $sub_value == $term_id ) { + return $ot_normalized_google_fonts; + } +} - $new_meta[$key][$sub_key] = $new_term_id; +if ( ! function_exists( 'ot_wpml_register_string' ) ) { + + /** + * Helper function to register a WPML string. + * + * @param string $id The string ID. + * @param string $value The string value. + * + * @access public + * @since 2.1 + */ + function ot_wpml_register_string( $id, $value ) { + if ( function_exists( 'icl_register_string' ) ) { + icl_register_string( 'Theme Options', $id, $value ); + } + } +} - } +if ( ! function_exists( 'ot_wpml_unregister_string' ) ) { + + /** + * Helper function to unregister a WPML string. + * + * @param string $id The string ID. + * + * @access public + * @since 2.1 + */ + function ot_wpml_unregister_string( $id ) { + if ( function_exists( 'icl_unregister_string' ) ) { + icl_unregister_string( 'Theme Options', $id ); + } + } +} - } +if ( ! function_exists( 'ot_maybe_migrate_settings' ) ) { - } + /** + * Maybe migrate Settings. + * + * @access public + * @since 2.3.3 + */ + function ot_maybe_migrate_settings() { + + // Filter the ID to migrate from. + $settings_id = apply_filters( 'ot_migrate_settings_id', '' ); + + // Attempt to migrate Settings. + if ( ! empty( $settings_id ) && false === get_option( ot_settings_id() ) && ot_settings_id() !== $settings_id ) { + + // Old settings. + $settings = get_option( $settings_id ); + + // Check for array keys. + if ( isset( $settings['sections'] ) && isset( $settings['settings'] ) ) { + update_option( ot_settings_id(), $settings ); + } + } + } +} - } +if ( ! function_exists( 'ot_maybe_migrate_options' ) ) { - // Update - if ( $old_meta !== $new_meta ) { - - update_post_meta( $post_id, $option['id'], $new_meta, $old_meta ); - - } + /** + * Maybe migrate Option. + * + * @access public + * @since 2.3.3 + */ + function ot_maybe_migrate_options() { - } + // Filter the ID to migrate from. + $options_id = apply_filters( 'ot_migrate_options_id', '' ); - } + // Attempt to migrate Theme Options. + if ( ! empty( $options_id ) && false === get_option( ot_options_id() ) && ot_options_id() !== $options_id ) { - } + // Old options. + $options = get_option( $options_id ); - } else { - $post_ids = get_posts( array( - 'fields' => 'ids', - 'meta_query' => array( - 'key' => $option['id'], - 'value' => $term_id, - 'compare' => 'IN' - ), - ) ); + // Migrate to new ID. + update_option( ot_options_id(), $options ); + } + } +} - if ( $post_ids ) { +if ( ! function_exists( 'ot_maybe_migrate_layouts' ) ) { - foreach( $post_ids as $post_id ) { + /** + * Maybe migrate Layouts. + * + * @access public + * @since 2.3.3 + */ + function ot_maybe_migrate_layouts() { - // Get the meta - $old_meta = get_post_meta( $post_id, $option['id'], true ); - $new_meta = $old_meta; + // Filter the ID to migrate from. + $layouts_id = apply_filters( 'ot_migrate_layouts_id', '' ); - // Has a saved value - if ( ! empty( $old_meta ) ) { + // Attempt to migrate Layouts. + if ( ! empty( $layouts_id ) && false === get_option( ot_layouts_id() ) && ot_layouts_id() !== $layouts_id ) { - // The value is an array of IDs - if ( is_array( $old_meta ) ) { + // Old options. + $layouts = get_option( $layouts_id ); - // Loop over the array - foreach( $old_meta as $key => $value ) { + // Migrate to new ID. + update_option( ot_layouts_id(), $layouts ); + } + } +} - // It's a single value, just replace it - if ( $value == $term_id ) { +if ( ! function_exists( 'ot_meta_box_post_format_gallery' ) ) { + + /** + * Returns an array with the post format gallery meta box. + * + * @param mixed $pages Excepts a comma separated string or array of + * post_types and is what tells the metabox where to + * display. Default 'post'. + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_meta_box_post_format_gallery( $pages = 'post' ) { + + if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'gallery', current( get_theme_support( 'post-formats' ) ), true ) ) { + return false; + } + + if ( is_string( $pages ) ) { + $pages = explode( ',', $pages ); + } + + return apply_filters( + 'ot_meta_box_post_format_gallery', + array( + 'id' => 'ot-post-format-gallery', + 'title' => esc_html__( 'Gallery', 'option-tree' ), + 'desc' => '', + 'pages' => $pages, + 'context' => 'side', + 'priority' => 'low', + 'fields' => array( + array( + 'id' => '_format_gallery', + 'label' => '', + 'desc' => '', + 'std' => '', + 'type' => 'gallery', + 'class' => 'ot-gallery-shortcode', + ), + ), + ), + $pages + ); + } +} - unset( $new_meta[$key] ); - $new_meta[$new_term_id] = $new_term_id; +if ( ! function_exists( 'ot_meta_box_post_format_link' ) ) { + + /** + * Returns an array with the post format link metabox. + * + * @param mixed $pages Excepts a comma separated string or array of + * post_types and is what tells the metabox where to + * display. Default 'post'. + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_meta_box_post_format_link( $pages = 'post' ) { + + if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'link', current( get_theme_support( 'post-formats' ) ), true ) ) { + return false; + } + + if ( is_string( $pages ) ) { + $pages = explode( ',', $pages ); + } + + return apply_filters( + 'ot_meta_box_post_format_link', + array( + 'id' => 'ot-post-format-link', + 'title' => esc_html__( 'Link', 'option-tree' ), + 'desc' => '', + 'pages' => $pages, + 'context' => 'side', + 'priority' => 'low', + 'fields' => array( + array( + 'id' => '_format_link_url', + 'label' => '', + 'desc' => esc_html__( 'Link URL', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + array( + 'id' => '_format_link_title', + 'label' => '', + 'desc' => esc_html__( 'Link Title', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + ), + ), + $pages + ); + } +} - } +if ( ! function_exists( 'ot_meta_box_post_format_quote' ) ) { + + /** + * Returns an array with the post format quote metabox. + * + * @param mixed $pages Excepts a comma separated string or array of + * post_types and is what tells the metabox where to + * display. Default 'post'. + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_meta_box_post_format_quote( $pages = 'post' ) { + + if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'quote', current( get_theme_support( 'post-formats' ) ), true ) ) { + return false; + } + + if ( is_string( $pages ) ) { + $pages = explode( ',', $pages ); + } + + return apply_filters( + 'ot_meta_box_post_format_quote', + array( + 'id' => 'ot-post-format-quote', + 'title' => esc_html__( 'Quote', 'option-tree' ), + 'desc' => '', + 'pages' => $pages, + 'context' => 'side', + 'priority' => 'low', + 'fields' => array( + array( + 'id' => '_format_quote_source_name', + 'label' => '', + 'desc' => esc_html__( 'Source Name (ex. author, singer, actor)', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + array( + 'id' => '_format_quote_source_url', + 'label' => '', + 'desc' => esc_html__( 'Source URL', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + array( + 'id' => '_format_quote_source_title', + 'label' => '', + 'desc' => esc_html__( 'Source Title (ex. book, song, movie)', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + array( + 'id' => '_format_quote_source_date', + 'label' => '', + 'desc' => esc_html__( 'Source Date', 'option-tree' ), + 'std' => '', + 'type' => 'text', + ), + ), + ), + $pages + ); + + } +} - } +if ( ! function_exists( 'ot_meta_box_post_format_video' ) ) { + + /** + * Returns an array with the post format video metabox. + * + * @param mixed $pages Excepts a comma separated string or array of + * post_types and is what tells the metabox where to + * display. Default 'post'. + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_meta_box_post_format_video( $pages = 'post' ) { + + if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'video', current( get_theme_support( 'post-formats' ) ), true ) ) { + return false; + } + + if ( is_string( $pages ) ) { + $pages = explode( ',', $pages ); + } + + /* translators: %1$s: link to WorPress Codex, %2$s: video shortcode */ + $string = esc_html__( 'Embed video from services like Youtube, Vimeo, or Hulu. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ); + + return apply_filters( + 'ot_meta_box_post_format_video', + array( + 'id' => 'ot-post-format-video', + 'title' => __( 'Video', 'option-tree' ), + 'desc' => '', + 'pages' => $pages, + 'context' => 'side', + 'priority' => 'low', + 'fields' => array( + array( + 'id' => '_format_video_embed', + 'label' => '', + 'desc' => sprintf( $string, '' . esc_html__( 'WordPress Codex', 'option-tree' ) . '', '[video]' ), + 'std' => '', + 'type' => 'textarea', + ), + ), + ), + $pages + ); + } +} - // It's a single value, just replace it - } else if ( $old_meta == $term_id ) { +if ( ! function_exists( 'ot_meta_box_post_format_audio' ) ) { + + /** + * Returns an array with the post format audio metabox. + * + * @param mixed $pages Excepts a comma separated string or array of + * post_types and is what tells the metabox where to + * display. Default 'post'. + * @return array + * + * @access public + * @since 2.4.0 + */ + function ot_meta_box_post_format_audio( $pages = 'post' ) { + + if ( ! current_theme_supports( 'post-formats' ) || ! in_array( 'audio', current( get_theme_support( 'post-formats' ) ), true ) ) { + return false; + } + + if ( is_string( $pages ) ) { + $pages = explode( ',', $pages ); + } + + /* translators: %1$s: link to WorPress Codex, %2$s: audio shortcode */ + $string = esc_html__( 'Embed audio from services like SoundCloud and Radio. You can find a list of supported oEmbed sites in the %1$s. Alternatively, you could use the built-in %2$s shortcode.', 'option-tree' ); + + return apply_filters( + 'ot_meta_box_post_format_audio', + array( + 'id' => 'ot-post-format-audio', + 'title' => esc_html__( 'Audio', 'option-tree' ), + 'desc' => '', + 'pages' => $pages, + 'context' => 'side', + 'priority' => 'low', + 'fields' => array( + array( + 'id' => '_format_audio_embed', + 'label' => '', + 'desc' => sprintf( $string, '' . esc_html__( 'WordPress Codex', 'option-tree' ) . '', '[audio]' ), + 'std' => '', + 'type' => 'textarea', + ), + ), + ), + $pages + ); + + } +} - $new_meta = $new_term_id; +if ( ! function_exists( 'ot_get_option_type_by_id' ) ) { - } + /** + * Returns the option type by ID. + * + * @param string $option_id The option ID. + * @param string $settings_id The settings array ID. + * @return string The option type. + * + * @access public + * @since 2.4.2 + */ + function ot_get_option_type_by_id( $option_id, $settings_id = '' ) { - // Update - if ( $old_meta !== $new_meta ) { - - update_post_meta( $post_id, $option['id'], $new_meta, $old_meta ); - - } + if ( empty( $settings_id ) ) { + $settings_id = ot_settings_id(); + } - } + $settings = get_option( $settings_id, array() ); - } + if ( isset( $settings['settings'] ) ) { - } + foreach ( $settings['settings'] as $value ) { - } + if ( $option_id === $value['id'] && isset( $value['type'] ) ) { + return $value['type']; + } + } + } - } + return false; + } +} - } +if ( ! function_exists( '_ot_settings_potential_shared_terms' ) ) { + + /** + * Build an array of potential Theme Options that could share terms. + * + * @return array + * + * @access private + * @since 2.5.4 + */ + function _ot_settings_potential_shared_terms() { + + $options = array(); + $settings = get_option( ot_settings_id(), array() ); + $option_types = array( + 'category-checkbox', + 'category-select', + 'tag-checkbox', + 'tag-select', + 'taxonomy-checkbox', + 'taxonomy-select', + ); + + if ( isset( $settings['settings'] ) ) { + + foreach ( $settings['settings'] as $value ) { + + if ( isset( $value['type'] ) ) { + + if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) { + + $saved = ot_get_option( $value['id'] ); + + foreach ( $value['settings'] as $item ) { + + if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) { + $sub_options = array(); + + foreach ( $saved as $sub_key => $sub_value ) { + if ( isset( $sub_value[ $item['id'] ] ) ) { + $sub_options[ $sub_key ] = $sub_value[ $item['id'] ]; + } + } + + if ( ! empty( $sub_options ) ) { + $options[] = array( + 'id' => $item['id'], + 'taxonomy' => $value['taxonomy'], + 'parent' => $value['id'], + 'value' => $sub_options, + ); + } + } + } + } + + if ( in_array( $value['type'], $option_types, true ) ) { + $saved = ot_get_option( $value['id'] ); + if ( ! empty( $saved ) ) { + $options[] = array( + 'id' => $value['id'], + 'taxonomy' => $value['taxonomy'], + 'value' => $saved, + ); + } + } + } + } + } + + return $options; + } +} +if ( ! function_exists( '_ot_meta_box_potential_shared_terms' ) ) { + + /** + * Build an array of potential Meta Box options that could share terms. + * + * @return array + * + * @access private + * @since 2.5.4 + */ + function _ot_meta_box_potential_shared_terms() { + global $ot_meta_boxes; + + $options = array(); + $settings = $ot_meta_boxes; + $option_types = array( + 'category-checkbox', + 'category-select', + 'tag-checkbox', + 'tag-select', + 'taxonomy-checkbox', + 'taxonomy-select', + ); + + foreach ( $settings as $setting ) { + + if ( isset( $setting['fields'] ) ) { + + foreach ( $setting['fields'] as $value ) { + + if ( isset( $value['type'] ) ) { + + if ( 'list-item' === $value['type'] && isset( $value['settings'] ) ) { + + $children = array(); + + foreach ( $value['settings'] as $item ) { + + if ( isset( $value['id'] ) && isset( $item['type'] ) && in_array( $item['type'], $option_types, true ) ) { + $children[ $value['id'] ][] = $item['id']; + } + } + + if ( ! empty( $children[ $value['id'] ] ) ) { + $options[] = array( + 'id' => $value['id'], + 'children' => $children[ $value['id'] ], + 'taxonomy' => $value['taxonomy'], + ); + } + } + + if ( in_array( $value['type'], $option_types, true ) ) { + $options[] = array( + 'id' => $value['id'], + 'taxonomy' => $value['taxonomy'], + ); + } + } + } + } + } + + return $options; + } } -add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 ); -/* End of file ot-functions-admin.php */ -/* Location: ./includes/ot-functions-admin.php */ +if ( ! function_exists( 'ot_split_shared_term' ) ) { + + /** + * Update terms when a term gets split. + * + * @param int $term_id ID of the formerly shared term. + * @param int $new_term_id ID of the new term created for the $term_taxonomy_id. + * @param int $term_taxonomy_id ID for the term_taxonomy row affected by the split. + * @param string $taxonomy Taxonomy for the split term. + * + * @access public + * @since 2.5.4 + */ + function ot_split_shared_term( $term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) { + unset( $term_taxonomy_id ); + + // Process the Theme Options. + $settings = _ot_settings_potential_shared_terms(); + $old_options = get_option( ot_options_id(), array() ); + $new_options = $old_options; + + // Process the saved settings. + if ( ! empty( $settings ) && ! empty( $old_options ) ) { + + // Loop over the Theme Options. + foreach ( $settings as $option ) { + + if ( ! is_array( $option['taxonomy'] ) ) { + $option['taxonomy'] = explode( ',', $option['taxonomy'] ); + } + + if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) { + continue; + } + + // The option ID was found. + if ( array_key_exists( $option['id'], $old_options ) || ( isset( $option['parent'] ) && array_key_exists( $option['parent'], $old_options ) ) ) { + + // This is a list item, we have to go deeper. + if ( isset( $option['parent'] ) ) { + + // Loop over the array. + foreach ( $option['value'] as $key => $value ) { + + // The value is an array of IDs. + if ( is_array( $value ) ) { + + // Loop over the sub array. + foreach ( $value as $sub_key => $sub_value ) { + + if ( $sub_value === $term_id ) { + unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $sub_key ] ); + $new_options[ $option['parent'] ][ $key ][ $option['id'] ][ $new_term_id ] = $new_term_id; + } + } + } elseif ( $value === $term_id ) { + unset( $new_options[ $option['parent'] ][ $key ][ $option['id'] ] ); + $new_options[ $option['parent'] ][ $key ][ $option['id'] ] = $new_term_id; + } + } + } else { + + // The value is an array of IDs. + if ( is_array( $option['value'] ) ) { + + // Loop over the array. + foreach ( $option['value'] as $key => $value ) { + + // It's a single value, just replace it. + if ( $value === $term_id ) { + unset( $new_options[ $option['id'] ][ $key ] ); + $new_options[ $option['id'] ][ $new_term_id ] = $new_term_id; + } + } + + // It's a single value, just replace it. + } elseif ( $option['value'] === $term_id ) { + $new_options[ $option['id'] ] = $new_term_id; + } + } + } + } + } + + // Options need to be updated. + if ( $old_options !== $new_options ) { + update_option( ot_options_id(), $new_options ); + } + + // Process the Meta Boxes. + $meta_settings = _ot_meta_box_potential_shared_terms(); + + if ( ! empty( $meta_settings ) ) { + + foreach ( $meta_settings as $option ) { + + if ( ! is_array( $option['taxonomy'] ) ) { + $option['taxonomy'] = explode( ',', $option['taxonomy'] ); + } + + if ( ! in_array( $taxonomy, $option['taxonomy'], true ) ) { + continue; + } + + if ( isset( $option['children'] ) ) { + $post_ids = get_posts( + array( + 'fields' => 'ids', + 'meta_key' => $option['id'], // phpcs:ignore + ) + ); + + if ( $post_ids ) { + + foreach ( $post_ids as $post_id ) { + + // Get the meta. + $old_meta = get_post_meta( $post_id, $option['id'], true ); + $new_meta = $old_meta; + + // Has a saved value. + if ( ! empty( $old_meta ) && is_array( $old_meta ) ) { + + // Loop over the array. + foreach ( $old_meta as $key => $value ) { + + foreach ( $value as $sub_key => $sub_value ) { + + if ( in_array( $sub_key, $option['children'], true ) ) { + + // The value is an array of IDs. + if ( is_array( $sub_value ) ) { + + // Loop over the array. + foreach ( $sub_value as $sub_sub_key => $sub_sub_value ) { + + // It's a single value, just replace it. + if ( $sub_sub_value === $term_id ) { + unset( $new_meta[ $key ][ $sub_key ][ $sub_sub_key ] ); + $new_meta[ $key ][ $sub_key ][ $new_term_id ] = $new_term_id; + } + } + + // It's a single value, just replace it. + } elseif ( $sub_value === $term_id ) { + $new_meta[ $key ][ $sub_key ] = $new_term_id; + } + } + } + } + + // Update. + if ( $old_meta !== $new_meta ) { + update_post_meta( $post_id, $option['id'], $new_meta, $old_meta ); + } + } + } + } + } else { + $post_ids = get_posts( + array( + 'fields' => 'ids', + 'meta_query' => array( // phpcs:ignore + 'key' => $option['id'], + 'value' => $term_id, + 'compare' => 'IN', + ), + ) + ); + + if ( $post_ids ) { + + foreach ( $post_ids as $post_id ) { + + // Get the meta. + $old_meta = get_post_meta( $post_id, $option['id'], true ); + $new_meta = $old_meta; + + // Has a saved value. + if ( ! empty( $old_meta ) ) { + + // The value is an array of IDs. + if ( is_array( $old_meta ) ) { + + // Loop over the array. + foreach ( $old_meta as $key => $value ) { + + // It's a single value, just replace it. + if ( $value === $term_id ) { + unset( $new_meta[ $key ] ); + $new_meta[ $new_term_id ] = $new_term_id; + } + } + + // It's a single value, just replace it. + } elseif ( $old_meta === $term_id ) { + $new_meta = $new_term_id; + } + + // Update. + if ( $old_meta !== $new_meta ) { + update_post_meta( $post_id, $option['id'], $new_meta, $old_meta ); + } + } + } + } + } + } + } + } + + add_action( 'split_shared_term', 'ot_split_shared_term', 10, 4 ); +} From 74661ac2cce5604eed3edab99773603eeafa7b61 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Thu, 7 Mar 2019 06:00:18 -0800 Subject: [PATCH 33/67] Validate encode/decode --- includes/class-ot-meta-box.php | 20 +--- includes/class-ot-settings.php | 26 +---- includes/ot-functions-admin.php | 141 +++++++++++++----------- includes/ot-functions-compat.php | 78 +++---------- includes/ot-functions-option-types.php | 6 +- includes/ot-functions-settings-page.php | 12 +- ot-loader.php | 26 +---- 7 files changed, 117 insertions(+), 192 deletions(-) diff --git a/includes/class-ot-meta-box.php b/includes/class-ot-meta-box.php index 6b7e0f0..15ef206 100755 --- a/includes/class-ot-meta-box.php +++ b/includes/class-ot-meta-box.php @@ -257,16 +257,8 @@ public function save_meta_box( $post_id, $post_object ) { ), ); - $decoded = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - // Convert the settings to an array. - $settings = maybe_unserialize( $decoded ); + $settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array(); // Settings are empty for some odd reason get the defaults. if ( empty( $settings ) ) { @@ -293,16 +285,8 @@ public function save_meta_box( $post_id, $post_object ) { } elseif ( 'social-links' === $field['type'] ) { - $decoded = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - // Convert the settings to an array. - $settings = maybe_unserialize( $decoded ); + $settings = isset( $post_global[ $field['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $field['id'] . '_settings_array' ] ) : array(); // Settings are empty get the defaults. if ( empty( $settings ) ) { diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index 8513a04..5c75a50 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -239,14 +239,14 @@ public function display_page() { $show_buttons = isset( $page['show_buttons'] ) && false === $page['show_buttons'] ? false : true; // Update active layout content. - if ( isset( $_REQUEST['settings-updated'] ) && true === $_REQUEST['settings-updated'] ) { // phpcs:ignore + if ( isset( $_REQUEST['settings-updated'] ) && true === filter_var( wp_unslash( $_REQUEST['settings-updated'] ), FILTER_VALIDATE_BOOLEAN ) ) { // phpcs:ignore $layouts = get_option( ot_layouts_id() ); // Has active layout. if ( isset( $layouts['active_layout'] ) ) { - $option_tree = get_option( $option['id'] ); - $layouts[ $layouts['active_layout'] ] = ot_encode( maybe_serialize( $option_tree ) ); + $option_tree = get_option( $option['id'], array() ); + $layouts[ $layouts['active_layout'] ] = ot_encode( $option_tree ); update_option( ot_layouts_id(), $layouts ); } } @@ -602,16 +602,8 @@ public function sanitize_callback( $input ) { ), ); - $decoded = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - // Convert the settings to an array. - $settings = maybe_unserialize( $decoded ); + $settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array(); // Settings are empty for some odd ass reason get the defaults. if ( empty( $settings ) ) { @@ -644,16 +636,8 @@ public function sanitize_callback( $input ) { } } elseif ( is_array( $input[ $setting['id'] ] ) && 'social-links' === $setting['type'] ) { - $decoded = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : 'YTowOnt9'; // Fallback is an empty encoded array. - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - // Convert the settings to an array. - $settings = maybe_unserialize( $decoded ); + $settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array(); // Settings are empty get the defaults. if ( empty( $settings ) ) { diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index b79044e..fe2b9c7 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -1124,14 +1124,9 @@ function ot_import() { // Default message. $message = 'failed'; - $decoded = isset( $_POST['import_settings'] ) ? ot_decode( $_POST['import_settings'] ) : ''; // phpcs:ignore - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + $settings = isset( $_POST['import_settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_settings'] ) ) ) : array(); - // Prevent object injection. - if ( $matches ) { - - // Convert the settings to an array. - $settings = maybe_unserialize( $decoded ); + if ( is_array( $settings ) && ! empty( $settings ) ) { $settings_safe = ot_validate_settings( $settings ); @@ -1162,15 +1157,9 @@ function ot_import() { // Default message. $message = 'failed'; + $options = isset( $_POST['import_data'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_data'] ) ) ) : array(); - $decoded = isset( $_POST['import_data'] ) ? ot_decode( $_POST['import_data'] ) : ''; // phpcs:ignore - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( $matches ) { - - // Convert the options to an array. - $options = maybe_unserialize( $decoded ); + if ( $options ) { $options_safe = array(); @@ -1219,15 +1208,9 @@ function ot_import() { // Default message. $message = 'failed'; + $layouts = isset( $_POST['import_layouts'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_POST['import_layouts'] ) ) ) : array(); - $decoded = isset( $_POST['import_layouts'] ) ? ot_decode( $_POST['import_layouts'] ) : ''; // phpcs:ignore - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( $matches ) { - - // Convert the layouts to an array. - $layouts = maybe_unserialize( $decoded ); + if ( $layouts ) { // Get settings array. $settings = get_option( ot_settings_id() ); @@ -1248,16 +1231,8 @@ function ot_import() { continue; } - $decoded = $value ? ot_decode( $value ) : 'YTowOnt9'; // Fallback is an empty encoded array. - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - // Convert the options to an array. - $options = maybe_unserialize( $decoded ); + $options = ot_decode( $value ); $options_safe = array(); @@ -1268,11 +1243,11 @@ function ot_import() { } // Store the sanitized values for later. - if ( $key === $layouts_safe['active_layout'] ) { + if ( $key === $layouts['active_layout'] ) { $new_options_safe = $options_safe; } - $layouts_safe[ $key ] = ot_encode( maybe_serialize( $options_safe ) ); + $layouts_safe[ $key ] = ot_encode( $options_safe ); } } @@ -1869,17 +1844,18 @@ function ot_validate_settings_array( $settings = array() ) { if ( 'choices' === $fk ) { foreach ( $field as $ck => $choice ) { foreach ( $choice as $vk => $value ) { - $settings_safe[ $sk ][ $fk ][ $ck ][ $vk ] = $field_types[ $fk ][ $vk ]( $value ); + $settings_safe[ $sk ][ $fk ][ $ck ][ $vk ] = call_user_func( $field_types[ $fk ][ $vk ], $value ); } } } elseif ( 'std' === $fk && is_array( $field ) ) { + $callback = $field_types[ $fk ]; + $array_map = function( $item ) use ( $array_map, $callback ) { + return is_array( $item ) ? array_map( $array_map, $item ) : call_user_func( $callback, $item ); + }; - // This is only for validating an array of standard values coming from a theme-options.php file. - foreach ( $field as $dk => $std ) { - $settings_safe[ $sk ][ $fk ][ $dk ] = $field_types[ $fk ]( $std ); - } + $settings_safe[ $sk ][ $fk ] = array_map( $array_map, $field ); } else { - $sanitized = $field_types[ $fk ]( $field ); + $sanitized = call_user_func( $field_types[ $fk ], $field ); if ( 'rows' === $fk && 0 === $sanitized ) { $sanitized = ''; } @@ -1913,7 +1889,7 @@ function ot_modify_layouts() { $option_tree_layouts = get_option( ot_layouts_id() ); // New layouts value. - $layouts = isset( $_POST[ ot_layouts_id() ] ) ? array_filter( $_POST[ ot_layouts_id() ], 'sanitize_text_field' ) : ''; // phpcs:ignore + $layouts = isset( $_POST[ ot_layouts_id() ] ) ? $_POST[ ot_layouts_id() ] : ''; // phpcs:ignore // Rebuild layout array. $rebuild = array(); @@ -1926,10 +1902,10 @@ function ot_modify_layouts() { $rebuild['active_layout'] = $layouts['active_layout']; } - /* add new and overwrite active layout */ + // Add new and overwrite active layout. if ( isset( $layouts['_add_new_layout_'] ) && ! empty( $layouts['_add_new_layout_'] ) ) { $rebuild['active_layout'] = ot_sanitize_layout_id( $layouts['_add_new_layout_'] ); - $rebuild[ $rebuild['active_layout'] ] = ot_encode( maybe_serialize( get_option( ot_options_id() ) ) ); + $rebuild[ $rebuild['active_layout'] ] = ot_encode( get_option( ot_options_id(), array() ) ); } $first_layout = ''; @@ -1962,22 +1938,31 @@ function ot_modify_layouts() { // Save & show success message. if ( is_array( $rebuild ) && 1 < count( $rebuild ) ) { - $decoded = ot_decode( $rebuild[ $rebuild['active_layout'] ] ); + $options = ot_decode( $rebuild[ $rebuild['active_layout'] ] ); - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); + if ( $options ) { - // Prevent object injection. - if ( $matches ) { + $options_safe = array(); - // Rebuild the theme options. - $rebuild_option_tree = maybe_unserialize( $decoded ); + // Get settings array. + $settings = get_option( ot_settings_id() ); - if ( is_array( $rebuild_option_tree ) ) { + // Has options. + if ( is_array( $options ) ) { + + // Validate options. + if ( is_array( $settings ) ) { + foreach ( $settings['settings'] as $setting ) { + if ( isset( $options[ $setting['id'] ] ) ) { + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); + } + } + } // Execute the action hook and pass the theme options to it. - do_action( 'ot_before_theme_options_save', $rebuild_option_tree ); + do_action( 'ot_before_theme_options_save', $options_safe ); - update_option( ot_options_id(), $rebuild_option_tree ); + update_option( ot_options_id(), $options_safe ); } } @@ -4894,16 +4879,20 @@ function ot_range( $start, $limit, $step = 1 ) { /** * Helper function to return encoded strings. * - * @param array $value The array to encode. + * @param array $value The array to encode. * - * @return string + * @return string|bool * - * @access public - * @since 2.0.13 + * @access public + * @since 2.0.13 + * @updated 2.7.0 */ function ot_encode( $value ) { - $func = 'base64' . '_encode'; // phpcs:ignore - return $func( $value ); + if ( is_array( $value ) ) { + return base64_encode( maybe_serialize( $value ) ); // phpcs:ignore + } + + return false; } } @@ -4920,8 +4909,29 @@ function ot_encode( $value ) { * @since 2.0.13 */ function ot_decode( $value ) { - $func = 'base64' . '_decode'; // phpcs:ignore - return $func( $value ); + + $fallback = array(); + $decoded = base64_decode( $value ); // phpcs:ignore + + // Search for an array. + preg_match( '/a:\d+:{.*?}/', $decoded, $array_matches, PREG_OFFSET_CAPTURE, 0 ); + + // Search for an object. + preg_match( '/O:\d+:"[a-z0-9_]+":\d+:{.*?}/i', $decoded, $obj_matches, PREG_OFFSET_CAPTURE, 0 ); + + // Prevent object injection or non arrays. + if ( $obj_matches || ! $array_matches ) { + return $fallback; + } + + // Convert the options to an array. + $decoded = maybe_unserialize( $decoded ); + + if ( is_array( $decoded ) ) { + return $decoded; + } + + return $fallback; } } @@ -4941,11 +4951,18 @@ function ot_decode( $value ) { function ot_filter_std_value( $value = '', $std = '' ) { if ( is_string( $std ) && ! empty( $std ) ) { - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $std, $matches, PREG_SET_ORDER ); + + // Search for an array. + preg_match( '/a:\d+:{.*?}/', $std, $array_matches, PREG_OFFSET_CAPTURE, 0 ); + + // Search for an object. + preg_match( '/O:\d+:"[a-z0-9_]+":\d+:{.*?}/i', $std, $obj_matches, PREG_OFFSET_CAPTURE, 0 ); // Prevent object injection. - if ( $matches ) { + if ( $array_matches && ! $obj_matches ) { $std = maybe_unserialize( $std ); + } elseif ( $obj_matches ) { + $std = ''; } } diff --git a/includes/ot-functions-compat.php b/includes/ot-functions-compat.php index 195d505..caca202 100755 --- a/includes/ot-functions-compat.php +++ b/includes/ot-functions-compat.php @@ -69,17 +69,8 @@ function compat_ot_import_from_files() { return false; } - $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; - $options = ot_decode( $rawdata ); - - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $options, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - return; - } - - $options = maybe_unserialize( $options ); + $options = isset( $get_data['body'] ) ? ot_decode( $get_data['body'] ) : array(); + $options_safe = array(); // Get settings array. $settings = get_option( ot_settings_id() ); @@ -91,19 +82,14 @@ function compat_ot_import_from_files() { if ( is_array( $settings ) ) { foreach ( $settings['settings'] as $setting ) { - if ( isset( $options[ $setting['id'] ] ) ) { - - $content = ot_stripslashes( $options[ $setting['id'] ] ); - - $options[ $setting['id'] ] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); } } } // Update the option tree array. - update_option( ot_options_id(), $options ); + update_option( ot_options_id(), $options_safe ); } } @@ -116,17 +102,8 @@ function compat_ot_import_from_files() { return false; } - $rawdata = isset( $get_data['body'] ) ? $get_data['body'] : ''; - $layouts = ot_decode( $rawdata ); - - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $layouts, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - return; - } - - $layouts = maybe_unserialize( $layouts ); + $layouts = isset( $get_data['body'] ) ? ot_decode( $get_data['body'] ) : array(); + $layouts_safe = array(); // Get settings array. $settings = get_option( ot_settings_id() ); @@ -140,53 +117,34 @@ function compat_ot_import_from_files() { foreach ( $layouts as $key => $value ) { if ( 'active_layout' === $key ) { + $layouts_safe['active_layout'] = $key; continue; } - $decoded = ot_decode( $value ); - - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - continue; - } - - $options = maybe_unserialize( $decoded ); + $options = ot_decode( $value ); + $options_safe = array(); foreach ( $settings['settings'] as $setting ) { - if ( isset( $options[ $setting['id'] ] ) ) { - - $content = ot_stripslashes( $options[ $setting['id'] ] ); - - $options[ $setting['id'] ] = ot_validate_setting( $content, $setting['type'], $setting['id'] ); - + $options_safe[ $setting['id'] ] = ot_validate_setting( wp_unslash( $options[ $setting['id'] ] ), $setting['type'], $setting['id'] ); } } - $layouts[ $key ] = ot_encode( serialize( $options ) ); // phpcs:ignore + if ( $key === $layouts['active_layout'] ) { + $new_options_safe = $options_safe; + } + + $layouts_safe[ $key ] = ot_encode( $options_safe ); } } // Update the option tree array. - if ( isset( $layouts['active_layout'] ) ) { - - $decoded = ot_decode( $layouts[ $layouts['active_layout'] ] ); - - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - return; - } - - update_option( ot_options_id(), maybe_unserialize( $decoded ) ); - + if ( isset( $new_options_safe ) ) { + update_option( ot_options_id(), $new_options_safe ); } // Update the option tree layouts array. - update_option( ot_layouts_id(), $layouts ); + update_option( ot_layouts_id(), $layouts_safe ); } } } diff --git a/includes/ot-functions-option-types.php b/includes/ot-functions-option-types.php index a71824f..d607ac6 100755 --- a/includes/ot-functions-option-types.php +++ b/includes/ot-functions-option-types.php @@ -1422,7 +1422,7 @@ function ot_type_list_item( $args = array() ) { echo '
      '; // Pass the settings array arround. - echo ''; + echo ''; /** * Settings pages have array wrappers like 'option_tree'. @@ -2185,7 +2185,7 @@ function ot_type_slider( $args = array() ) { echo '
      '; // Pass the settings array around. - echo ''; + echo ''; /** * Settings pages have array wrappers like 'option_tree'. @@ -2350,7 +2350,7 @@ function ot_type_social_links( $args = array() ) { echo '
      '; // Pass the settings array around. - echo ''; + echo ''; /** * Settings pages have array wrappers like 'option_tree'. diff --git a/includes/ot-functions-settings-page.php b/includes/ot-functions-settings-page.php index 7915ad5..abafcca 100755 --- a/includes/ot-functions-settings-page.php +++ b/includes/ot-functions-settings-page.php @@ -330,8 +330,8 @@ function ot_type_export_settings() { echo '
      '; // Get theme options data. - $settings = get_option( ot_settings_id() ); - $settings = ! empty( $settings ) ? ot_encode( maybe_serialize( $settings ) ) : ''; + $settings = get_option( ot_settings_id(), array() ); + $settings = ! empty( $settings ) ? ot_encode( $settings ) : ''; echo '
      '; echo ''; // phpcs:ignore @@ -365,8 +365,8 @@ function ot_type_export_data() { echo '
      '; // Get theme options data. - $data = get_option( ot_options_id() ); - $data = ! empty( $data ) ? ot_encode( maybe_serialize( $data ) ) : ''; + $data = get_option( ot_options_id(), array() ); + $data = ! empty( $data ) ? ot_encode( $data ) : ''; echo '
      '; echo ''; // phpcs:ignore @@ -400,8 +400,8 @@ function ot_type_export_layouts() { echo '
      '; // Get layout data. - $layouts = get_option( ot_layouts_id() ); - $layouts = ! empty( $layouts ) ? ot_encode( maybe_serialize( $layouts ) ) : ''; + $layouts = get_option( ot_layouts_id(), array() ); + $layouts = ! empty( $layouts ) ? ot_encode( $layouts ) : ''; echo '
      '; echo ''; // phpcs:ignore diff --git a/ot-loader.php b/ot-loader.php index dad36dd..94f6c8b 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -577,18 +577,9 @@ public function add_list_item() { $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0; $get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : ''; $type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : ''; - $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'YTowOnt9'; // Fallback is an empty encoded array. - $decoded = ot_decode( $settings ); + $settings = isset( $_REQUEST['settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) ) : array(); - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - echo esc_html__( 'Settings are invalid.', 'option-tree' ); - wp_die(); - } - - ot_list_item_view( $name, $count, array(), $post_id, $get_option, maybe_unserialize( $decoded ), $type ); + ot_list_item_view( $name, $count, array(), $post_id, $get_option, $settings, $type ); wp_die(); } @@ -603,18 +594,9 @@ public function add_social_links() { $post_id = isset( $_REQUEST['post_id'] ) ? absint( $_REQUEST['post_id'] ) : 0; $get_option = isset( $_REQUEST['get_option'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['get_option'] ) ) : ''; $type = isset( $_REQUEST['type'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['type'] ) ) : ''; - $settings = isset( $_REQUEST['settings'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) : 'YTowOnt9'; // Fallback is an empty encoded array. - $decoded = ot_decode( $settings ); - - preg_match_all( '/^a:[0-9]+:{((?!O:[0-9]+:).)*}$/', $decoded, $matches, PREG_SET_ORDER ); - - // Prevent object injection. - if ( ! $matches ) { - echo esc_html__( 'Settings are invalid.', 'option-tree' ); - wp_die(); - } + $settings = isset( $_REQUEST['settings'] ) ? ot_decode( sanitize_text_field( wp_unslash( $_REQUEST['settings'] ) ) ) : array(); - ot_social_links_view( $name, $count, array(), $post_id, $get_option, maybe_unserialize( $decoded ), $type ); + ot_social_links_view( $name, $count, array(), $post_id, $get_option, $settings, $type ); wp_die(); } From 46245c1b49e9852464826fde5fbb6963b036e270 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Thu, 7 Mar 2019 06:50:56 -0800 Subject: [PATCH 34/67] Ensure all keys are present --- includes/class-ot-settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index 5c75a50..35c6a4e 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -436,8 +436,8 @@ public function add_settings() { // Loop through page settings. foreach ( (array) $this->get_the_settings( $page ) as $setting ) { - // Skip if no setting ID. - if ( ! isset( $setting['id'] ) ) { + // Skip if missing setting keys. + if ( ! array_diff_key( array_flip( array( 'id', 'label', 'section' ) ), $setting ) ) { continue; } From 0000828ee9c18dd8f1f3aac9817e24fc11cc5edd Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Thu, 7 Mar 2019 14:48:07 -0800 Subject: [PATCH 35/67] Make it simple --- includes/class-ot-settings.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index 35c6a4e..f085afb 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -436,8 +436,8 @@ public function add_settings() { // Loop through page settings. foreach ( (array) $this->get_the_settings( $page ) as $setting ) { - // Skip if missing setting keys. - if ( ! array_diff_key( array_flip( array( 'id', 'label', 'section' ) ), $setting ) ) { + // Skip if missing setting ID, label, or section. + if ( ! isset( $setting['id'] ) || ! isset( $setting['label'] ) || ! isset( $setting['section'] ) ) { continue; } @@ -453,7 +453,6 @@ public function add_settings() { $setting['section'], $setting ); - } } } From 542b48d34cda28e8f8ef67733644b9d028e7a392 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 20:43:40 -0700 Subject: [PATCH 36/67] Validate all settings on save & support WP 5.0+ --- assets/css/ot-admin.css | 18 +- includes/class-ot-meta-box.php | 14 ++ includes/class-ot-settings.php | 21 +- includes/ot-functions-admin.php | 360 ++++++++++++++++++-------------- ot-loader.php | 7 +- 5 files changed, 257 insertions(+), 163 deletions(-) diff --git a/assets/css/ot-admin.css b/assets/css/ot-admin.css index 591b136..ee6affe 100755 --- a/assets/css/ot-admin.css +++ b/assets/css/ot-admin.css @@ -1187,6 +1187,19 @@ -moz-border-radius: 0 0 2px 2px; border-radius: 0 0 2px 2px; } +.postbox.ot-meta-box { + +} + +#poststuff .postbox.ot-meta-box .inside { + background-color: #f3f4f5; + margin: 0; + padding: 6px 12px 12px; +} + +#poststuff .postbox.ot-meta-box .is-panel { + display: none !important; +} /* -------------------------------------------------- :: Header @@ -2157,6 +2170,9 @@ li ul .format-setting-label { width: 14px; z-index: 10; } +.postbox.ot-meta-box .ot-option-group--icon { + width: 28px; +} .ot-icon-circle.ot-option-group--icon:before { left: 1px; position: relative; @@ -3970,4 +3986,4 @@ a.ui-datepicker-next { .ot-metabox-tabs.ui-tabs .ot-metabox-panel { clear: both; } -} \ No newline at end of file +} diff --git a/includes/class-ot-meta-box.php b/includes/class-ot-meta-box.php index 15ef206..627abda 100755 --- a/includes/class-ot-meta-box.php +++ b/includes/class-ot-meta-box.php @@ -66,8 +66,22 @@ public function __construct( $meta_box ) { * @since 1.0 */ public function add_meta_boxes() { + global $wp_version; + + $is_wp_5 = version_compare( $wp_version, '5.0', '>=' ); + foreach ( (array) $this->meta_box['pages'] as $page ) { add_meta_box( $this->meta_box['id'], $this->meta_box['title'], array( $this, 'build_meta_box' ), $page, $this->meta_box['context'], $this->meta_box['priority'], $this->meta_box['fields'] ); + + if ( $is_wp_5 ) { + add_filter( + 'postbox_classes_' . $page . '_' . $this->meta_box['id'], + function( $classes ) { + array_push( $classes, 'ot-meta-box' ); + return $classes; + } + ); + } } } diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index f085afb..456e325 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -617,6 +617,7 @@ public function sanitize_callback( $input ) { foreach ( $input[ $setting['id'] ] as $k => $setting_array ) { + $has_value = false; foreach ( $settings as $sub_setting ) { // Setup the WPML ID. @@ -632,6 +633,10 @@ public function sanitize_callback( $input ) { $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); } } + + if ( ! $has_value ) { + unset( $input[ $setting['id'] ][ $k ] ); + } } } elseif ( is_array( $input[ $setting['id'] ] ) && 'social-links' === $setting['type'] ) { @@ -648,6 +653,7 @@ public function sanitize_callback( $input ) { foreach ( $input[ $setting['id'] ] as $k => $setting_array ) { + $has_value = false; foreach ( $settings as $sub_setting ) { // Setup the WPML ID. @@ -659,10 +665,23 @@ public function sanitize_callback( $input ) { // Verify sub setting has a type & value. if ( isset( $sub_setting['type'] ) && isset( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] ) ) { + if ( 'href' === $sub_setting['id'] ) { + $sub_setting['type'] = 'url'; + } + // Validate setting. - $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); + $input_safe = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); + + if ( ! empty( $input_safe ) ) { + $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = $input_safe; + $has_value = true; + } } } + + if ( ! $has_value ) { + unset( $input[ $setting['id'] ][ $k ] ); + } } } else { $input[ $setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ], $setting['type'], $setting['id'], $setting['id'] ); diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index fe2b9c7..161130e 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -434,250 +434,282 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { return $input; } + /** + * Filter to modify a setting field value before validation. + * + * This cannot be used to filter the returned value of a custom + * setting type. You must use the `ot_validate_setting_input_safe` + * filter to ensure custom setting types are saved to the database. + * + * @param mixed $input The setting field value. + * @param string $type The setting field type. + * @param string $field_id The setting field ID. + */ $input = apply_filters( 'ot_validate_setting', $input, $type, $field_id ); + /** + * Filter to validate a setting field value. + * + * @param mixed $input_safe This is either null, or the filtered input value. + * @param mixed $input The setting field value. + * @param string $type The setting field type. + * @param string $field_id The setting field ID. + */ + $input_safe = apply_filters( 'ot_validate_setting_input_safe', null, $input, $type, $field_id ); + + // The value was filtered and is safe to return. + if ( ! is_null( $input_safe ) ) { + return $input_safe; + } + /* translators: %1$s: the input id, %2$s: the field id */ $string_nums = esc_html__( 'The %1$s input field for %2$s only allows numeric values.', 'option-tree' ); - /* translators: %s: the field id */ - $string_color = esc_html__( 'The %s Colorpicker only allows valid hexadecimal or rgba values.', 'option-tree' ); - if ( 'background' === $type ) { - $input['background-color'] = ot_validate_setting( $input['background-color'], 'colorpicker', $field_id ); - - $input['background-image'] = ot_validate_setting( $input['background-image'], 'upload', $field_id ); + $input_safe = array(); // Loop over array and check for values. foreach ( (array) $input as $key => $value ) { - if ( ! empty( $value ) ) { - $has_value = true; + if ( 'background-color' === $key ) { + $input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); + } elseif ( 'background-image' === $key ) { + $input_safe[ $key ] = ot_validate_setting( $value, 'upload', $field_id ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); } } - - // No value; set to empty. - if ( ! isset( $has_value ) ) { - $input = ''; - } } elseif ( 'border' === $type ) { + $input_safe = array(); + // Loop over array and set errors or unset key from array. foreach ( $input as $key => $value ) { - // Validate width. - if ( 'width' === $key && ! empty( $value ) && ! is_numeric( $value ) ) { - - $input[ $key ] = '0'; - - add_settings_error( 'option-tree', 'invalid_border_width', sprintf( $string_nums, 'width', '' . $field_id . '' ), 'error' ); - - } - - // Validate color. - if ( 'color' === $key && ! empty( $value ) ) { - - $input[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); - + if ( empty( $value ) ) { + continue; } - // Unset keys with empty values. - if ( empty( $value ) && 0 === strlen( $value ) ) { - unset( $input[ $key ] ); + // Validate width. + if ( 'width' === $key ) { + if ( ! is_numeric( $value ) ) { + add_settings_error( 'option-tree', 'invalid_border_width', sprintf( $string_nums, 'width', '' . $field_id . '' ), 'error' ); + } else { + $input_safe[ $key ] = absint( $value ); + } + } elseif ( 'color' === $key ) { + $input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); } } - - if ( empty( $input ) ) { - $input = ''; - } } elseif ( 'box-shadow' === $type ) { - // Validate inset. - $input['inset'] = isset( $input['inset'] ) ? 'inset' : ''; - - // Validate offset-x. - $input['offset-x'] = isset( $input['offset-x'] ) ? ot_validate_setting( $input['offset-x'], 'text', $field_id ) : ''; - - // Validate offset-y. - $input['offset-y'] = isset( $input['offset-y'] ) ? ot_validate_setting( $input['offset-y'], 'text', $field_id ) : ''; - - // Validate blur-radius. - $input['blur-radius'] = isset( $input['blur-radius'] ) ? ot_validate_setting( $input['blur-radius'], 'text', $field_id ) : ''; - - // Validate spread-radius. - $input['spread-radius'] = isset( $input['spread-radius'] ) ? ot_validate_setting( $input['spread-radius'], 'text', $field_id ) : ''; - - // Validate color. - $input['color'] = isset( $input['color'] ) ? ot_validate_setting( $input['color'], 'colorpicker', $field_id ) : ''; + $input_safe = array(); - // Unset keys with empty values. - foreach ( $input as $key => $value ) { - if ( empty( $value ) && 0 === strlen( $value ) ) { - unset( $input[ $key ] ); + // Loop over array and check for values. + foreach ( (array) $input as $key => $value ) { + if ( 'inset' === $key ) { + $input_safe[ $key ] = 'inset'; + } elseif ( 'color' === $key ) { + $input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); } } + } elseif ( 'checkbox' === $type ) { - // Set empty array to empty string. - if ( empty( $input ) ) { - $input = ''; + $input_safe = array(); + + // Loop over array and check for values. + foreach ( (array) $input as $key => $value ) { + if ( ! empty( $value ) ) { + $input_safe[ $key ] = sanitize_text_field( $value ); + } } } elseif ( 'colorpicker' === $type ) { - // Return empty & set error. - if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) { + $input_safe = ''; - $input = ''; + // Only strings are allowed. + if ( is_string( $input ) ) { - add_settings_error( 'option-tree', 'invalid_hex', sprintf( $string_color, '' . $field_id . '' ), 'error' ); + /* translators: %s: the field id */ + $string_color = esc_html__( 'The %s Colorpicker only allows valid hexadecimal or rgba values depending on the setting type.', 'option-tree' ); + if ( 0 === preg_match( '/^#([a-f0-9]{6}|[a-f0-9]{3})$/i', $input ) && 0 === preg_match( '/^rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]{1,4})\s*\)/i', $input ) ) { + add_settings_error( 'option-tree', 'invalid_hex_or_rgba', sprintf( $string_color, '' . $field_id . '' ), 'error' ); + } else { + $input_safe = $input; + } } } elseif ( 'colorpicker-opacity' === $type ) { + $input_safe = ot_validate_setting( $input, 'colorpicker', $field_id ); + } elseif ( in_array( $type, array( 'category-checkbox', 'custom-post-type-checkbox', 'page-checkbox', 'post-checkbox', 'tag-checkbox', 'taxonomy-checkbox' ), true ) ) { - // Not allowed. - if ( is_array( $input ) ) { - $input = ''; + $input_safe = array(); + + // Loop over array and check for values. + foreach ( (array) $input as $key => $value ) { + if ( filter_var( $value, FILTER_VALIDATE_INT ) && 0 < $value ) { + $input_safe[ $key ] = absint( $value ); + } } + } elseif ( in_array( $type, array( 'category-select', 'custom-post-type-select', 'page-select', 'post-select', 'tag-select', 'taxonomy-select' ), true ) ) { - // Validate color. - $input = ot_validate_setting( $input, 'colorpicker', $field_id ); + $input_safe = ''; + if ( filter_var( $input, FILTER_VALIDATE_INT ) && 0 < $input ) { + $input_safe = absint( $input ); + } } elseif ( in_array( $type, array( 'css', 'javascript', 'text', 'textarea', 'textarea-simple' ), true ) ) { - - if ( ! current_user_can( 'unfiltered_html' ) && false === OT_ALLOW_UNFILTERED_HTML ) { - - $input = wp_kses_post( $input ); - + $filter = function( $tags, $context ) { + if ( 'post' === $context ) { + if ( current_user_can( 'unfiltered_html' ) || true === OT_ALLOW_UNFILTERED_HTML ) { + $tags['script'] = array_fill_keys( array( 'async', 'charset', 'defer', 'src', 'type' ), 1 ); + $tags['style'] = array_fill_keys( array( 'media', 'type' ), 1 ); + $tags['iframe'] = array_fill_keys( array( 'align', 'frameborder', 'height', 'longdesc', 'marginheight', 'marginwidth', 'name', 'sandbox', 'scrolling', 'src', 'srcdoc', 'width' ), 1 ); + + $tags = apply_filters( 'ot_allowed_html', $tags ); + } + } + return $tags; + }; + + add_filter( 'wp_kses_allowed_html', $filter, 10, 2 ); + $input_safe = wp_kses_post( $input ); + remove_filter( 'wp_kses_allowed_html', $filter ); + } elseif ( 'date-picker' === $type || 'date-time-picker' === $type ) { + if ( ! empty( $input ) && (bool) strtotime( $input ) ) { + $input_safe = sanitize_text_field( $input ); } } elseif ( 'dimension' === $type ) { - // Loop over array and set error keys or unset key from array. + $input_safe = array(); + + // Loop over array and set errors. foreach ( $input as $key => $value ) { - if ( ! empty( $value ) && ! is_numeric( $value ) && 'unit' !== $key ) { - $errors[] = $key; - } - if ( empty( $value ) && 0 === strlen( $value ) ) { - unset( $input[ $key ] ); + if ( ! empty( $value ) ) { + if ( ! is_numeric( $value ) && 'unit' !== $key ) { + add_settings_error( 'option-tree', 'invalid_dimension_' . $key, sprintf( $string_nums, '' . $key . '', '' . $field_id . '' ), 'error' ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); + } } } + } elseif ( 'gallery' === $type ) { - // Return 0 & set error. - if ( isset( $errors ) ) { - - foreach ( $errors as $error ) { - - $input[ $error ] = '0'; - - add_settings_error( 'option-tree', 'invalid_dimension_' . $error, sprintf( $string_nums, '' . $error . '', '' . $field_id . '' ), 'error' ); - - } - } + $input_safe = ''; - if ( empty( $input ) ) { - $input = ''; + if ( '' !== trim( $input ) ) { + $input_safe = sanitize_text_field( $input ); } } elseif ( 'google-fonts' === $type ) { - unset( $input['%key%'] ); + $input_safe = array(); - // Loop over array and check for values. - if ( is_array( $input ) && ! empty( $input ) ) { - $input = array_values( $input ); - } + // Loop over array. + foreach ( $input as $key => $value ) { + if ( '%key%' === $key ) { + continue; + } - // No value; set to empty. - if ( empty( $input ) ) { - $input = ''; + foreach ( $value as $fk => $fvalue ) { + if ( is_array( $fvalue ) ) { + foreach ( $fvalue as $sk => $svalue ) { + $input_safe[ $key ][ $fk ][ $sk ] = sanitize_text_field( $svalue ); + } + } else { + $input_safe[ $key ][ $fk ] = sanitize_text_field( $fvalue ); + } + } } + + array_values( $input_safe ); } elseif ( 'link-color' === $type ) { + $input_safe = array(); + // Loop over array and check for values. if ( is_array( $input ) && ! empty( $input ) ) { foreach ( $input as $key => $value ) { if ( ! empty( $value ) ) { - $input[ $key ] = ot_validate_setting( $input[ $key ], 'colorpicker', $field_id . '-' . $key ); - $has_value = true; + $input_safe[ $key ] = ot_validate_setting( $input[ $key ], 'colorpicker', $field_id . '-' . $key ); } } } - // No value; set to empty. - if ( ! isset( $has_value ) ) { - $input = ''; - } + array_filter( $input_safe ); } elseif ( 'measurement' === $type ) { - $input[0] = sanitize_text_field( $input[0] ); + $input_safe = array(); - // No value; set to empty. - if ( empty( $input[0] ) && 0 === strlen( $input[0] ) && empty( $input[1] ) ) { - $input = ''; - } - } elseif ( 'spacing' === $type ) { - - // Loop over array and set error keys or unset key from array. foreach ( $input as $key => $value ) { - if ( ! empty( $value ) && ! is_numeric( $value ) && 'unit' !== $key ) { - $errors[] = $key; + if ( ! empty( $value ) ) { + $input_safe[ $key ] = sanitize_text_field( $value ); } - if ( empty( $value ) && 0 === strlen( $value ) ) { - unset( $input[ $key ] ); + } + } elseif ( 'numeric-slider' === $type ) { + $input_safe = ''; + + if ( ! empty( $input ) ) { + if ( ! is_numeric( $input ) ) { + add_settings_error( 'option-tree', 'invalid_numeric_slider', sprintf( $string_nums, '' . esc_html__( 'slider', 'option-tree' ) . '', '' . $field_id . '' ), 'error' ); + } else { + $input_safe = sanitize_text_field( $input ); } } + } elseif ( 'on-off' === $type ) { + $input_safe = ''; - // Return 0 & set error. - if ( isset( $errors ) ) { + if ( ! empty( $input ) ) { + $input_safe = sanitize_text_field( $input ); + } + } elseif ( 'radio' === $type || 'radio-image' === $type || 'select' === $type || 'sidebar-select' === $type ) { + $input_safe = ''; - foreach ( $errors as $error ) { + if ( ! empty( $input ) ) { + $input_safe = sanitize_text_field( $input ); + } + } elseif ( 'spacing' === $type ) { - $input[ $error ] = '0'; + $input_safe = array(); - add_settings_error( 'option-tree', 'invalid_spacing_' . $error, sprintf( $string_nums, '' . $error . '', '' . $field_id . '' ), 'error' ); + // Loop over array and set errors. + foreach ( $input as $key => $value ) { + if ( ! empty( $value ) ) { + if ( ! is_numeric( $value ) && 'unit' !== $key ) { + add_settings_error( 'option-tree', 'invalid_spacing_' . $key, sprintf( $string_nums, '' . $key . '', '' . $field_id . '' ), 'error' ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); + } } } - - if ( empty( $input ) ) { - $input = ''; - } } elseif ( 'typography' === $type && isset( $input['font-color'] ) ) { - $input['font-color'] = ot_validate_setting( $input['font-color'], 'colorpicker', $field_id ); + $input_safe = array(); // Loop over array and check for values. foreach ( $input as $key => $value ) { - if ( ! empty( $value ) ) { - $has_value = true; + if ( 'font-color' === $key ) { + $input_safe[ $key ] = ot_validate_setting( $value, 'colorpicker', $field_id ); + } else { + $input_safe[ $key ] = sanitize_text_field( $value ); } } - - // No value; set to empty. - if ( ! isset( $has_value ) ) { - $input = ''; - } } elseif ( 'upload' === $type ) { - if ( filter_var( $input, FILTER_VALIDATE_INT ) === false ) { - $input = esc_url_raw( $input ); - } - } elseif ( 'gallery' === $type ) { - - $input = trim( $input ); - - } elseif ( 'social-links' === $type ) { + $input_safe = filter_var( $input, FILTER_VALIDATE_INT ); - // Loop over array and check for values, plus sanitize the text field. - foreach ( (array) $input as $key => $value ) { - if ( ! empty( $value ) && is_array( $value ) ) { - foreach ( (array) $value as $item_key => $item_value ) { - if ( ! empty( $item_value ) ) { - $has_value = true; - $input[ $key ][ $item_key ] = sanitize_text_field( $item_value ); - } - } - } + if ( false === $input_safe && is_string( $input ) ) { + $input_safe = esc_url_raw( $input ); } + } elseif ( 'url' === $type ) { + + $input_safe = ''; - // No value; set to empty. - if ( ! isset( $has_value ) ) { - $input = ''; + if ( ! empty( $input ) ) { + $input_safe = esc_url_raw( $input ); } } @@ -688,17 +720,27 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { $single_string_types = apply_filters( 'ot_wpml_option_types', array( 'text', 'textarea', 'textarea-simple' ) ); if ( in_array( $type, $single_string_types, true ) ) { - if ( ! empty( $input ) ) { - ot_wpml_register_string( $wmpl_id, $input ); + if ( ! empty( $input_safe ) ) { + ot_wpml_register_string( $wmpl_id, $input_safe ); } else { ot_wpml_unregister_string( $wmpl_id ); } } } - $input = apply_filters( 'ot_after_validate_setting', $input, $type, $field_id ); + /** + * Filter to modify the validated setting field value. + * + * It's important to note that the filter does not have access to + * the original value and can only modify the validated input value. + * + * @param mixed $input_safe The setting field value. + * @param string $type The setting field type. + * @param string $field_id The setting field ID. + */ + $input_safe = apply_filters( 'ot_after_validate_setting', $input_safe, $type, $field_id ); - return $input; + return $input_safe; } } diff --git a/ot-loader.php b/ot-loader.php index 94f6c8b..c6e5714 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -192,11 +192,14 @@ private function constants() { /** * For developers: Allow Unfiltered HTML in all the textareas. * - * Run a filter and set to true if you want all the - * users to be able to post anything in the textareas. + * Run a filter and set to true if you want all the users to be + * able to add script, style, and iframe tags in the textareas. * WARNING: This opens a security hole for low level users * to be able to post malicious scripts, you've been warned. * + * If a user can already post `unfiltered_html` then the tags + * above will be available to them without setting this to `true`. + * * @since 2.0 */ define( 'OT_ALLOW_UNFILTERED_HTML', apply_filters( 'ot_allow_unfiltered_html', false ) ); From 64750a2d7af0a674dacdc4bce69c3ab101d83e08 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 21:45:56 -0700 Subject: [PATCH 37/67] Only load if there is access to WordPress --- ot-loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot-loader.php b/ot-loader.php index c6e5714..63573c4 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -26,7 +26,7 @@ function ot_conflict_notice() { add_action( 'admin_notices', 'ot_conflict_notice' ); } -if ( ! class_exists( 'OT_Loader' ) ) { +if ( ! class_exists( 'OT_Loader' ) && defined( 'ABSPATH' ) ) { /** * OptionTree loader class. From 054bb14d60125e4a3e0a6db9a8be030109b42c92 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 21:50:01 -0700 Subject: [PATCH 38/67] Add project type --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 3832d21..663dd8e 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "valendesigns/option-tree", "description": "Theme Options UI Builder for WordPress.", + "type": "wordpress-plugin", "homepage": "https://github.com/valendesigns/option-tree", "license": "GPLv3", "authors": [ From 498f1a6158ef3a88f703bd29470853ddaf25245b Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 21:56:47 -0700 Subject: [PATCH 39/67] Updates for v2.7.0 --- readme.md | 649 ++++++++++++++++++++++++++ readme.txt | 1283 ++++++++++++++++++++++++++-------------------------- 2 files changed, 1296 insertions(+), 636 deletions(-) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..c2ea67d --- /dev/null +++ b/readme.md @@ -0,0 +1,649 @@ + +# OptionTree + +Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. + +**Contributors:** [valendesigns](https://profiles.wordpress.org/valendesigns) +**Tags:** [options](https://wordpress.org/plugins/tags/options), [theme options](https://wordpress.org/plugins/tags/theme-options), [meta boxes](https://wordpress.org/plugins/tags/meta-boxes) +**Requires at least:** 3.8 +**Tested up to:** 5.1 +**Stable tag:** 2.7.0 +**License:** GPLv3 +**Donate link:** https://bit.ly/2TBvksV + +[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) [![Coverage Status](https://coveralls.io/repos/valendesigns/option-tree/badge.svg?branch=develop)](https://coveralls.io/github/valendesigns/option-tree) + +## Description ## + +OptionTree attempts to bridge the gap between WordPress developers, designers and end-users by creating fully responsive option panels and meta boxes with an ease unlike any other plugin. OptionTree has many advanced features with well placed hooks and filters to adjust every aspect of the user experience. + +Build your Theme Options panel locally with an easy to use drag & drop interface and then export a functioning `theme-options.php` file for production use that is i18n translation ready, with your custom text domain automatically inserted. + +And, in just a few simple lines of code, save settings to the database with a unique array ID so none of your Theme Options conflict with other themes that use OptionTree. + +Also, OptionTree now takes full advantage of the new color schemes introduced in WordPress 3.8, it looks and feels built-in. + +#### Theme Integration +If you're like me, you want to know how everything works. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and see first hand how to integrate OptionTree into your own project. I'll walk you through installing OptionTree and you'll get a chance to see all the various options and filters first hand and in the wild. + +#### Contributing +To contribute or report bugs, please go to the [OptionTree Github](https://github.com/valendesigns/option-tree) repository. + +#### Sponsorship +OptionTree is a project partly sponsored by ThemeForest, the largest WordPress theme marketplace on the web. + +#### Option Types +This is a complete list of all the available option types that come shipped with OptionTree. + +* Background +* Border +* Box Shadow +* Category Checkbox +* Category Select +* Checkbox +* Colorpicker +* Colorpicker Opacity +* CSS +* Custom Post Type Checkbox +* Custom Post Type Select +* Date Picker +* Date Time Picker +* Dimension +* Gallery +* Google Fonts +* JavaScript +* Link Color +* List Item +* Measurement +* Numeric Slider +* On/Off +* Page Checkbox +* Page Select +* Post Checkbox +* Post Select +* Radio +* Radio Image +* Select +* Sidebar Select +* Slider +* Social Links +* Spacing +* Tab +* Tag Checkbox +* Tag Select +* Taxonomy Checkbox +* Taxonomy Select +* Text +* Textarea +* Textarea Simple +* Textblock +* Textblock Titled +* Typography +* Upload + +## Installation ## + +**Plugin Mode** + +1. Upload `option-tree` to the `/wp-content/plugins/` directory +1. Activate the plugin through the `Plugins` menu in WordPress +1. Click the `OptionTree->Documentation` link in the WordPress admin sidebar menu for further setup assistance. + +**Theme Mode** + +1. Download the latest version of OptionTree and unarchive the `.zip` directory. +1. Put the `option-tree` directory in the root of your theme. For example, the server path would be `/wp-content/themes/theme-name/option-tree/`. +1. You must deactivate and/or delete the plugin version of OptionTree. +1. Add the following code to the beginning of your `functions.php`. + +`/** + * Required: set 'ot_theme_mode' filter to true. + */ +add_filter( 'ot_theme_mode', '__return_true' ); + +/** + * Required: include OptionTree. + */ +require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );` + +For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode. + +## Frequently Asked Questions ## + +### Is there a demo theme I can install? ### +There sure is, and I'm glad you asked. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and get some experience setting up OptionTree on your own with detailed directions and tips. + +### Why are my translation files not loading? ### +It is important to note that when you use OptionTree as a plugin, you must store your language files in the `option-tree/languages` directory and use file names like `option-tree-es_ES.mo` & `option-tree-es_ES.po`. However, when using OptionTree in Theme Mode you must also create a `theme-mode` directory inside the `option-tree/languages` directory and store your files there with names like `es_ES.mo` & `es_ES.po`. This is due to the different naming conventions of the `load_plugin_textdomain()` and `load_theme_textdomain()` functions. + +### I get errors or a blank screen when I activate the plugin. What's the deal? ### +The most likely scenario is your theme already has OptionTree installed in Theme Mode. And since the plugin and theme version can't both be active at the same time without the sky falling on your head, your site has decided to throw in the towel. If that's not your issue, open up a support request and we'll figure it out together. UPDATE: As of OptionTree 2.4.0 the plugin version will not conflict with the Theme Mode version if they are both 2.4.0 or higher. + + +## Screenshots ## + + +## Changelog ## + +### 2.7.0 ### +* Require PHP 5.3+ +* Fix all PHPCS errors and warnings. +* Fix a vulnerability where Object Injection could take place if someone has a valid nonce. +* Force all settings to be sanitized and escaped before saving and during display. +* Add filter `ot_validate_setting_input_safe` which is used to validate the input value of a custom setting type. All values must be validated! +* Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50 +* Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred +* Fix notice "Only variables should be passed by reference". props @SergeAx +* Add `wordpress-plugin` project type to composer file. props @egifford + +### 2.6.0 ### +* Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. +* Fix the Google Fonts URL so it passed the W3 Validator. props @BassemN +* Fix `global_admin_css` so it's only enqueued when needed. +* Fix `dynamic.css` so that a child theme doesn't load the styles saved to the parent theme. +* Add filter `ot_recognized_post_format_meta_boxes` to support additional post formats meta boxes. props @BassemN +* Add action `ot_do_settings_fields_before` & `ot_do_settings_fields_after`. props @BassemN, @valendesigns +* Add Text Domain to plugin file to fully support the new translate.wordpress.org Language Packs. +* Fix notice in PHP 7.0.0 props @Zackio + +### 2.5.5 ### +* Hotfix - Allow a `0` value to be saved with certain option types. Contributors via github @BassemN. +* Hotfix - Stop media from being attached to the OptionTree post type when uploaded from the media manager or customizer. Contributors via github @earnjam, and @valendesigns. +* Hotfix - Added filter `ot_load_dynamic_css` to explicitly turn the feature off if desired. +* Hotfix - Stopped `dynamic.css` created with other themes from being loaded elsewhere. + +### 2.5.4 ### +* Hotfix - Support for WordPress 4.2 term splitting. +* Hotfix - Removed any potential XSS security issues with `add_query_arg` by escaping it. +* Hotfix - Fixed an issue where Visual Composer was indirectly destroying OptionTree meta box values. +* Hotfix - Fixed an issue where the select field value was not visible. Contributors via github @sabbirk15. + +### 2.5.3 ### +* Hotfix - Added `inherit` fallback to the `border` option type in dynamic.css. +* Hotfix - Added `none` fallback to the `box-shadow` option type in dynamic.css. +* Hotfix - Added `inherit` fallback to the `colorpicker` option type in dynamic.css. +* Hotfix - Added `inherit` fallback to the `colorpicker-opacity` option type in dynamic.css. +* Hotfix - Added filter `ot_insert_css_with_markers_fallback` to filter the `dynamic.css` fallback value. +* Hotfix - Added filter `ot_type_radio_image_attributes` to filter the image attributes for each radio choice. Contributors via github @BassemN, and @valendesigns. +* Hotfix - Refactored `ot_insert_css_with_markers` to remove confusing & unnecessary PHP statements and fix whitespace. +* Hotfix - Fixed an issue in `ot_insert_css_with_markers` where the `$option_type` variable was not being set properly. +* Hotfix - Fixed an issue where having multiple Google Fonts option types caused the "Add Google Font" button to insert multiple dropdowns. + +### 2.5.2 ### +* Hotfix - Added `inherit` fallback to the `link-color` option type in dynamic.css. +* Hotfix - Remove `$.browser.msie` JS error caused by function being deprecated. +* Hotfix - Change `hover` to `mouseenter mouseleave` to stop jQuery migrate error message. +* Hotfix - Don't allow duplicate Google Fonts in the `ot-google-fonts-css` enqueue. +* Hotfix - Fixed an issue with the CSS and JavaScript option types not being initiating inside of tabs. +* Hotfix - Fixed metabox tab styles for mobile. +* Hotfix - Separate the post formats JS so it does not interfere with the default behavior and loads only as needed. +* Hotfix - Adding the `not-sortable` class to the List Item option type will remove the sortable feature for that option. + +### 2.5.1 ### +* Hotfix - Overhaul the Colorpicker Opacity option type so it saves rgba values, not arrays. +* Hotfix - Added the ability to set opacity on any colorpicker with the `ot-colorpicker-opacity` class. +* Hotfix - Don't use `esc_url_raw` to filter the Upload option type when it's saving an attachment ID. Contributors via github @RistoNiinemets. +* Hotfix - Show an error message to user if unable to write to the `dynamic.css` file. Contributors via github @johnh10, and @valendesigns. +* Hotfix - Force the `ot_google_fonts` array to be rebuilt when switching between themes. +* Hotfix - Stop theme check from nagging about using `add_menu_page` in `ot-cleanup-api.php`. + +### 2.5.0 ### +* Added the Google Fonts option type. Contributors via github @maimairel, and @valendesigns. +* Added the Border option type. Contributors via github @doitmax, and @valendesigns. +* Added the Box Shadow option type. Contributors via github @doitmax, and @valendesigns. +* Added the Colorpicker Opacity option type. Contributors via github @doitmax, and @valendesigns. +* Added the Dimension option type. Contributors via github @doitmax, and @valendesigns. +* Added the JavaScript option type. +* Added the Link Color option type. Contributors via github @doitmax, and @valendesigns. +* Added the Spacing option type. Contributors via github @doitmax, and @valendesigns. +* Fixed an issue where the Colorpicker was not parsing conditions on `change` or `clear`. +* Fixed the Colorpicker styles on mobile devices. +* Show the Colorpicker setting ID inside the error message string when the value is invalid. +* Added an 'on change' trigger to the Numeric Slider's hidden input. Contributors via github @cubell. +* Stop Theme Check from complaining about the `register_post_type()` function being used in Theme Mode. +* Added styles that clean up the appearance of the included Font Awesome icons in section tabs. +* Fixed jQuery UI style conflicts created by the WP Review plugin. +* Changed the sanitization function from `sanitize_text_field` to `esc_url_raw` for the Upload option type. +* Added filter `ot_dequeue_jquery_ui_css_screen_ids` to dequeue `jquery-ui-css` by screen ID. +* Added filter `ot_on_off_switch_on_value` to filter the value of the On button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_on_label` to filter the label of the On button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_off_value` to filter the value of the Off button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_off_label` to filter the label of the Off button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_width` to filter the width of the On/Off switch. +* Added filter `ot_type_date_picker_readonly` to filter the addition of the readonly attribute. +* Added filter `ot_type_date_time_picker_readonly` to filter the addition of the readonly attribute. +* Added filter `ot_admin_menu_priority` to filter the `admin_menu` action hook priority. +* Added Estonian translation. Contributors via github @tjuris, and @RistoNiinemets. +* Fixed an issue where changes to `theme-options.php` required a second page load. +* Fixed the clean up script, it only displays when there's something to clean up. No more menu item! +* Update demo files with the latest option types. +* Changed where `ot_css_file_paths` is saved when `is_multisite` for better `dynamic.css` file support. +* Changed the default `dynamic.css` file path in multisite to be `dynamic-{current-blog-id}.css`. + +### 2.4.6 ### +* Hotfix - Added a clean up script to consolidate orphaned media posts and remove the old and unused `wp_option_tree` table. +* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was never able to set the value of the `ot_media_post_ID` option because it was already set to empty. Causing the `ot_create_media_post()` function to create multiple media posts. + +### 2.4.5 ### +* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was setting the value of the `ot_media_post_ID` option to `null`. Causing the `ot_create_media_post()` function to create multiple media posts. A clean up script will be added to `2.5.0`. + +### 2.4.4 ### +* Hotfix - Fixed undefined index caused by shorthand conditional. +* Hotfix - Fixed jQuery UI style conflicts created by the Easy Digital Downloads plugin. +* Hotfix - Added placeholder to background-image. Contributors via github @BassemN. + +### 2.4.3 ### +* Hotfix - WordPress 4.0 compatible. +* Hotfix - Fixed an issue where all media was being attached to the default OptionTree media post. +* Hotfix - Removed the deprecated `screen_icon()` function. +* Hotfix - Fixed the `ot_line_height_range_interval` filter being misnamed as `ot_line_height_unit_type`. Contributors via github @youri--. +* Hotfix - Fixed a conflict with "Frontend Publishing Pro" when using the media uploader on the front-end. +* Hotfix - Increase condition performance. Contributors via github @designst. +* Hotfix - Add custom style classes to list-item settings. Contributors via github @designst. +* Hotfix - Check for `post_title` instead of `post_name` in `ot_get_media_post_ID()`. Contributors via github @clifgriffin. +* Hotfix - Store the return value of `ot_get_media_post_ID()` in the options table as `ot_media_post_ID`. +* Hotfix - Added padding to List Items options to reflect the same UI as individual options. Contributors via github @valendesigns and @designst. +* Hotfix - Fixed a bug that caused the Social Links option type to not properly import. + +### 2.4.2 ### +* Hotfix - Fixed a PHP notice that was created when `background-size` in the Background option type is undefined. +* Hotfix - Fixed an issue with the Upload option type, in attachment ID mode, not storing its value. +* Hotfix - Replaced `load_template` with `require` throught the documentation. +* Hotfix - Added a settings ID auto-fill that is based on the text of the settings label in the Theme Options UI Builder. Contributors via github @valendesigns and @Ore4444. +* Hotfix - Added filter `ot_override_forced_textarea_simple` to allow the Textarea option type to be moved in the DOM and not replaced with the Textarea Simple option type in meta boxes and list items. + +### 2.4.1 ### +* Hotfix - Fixed a typo in the demo Theme Options related to the `social-links`. +* Hotfix - Fixed the language directory path conflict between IIS and Linux while in Theme Mode. +* Hotfix - Fixed a style issue where select fields would overflow their parent elements. +* Hotfix - Fixed a PHP notice that was created when the Measurement option type did not have a saved value. + +### 2.4.0 ### +* Added filter 'ot_post_formats' which loads meta boxes specifically for post formats. +* Added the Social Links option type. +* Fixed OptionTree being conflicted due to having both the plugin and theme version activated. Contributors via github @valendesigns and @bitcommit. +* Added an admin notice when the UI Builder is being overridden by custom theme options. +* Allow the Upload option type to be stored as an attachment ID by adding `ot-upload-attachment-id` to the elements `class` attribute. Contributors via github @valendesigns and @krisarsov. +* Fixed an issue with the CSS option type not showing the Ace editor in a metabox that is broken into tabbed content. +* Fixed missing option type translation strings. Contributors via github @RistoNiinemets. +* Replaced mysql functions with the wpdb equivalent. Contributors via github @joshlevinson. +* Fixed search order of the `contains` condition string. Contributors via github @designst. +* Added meta box field wrapper class if a custom field class is defined in the settings. Contributors via github @designst. +* Added filter 'ot_type_select_choices' to dynamically change select choices. Contributors via github @maimairel and @valendesigns. +* Fixed a bug that added an unnecessary directory separator to the `load_theme_textdomain()` `$path` variable. Contributors via github @PatrickDelancy and @valendesigns. +* Fixed the state of metabox radio buttons after a Drag & Drop event. Contributors via github @themovation and @valendesigns. +* Fixed conditions not working correctly within list items. +* Fixed the min-height issue when using tabs in metaboxes. +* Added filter `ot_recognized_font_sizes` to dynamically change the font sizes by field ID. +* Added filter `ot_recognized_letter_spacing` to dynamically change the letter spacing by field ID. +* Added filter `ot_recognized_line_heights` to dynamically change the line heights by field ID. +* Fixed a style issue where list item labels in metaboxes were not displaying correctly. +* Fixed an issue where the WooCommerce plugin would alter the style of metabox tabs on product pages. + +### 2.3.4 ### +* Hotfix - Fixed an issue where condition number values were being treated like strings and not returning a correct boolean response. + +### 2.3.3 ### +* Hotfix - Fixed subfolder compatibility with versions of Windows that use backslashes instead of forward slashes. Contributors via github @primozcigler and @valendesigns. +* Hotfix - Fixed missing text domain in demo files. Contributors via github @jetonr. +* Hotfix - Added filter `ot_migrate_settings_id` to migrate themes that used `option_tree_settings` and now use a custom settings ID. +* Hotfix - Added filter `ot_migrate_options_id` to migrate themes that used `option_tree` and now use a custom options ID. +* Hotfix - Added filter `ot_migrate_layouts_id` to migrate themes that used `option_tree_layouts` and now use a custom layouts ID. + +### 2.3.2 ### +* Hotfix - Fixed an issue with the `ot_create_media_post` function creating multiple `option-tree` posts. +* Hotfix - Change the icon used by the layout management option type to differentiate it from the edit button. +* Hotfix - Suppress PHP warning in the Background option type "Invalid argument supplied for foreach()". Contributors via github @tomkwok. +* Hotfix - Added filter `ot_type_date_picker_date_format` to change the date format of the Date Picker option type. +* Hotfix - Added filter `ot_type_date_time_picker_date_format` to change the date format of the Date Time Picker option type. + +### 2.3.1 ### +* Hotfix - Fixed a bug with the Gallery option type that would show attachments in the media window when none had been added yet. +* Hotfix - Added the option to save the Gallery as a shortcode by adding `ot-gallery-shortcode` to the elements `class` attribute. +* Hotfix - Fixed conditions not being effective in List Items directly after clicking "Add New". Contributors via github @bitcommit. + +### 2.3.0 ### +* Added the Tab option type. +* Added Ace Editor to the CSS option type. Contributors via github @imangm and @valendesigns. +* Added support for WordPress 3.8 color schemes. +* Added support for RTL languages. Contributors via github @omid-khd and @valendesigns. +* Added actions before and after the enqueue styles and scripts. +* Added Date Picker option type. Contributors via github @jetonr and @valendesigns. +* Added Date Time Picker option type. Contributors via github @jetonr and @valendesigns. +* Added filter 'ot_list_item_title_label' to change the label for a List Item's required title field. +* Added filter 'ot_list_item_title_desc' to change the description for a List Item's required title field. +* Added filter 'ot_options_id' to change the 'option_tree' option ID to a unique value. +* Added filter 'ot_settings_id' to change the 'option_tree_settings' option ID to a unique value. +* Added filter 'ot_layouts_id' to change the 'option_tree_layouts' option ID to a unique value. +* Added filter 'ot_header_logo_link' to change the logo link inside the header of OptionTree. +* Added filter 'ot_header_version_text' to change the version text inside the header of OptionTree. +* Added action 'ot_header_list' to add additional theme specific list items to the header of OptionTree. +* Added filter 'ot_upload_text' to change the "Send to OptionTree" text. +* Added the CSS Class field value to the parent `.format-settings` div in addition to the class being added to the element. Each class is now appended with `-wrap`. +* Added support for [Composer](https://github.com/composer/composer). Contributors via github @designst. +* Added support for adding I18n text domains to the exported `theme-options.php` file. +* Fixed a bug that kept the UI from displaying when using the `ot_type_background_size_choices` filter. +* Fixed a bug that caused the Gallery option type to save a single space instead of `null`. +* Fixed the return value of the Background, Measurement, and Typography option types. They now return `null` if no values are saved to the array. +* Fixed a bug that resulted in a PHP warning if the choices array was set to an empty string. +* Updated the documentation, including this `readme.txt` and a new demo [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) to parallel OptionTree. +* Added filter 'ot_type_radio_image_src' which allows the Radio Image option type source URI to be changed. Contributors via github @bitcommit. + +### 2.2.3 ### +* Hotfix - Allow empty condition values. For example, `field_id:is()` or `field_id:not()` would now be valid syntax. +* Hotfix - Fixed a bug in the `init_upload_fix` JavaScript method. +* Hotfix - Fixed a bug in the `url_exists` javaScript method. The code will no longer will check if a URL exists on another domain. + +### 2.2.2 ### +* Hotfix - Added support for both upper and lower case conditions operator. +* Hotfix - Updated the color and font size of inline code. +* Hotfix - Fix an issue with IE filter and updated the style of the On/Off option type. +* Hotfix - Added opacity to radio images to improve distinction. Contributors via github @jetonr. + +### 2.2.1 ### +* Hotfix - Fixed a UI bug that caused the layouts input to cover the wp menu. +* Hotfix - Moved the screen shots to the WordPress SVN assets directory. + +### 2.2.0 ### +* Added the Gallery option type. +* Added the On/Off option type. +* Replaced the old Color Picker with the default WP Color Picker. +* Added UI support for WordPress 3.8. Contributors via github @AlxMedia, and @valendesigns. +* Added support for conditional toggling of settings fields. Contributors via github @maimairel, @valendesigns, @doitmax, and @imangm. +* Replaced the OptionTree image icon with a font version. +* Added 'background-size' to the Background option type. +* Added fallback text when displaying posts without titles in various option types. +* Added filter 'ot_recognized_background_fields' to show/hide fields for background option types. +* Added filter 'ot_filter_description' that allows the theme option descriptions to be filtered before being displayed. +* Added subfolder compatibility in theme mode. Contributors via github @doitmax, and @valendesigns. +* Fixed a bug caused by using 'home_url' when loading dynamic CSS files. +* Fixed an issue where you could not save metabox text field values as "0". Contributors via github @sparkdevelopment, and @valendesigns. +* Fixed the broken localization directory path in theme mode. Contributors via github @youri--, and @valendesigns. +* Fixed missing custom class for the Numeric Slider. Contributors via github @doitmax. +* Added filter 'ot_type_category_checkbox_query' which allows you to filter the get_categories() args for Category Checkbox. +* Added filter 'ot_type_category_select_query' which allows you to filter the get_categories() args for Category Select. +* Added filter 'ot_type_taxonomy_checkbox_query' which allows you to filter the get_categories() args for Taxonomy Checkbox. +* Added filter 'ot_type_taxonomy_select_query' which allows you to filter the get_categories() args for Taxonomy Select. +* Added the 'ot_echo_option' function. Contributors via github @joshlevinson. +* Added filter 'ot_theme_options_contextual_help' which allows you to filter the Contextual Help on the Theme Options page. +* Added filter 'ot_theme_options_sections' which allows you to filter the Sections on the Theme Options page. Contributors via github @joshlevinson. +* Added filter 'ot_theme_options_settings' which allows you to filter the Settings on the Theme Options page. Contributors via github @joshlevinson. + +### 2.1.4 ### +* Hotfix - Fixed the Numeric Slider not work inside of a newly added List item. +* Hotfix - Fixed the numeric slider fallback value being set to 0, it now becomes the minimum value if no standard is set. +* Hotfix - Allow single quotes in std and choice value when exporting theme-options.php. Contributors via github @maimairel. +* Hotfix - Additional Themecheck bypass for required functions. Contributors via github @maimairel. +* Hotfix - Fixed post meta information being lost when loading revisions. Contributors via github @live-mesh. +* Hotfix - Removed template queries in option types. Contributors via github @live-mesh. + +### 2.1.3 ### +* Hotfix - Loading OptionTree on the 'init' action proved to be wrong, it now loads on 'after_setup_theme'. +* Hotfix - Layouts were not being imported properly due to using the wrong path variable. + +### 2.1.2 ### +* Hotfix - Fixed a JS mistake that caused upload in list items and sliders to not open the media uploader until saved first. +* Hotfix - Load OptionTree on the 'init' action, which allows the UI filters to properly function when not in theme mode. + +### 2.1.1 ### +* Hotfix - The OT_SHOW_SETTINGS_EXPORT constant was incorrectly set to false as the default. + +### 2.1 ### +* Added support for WordPress 3.6. +* UI got a small but needed update, and is now more inline with WordPress. +* Added WPML support for the Text, Textarea, and Textarea Simple option types, and within list items; even after drag & drop. +* Upload now uses the media uploader introduced in WordPress 3.5. Contributors via github @htvu, @maimairel, and @valendesigns. +* Added a horizontal Numeric Slider option type. Contributors via github @maimairel and @valendesigns. +* Added a Sidebar Select option type. Contributors via github @maimairel. +* Removed additional deprecated assigning of return value in PHP. +* Fix missing "Send to OptionTree" button in CPT. Contributors via github @jomaddim. +* Fix option types that use $count instead of an array key to select the option value. +* Created functions to register the Theme Options & Settings pages, and with better filtering. +* Added relative path support for Radio Image choices. +* Added dynamic replacement of 'OT_URL' & 'OT_THEME_URL' in the Radio Image source path. +* Make '0' possible as a field value. Validate for empty strings instead of empty(). Contributors via github @maimairel. +* The 'ot_theme_options_capability' filter is now working for different capabilities like editor. +* The 'ot_display_by_type' filter is now being assigned to a value. +* Added filter 'ot_show_options_ui' which allows you to hide the Theme Options UI Builder. +* Added filter 'ot_show_settings_import' which allows you to hide the Settings Import options on the Import page. +* Added filter 'ot_show_settings_export' which allows you to hide the Settings Export options on the Export page. +* Added filter 'ot_show_docs' which allows you to hide the Documentation. +* Added filter 'ot_use_theme_options' which allows you to hide the OptionTree Theme Option page (not recommended for beginners). +* Added filter 'ot_list_item_description' which allows you to change the default list item description text. +* Added filter 'ot_type_custom_post_type_checkbox_query' which allows you to filter the get_posts() args for Custom Post Type Checkbox. +* Added filter 'ot_type_custom_post_type_select_query' which allows you to filter the get_posts() args for Custom Post Type Select. +* Added filter 'ot_type_page_checkbox_query' which allows you to filter the get_posts() args for Page Checkbox. +* Added filter 'ot_type_page_select_query' which allows you to filter the get_posts() args for Page Select. +* Added filter 'ot_type_post_checkbox_query' which allows you to filter the get_posts() args for Post Checkbox. +* Added filter 'ot_type_post_select_query' which allows you to filter the get_posts() args for Post Select. + +### 2.0.16 ### +* Fixed an urgent JS regression bug that caused the upload option type to break. Code contributed by @anonumus via github. +* Added 'font-color' to the typography filter. + +### 2.0.15 ### +* Added support for Child Theme mode. +* Improved handling of standard values when settings are written manually. +* Add filter for CSS insertion value. +* Added 'ot_before_theme_options_save' action hook. +* Fix 'indexOf' JS error when upload is closed without uploading. +* Add textarea std value when option type is 'textarea', 'textarea-simple', or 'css'. +* Remove load_template and revert back to include_once. +* Fixed dynamic.css regression from 2.0.13 that caused the file to not save. + +### 2.0.14 ### +* Removed deprecated assigning of return value in PHP. +* Patch to fix PHP notice regression with the use of load_template in a plugin after Theme Check update. +* Fixed missing required arguments in OT_Loader::add_layout. +* Removed esc_attr() on font-family check. +* Added a 'ot_theme_options_parent_slug' filter in ot-ui-theme-options.php +* Fixed WP_Error from the use of wp_get_remote() instead of file_get_contents(). + +### 2.0.13 ### +* Removed almost all of the Theme Check nag messages when in 'ot_theme_mode'. +* Fix an issue where Media Upload stopped working on some servers. + +### 2.0.12 ### +* Added additional filters to the array that builds the Theme Option UI. +* Made option-tree post type private. +* Revert capabilities back to manage_options in ot-ui-admin.php. +* Upload now sends the URL of the selected image size to OptionTree. +* Added new range interval filter to font-size, letter-spacing, & line-height. +* Allow Typography fields to be filtered out of the UI. + +### 2.0.11 ### +* Added filters to the array that builds the Theme Option UI. +* Added .format-setting-wrap div to allow for complex CSS layouts. +* Added better namespacing for the Colorpicker option type. +* Fixed theme-options.php export where it was adding an extra comma. + +### 2.0.10 ### +* Fixed a bug where the Textarea row count wasn't working for List Items. +* Added an apply_filter to the exported theme-options.php file. +* Added CSS id's to tabs and settings. +* Allow "New Layout" section to be hidden on the theme options page via a filter. +* Fixed a bug where the Colorpicker was not closing in List Items. +* Change capabilities from manage_options to edit_theme_options. +* Remove Textblock title in List Items & Metaboxes. +* Fixed a List Item bug that incorrectly added ID's based on counting objects - submitted by Spark +* Fixed incorrect text domain paths for both plugin and theme mode. +* Fixed a bug with UI Sortable not properly calculating the container height. +* Fixed Select dropdown selector bug - submitted by Manfred Haltner +* Fixed Radio Image remove class bug - submitted by designst +* Added new typography fields - submitted by darknailblue +* Added dynamic CSS support for new typography fields. +* Added new filters to typography fields, including low/high range & unit types. + +### 2.0.9 ### +* Fixed the issue where the Textarea Simple and CSS option types were mysteriously being ran through wpautop. +* Added missing class setting to Textarea, Textarea Simple, & CSS option types. +* Fixed theme-options.php exported array where label values were not correct. +* Change GET to POST for all AJAX calls to fix a bug where some servers would not allow long strings to be passed in GET variables. +* Added the 'ot_after_validate_setting' filter to the validation function. +* Added $field_id to the ot_validate_setting() for more precise filtering. +* Added the ot_reverse_wpautop() function that you can run input through just incase you need it. +* Updated the docs to include information on why WYSIWYG editors are not allowed in meta boxes and that they revert to a Textarea Simple. +* Update option-tree.pot file. + +### 2.0.8 ### +* Add auto import for backwards compatibility of old 1.x files. +* Added the ability to export settings into a fully functional theme-options.php. +* Fix typo in docs regarding the filter demo code. +* Removed slashes in the section and contextual help titles. +* Made colorpicker input field alignment more cross browser compatible. + +### 2.0.7 ### +* Fixed the load order to be compatible with 1.x version themes that think the get_option_tree() function doesn't exist yet. +* Tested and compatible with Cudazi themes, but the nag message is still visible. + +### 2.0.6 ### +* Run the 'option_tree' array through validation when importing data and layouts. +* Fix a bug where list items and sliders were not allowing the user to select the input field. +* Add a filter that allows you to not load resources for meta boxes if you're not going to use them. +* Update option-tree.pot file. + +### 2.0.5 ### +* Change the way the 'option_tree_settings' array validates. Strip out those damn slashes! + +### 2.0.4 ### +* Run the 'option_tree' array through validation when upgrading from the 1.0 branch to the 2.0 branch for the first time. +* Fix a typo in the slider array where textarea's were not saving the first time due to an incorrect array key. + +### 2.0.3 ### +* Had an incorrect conditional statement causing an issue where the plugin was attempting to create the 'option-tree' image attachment page, even though it was already created. +* The above also fixed a conflict with 'The Events Calendar' plugin. + +### 2.0.2 ### +* Added I18n support, let the translations begin. The option-tree.pot file is inside the languages directory. +* Trim whitespace on imported choices array. +* Fixed the CSS insert function not having a value to save. + +### 2.0.1 ### +* Import from table was not mapping settings correctly. It is now. + +### 2.0 ### +* Complete rewrite form the ground up. +* Better Theme Options UI Builder. +* New in-plugin documentation. +* Brand new responsive UI. +* Add new option types, most notable the List Item which should eventually replace the Slider. +* Added the simpler ot_get_option() function to eventually replace get_option_tree(). +* Added support for Meta Boxes. +* Added Theme Mode where you can now include the plugin directly in your theme. +* Better validation on saved data. +* Simplified the import process. +* Added support for contextual help. +* Permanently move the Theme Option to the Appearance tab. +* Added a ton of filters. +* Made huge improvements to the code base and tested rigorously. + +### 1.1.8.1 ### +* Removed get_option_tree() in the WordPress admin area due to theme conflicts. +* Removed demo files in the assets folder at the request of WordPress + +### 1.1.8 ### +* Fixed scrolling issue on extra tall pages +* Added ability to show/hide settings & documentation via the User Profile page. +* Added Background option type. +* Added Typography option type. +* Added CSS option type. +* Better looking selects with 1=Yes,2=No where '1' is the value and 'Yes' is the text in the select. +* Made the AJAX message CSS more prominent. +* functions.load.php will now only load option type functions if viewing an OT admin page. +* Deregistered the custom jQuery UI in the 'Cispm Mail Contact' plugin when viewing an OptionTree page. +* Can now save layouts from the Theme Options page. +* You can now change the slider fields by targeting a specific "Option Key" +* Modified upload for situations where you manually enter a relative path +* Allow get_option_tree() function to be used in WP admin +* Changed permissions to edit_theme_options + +### 1.1.7.1 ### +* Revert functions.load.php, will fix and update in next version + +### 1.1.7 ### +* Added layout (theme variation) support with save/delete/activate/import/export capabilities. +* Allow layout change on Theme Options page. +* Full Multisite compatibility by manually adding xml mime type for import options. +* Replaced eregi() with preg_match() for 5.3+ compatibility. +* Changed test data in the assets directory for new layout option. +* Made it so when the slider & upload image changes it's reflected on blur. +* Gave the slider image an upload button. +* Added do_action('option_tree_import_data') to option_tree_import_data() function before exit. +* Added do_action('option_tree_array_save') to option_tree_array_save() function before exit. +* Added do_action('option_tree_save_layout') to option_tree_save_layout() function before exit. +* Added do_action('option_tree_delete_layout') to option_tree_delete_layout() function before exit. +* Added do_action('option_tree_activate_layout') to option_tree_activate_layout() function before exit. +* Added do_action('option_tree_import_layout') to option_tree_import_layout() function before redirect. +* Added do_action('option_tree_admin_header') hook before all admin pages. +* Fixed bug where users could add a color without a hash. +* Only load option type function on Theme Options page +* Loading resources with absolute paths, no longer relative. +* Fixed a bug with uploader creating extra option-tree draft pages. +* Fixed slider toggle bug, now the sliders close when you open another or create new slide. + +### 1.1.6 ### +* Theme Integration added. +* Made the upload XML file openbase_dir compliant. + +### 1.1.5 ### +* Fixed multiple sliders issue + +### 1.1.4 ### +* Patch for get_option_tree() $is_array being false and still returning an array + +### 1.1.3 ### +* Added Slider option type with filter for changing the optional fields +* Fixed the text displayed for Measurement option type after options are reset +* Added filter to measurement units +* Code cleanup in the option_tree_array_save() function +* Fixed double quotes on front-end display + +### 1.1.2 ### +* Fixed double quotes in Textarea option type +* Added Measurement option type for CSS values +* Fixed Post option type only returning 5 items +* Added a scrolling window for checkboxes > 10 + +### 1.1.1 ### +* Fixed the 'remove' icon from showing when nothing's uploaded + +### 1.1 ### +* Fixed the Undefined index: notices when WP_DEBUG is set to true + +### 1.0.0 ### +* Initial version + + +## Upgrade Notice ## + +### 2.3.0 ### +As with each major release, please install OptionTree on a test server before upgrading your live site. + +### 2.1.4 ### +If you're not the developer of this theme, please ask them to test compatibility with version 2.1 before upgrading. If you are the developer, I urge you to do the same in a controlled environment. + +### 2.0.16 ### +There was an issue with the upload option type's JavaScript not allowing anything other than images to be sent to the editor. This urgent issue is now fixed and why this version is light on changes. + +### 2.0.12 ### +The plugin has undertaken a complete rebuild! If you are not the theme developer, I urge you to contact that person before you upgrade and ask them to test the themes compatibility. + +### 1.1.8.1 ### +Removed get_option_tree() in the WordPress admin area due to theme conflicts. + +### 1.1.8 ### +Added Typography, Background, & CSS option types. Lots of way to extend them, as well. + +### 1.1.7 ### +Lots of additions, none critical just fun. Added layouts & upload to slider. As well, started including action hooks for extending and integrating with other plugins. + +### 1.1.6 ### +Added theme integration for developers. It's now possible to have a default XML file included in your theme to populate the theme options and hide the settings and docs pages. Read more about this in the plugins built in documentation. + +### 1.1.5 ### +Having multiple sliders caused a naming collision in the JavaScript and is now fixed. Upgrade ASAP to have multiple sliders available in the UI. + +### 1.1.4 ### +Fixed the returned value of the get_option_tree() function when $is_array is set to false. If you have created any slider or measurement option types please read the updated documentation for examples on how to use them in your theme. + + diff --git a/readme.txt b/readme.txt index d15a017..05d3e61 100755 --- a/readme.txt +++ b/readme.txt @@ -1,636 +1,647 @@ -=== OptionTree === -Contributors: valendesigns -Donate link: http://bit.ly/NuXI3T -Tags: options, theme options, meta boxes -Requires at least: 3.8 -Tested up to: 4.4 -Stable tag: 2.6.0 -License: GPLv3 - -Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. - -== Description == - -OptionTree attempts to bridge the gap between WordPress developers, designers and end-users by creating fully responsive option panels and meta boxes with an ease unlike any other plugin. OptionTree has many advanced features with well placed hooks and filters to adjust every aspect of the user experience. - -Build your Theme Options panel locally with an easy to use drag & drop interface and then export a functioning `theme-options.php` file for production use that is i18n translation ready, with your custom text domain automatically inserted. - -And, in just a few simple lines of code, save settings to the database with a unique array ID so none of your Theme Options conflict with other themes that use OptionTree. - -Also, OptionTree now takes full advantage of the new color schemes introduced in WordPress 3.8, it looks and feels built-in. - -#### Theme Integration -If you're like me, you want to know how everything works. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and see first hand how to integrate OptionTree into your own project. I'll walk you through installing OptionTree and you'll get a chance to see all the various options and filters first hand and in the wild. - -#### Contributing -To contribute or report bugs, please go to the [OptionTree Github](https://github.com/valendesigns/option-tree) repository. - -#### Sponsorship -OptionTree is a project partly sponsored by ThemeForest, the largest WordPress theme marketplace on the web. - -#### Option Types -This is a complete list of all the available option types that come shipped with OptionTree. - -* Background -* Border -* Box Shadow -* Category Checkbox -* Category Select -* Checkbox -* Colorpicker -* Colorpicker Opacity -* CSS -* Custom Post Type Checkbox -* Custom Post Type Select -* Date Picker -* Date Time Picker -* Dimension -* Gallery -* Google Fonts -* JavaScript -* Link Color -* List Item -* Measurement -* Numeric Slider -* On/Off -* Page Checkbox -* Page Select -* Post Checkbox -* Post Select -* Radio -* Radio Image -* Select -* Sidebar Select -* Slider -* Social Links -* Spacing -* Tab -* Tag Checkbox -* Tag Select -* Taxonomy Checkbox -* Taxonomy Select -* Text -* Textarea -* Textarea Simple -* Textblock -* Textblock Titled -* Typography -* Upload - -== Installation == - -**Plugin Mode** - -1. Upload `option-tree` to the `/wp-content/plugins/` directory -1. Activate the plugin through the `Plugins` menu in WordPress -1. Click the `OptionTree->Documentation` link in the WordPress admin sidebar menu for further setup assistance. - -**Theme Mode** - -1. Download the latest version of OptionTree and unarchive the `.zip` directory. -1. Put the `option-tree` directory in the root of your theme. For example, the server path would be `/wp-content/themes/theme-name/option-tree/`. -1. You must deactivate and/or delete the plugin version of OptionTree. -1. Add the following code to the beginning of your `functions.php`. - -`/** - * Required: set 'ot_theme_mode' filter to true. - */ -add_filter( 'ot_theme_mode', '__return_true' ); - -/** - * Required: include OptionTree. - */ -require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );` - -For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode. - -== Frequently Asked Questions == - -= Is there a demo theme I can install? = - -There sure is, and I'm glad you asked. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and get some experience setting up OptionTree on your own with detailed directions and tips. - -= Why are my translation files not loading? = - -It is important to note that when you use OptionTree as a plugin, you must store your language files in the `option-tree/languages` directory and use file names like `option-tree-es_ES.mo` & `option-tree-es_ES.po`. However, when using OptionTree in Theme Mode you must also create a `theme-mode` directory inside the `option-tree/languages` directory and store your files there with names like `es_ES.mo` & `es_ES.po`. This is due to the different naming conventions of the `load_plugin_textdomain()` and `load_theme_textdomain()` functions. - -= I get errors or a blank screen when I activate the plugin. What's the deal? = - -The most likely scenario is your theme already has OptionTree installed in Theme Mode. And since the plugin and theme version can't both be active at the same time without the sky falling on your head, your site has decided to throw in the towel. If that's not your issue, open up a support request and we'll figure it out together. UPDATE: As of OptionTree 2.4.0 the plugin version will not conflict with the Theme Mode version if they are both 2.4.0 or higher. - -== Screenshots == - -1. Theme Options -2. Settings -3. Documentation - -== Changelog == - -= 2.6.0 = -* Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. -* Fix the Google Fonts URL so it passed the W3 Validator. props @BassemN -* Fix `global_admin_css` so it's only enqueued when needed. -* Fix `dynamic.css` so that a child theme doesn't load the styles saved to the parent theme. -* Add filter `ot_recognized_post_format_meta_boxes` to support additional post formats meta boxes. props @BassemN -* Add action `ot_do_settings_fields_before` & `ot_do_settings_fields_after`. props @BassemN, @valendesigns -* Add Text Domain to plugin file to fully support the new translate.wordpress.org Language Packs. -* Fix notice in PHP 7.0.0 props @Zackio - -= 2.5.5 = -* Hotfix - Allow a `0` value to be saved with certain option types. Contributors via github @BassemN. -* Hotfix - Stop media from being attached to the OptionTree post type when uploaded from the media manager or customizer. Contributors via github @earnjam, and @valendesigns. -* Hotfix - Added filter `ot_load_dynamic_css` to explicitly turn the feature off if desired. -* Hotfix - Stopped `dynamic.css` created with other themes from being loaded elsewhere. - -= 2.5.4 = -* Hotfix - Support for WordPress 4.2 term splitting. -* Hotfix - Removed any potential XSS security issues with `add_query_arg` by escaping it. -* Hotfix - Fixed an issue where Visual Composer was indirectly destroying OptionTree meta box values. -* Hotfix - Fixed an issue where the select field value was not visible. Contributors via github @sabbirk15. - -= 2.5.3 = -* Hotfix - Added `inherit` fallback to the `border` option type in dynamic.css. -* Hotfix - Added `none` fallback to the `box-shadow` option type in dynamic.css. -* Hotfix - Added `inherit` fallback to the `colorpicker` option type in dynamic.css. -* Hotfix - Added `inherit` fallback to the `colorpicker-opacity` option type in dynamic.css. -* Hotfix - Added filter `ot_insert_css_with_markers_fallback` to filter the `dynamic.css` fallback value. -* Hotfix - Added filter `ot_type_radio_image_attributes` to filter the image attributes for each radio choice. Contributors via github @BassemN, and @valendesigns. -* Hotfix - Refactored `ot_insert_css_with_markers` to remove confusing & unnecessary PHP statements and fix whitespace. -* Hotfix - Fixed an issue in `ot_insert_css_with_markers` where the `$option_type` variable was not being set properly. -* Hotfix - Fixed an issue where having multiple Google Fonts option types caused the "Add Google Font" button to insert multiple dropdowns. - -= 2.5.2 = -* Hotfix - Added `inherit` fallback to the `link-color` option type in dynamic.css. -* Hotfix - Remove `$.browser.msie` JS error caused by function being deprecated. -* Hotfix - Change `hover` to `mouseenter mouseleave` to stop jQuery migrate error message. -* Hotfix - Don't allow duplicate Google Fonts in the `ot-google-fonts-css` enqueue. -* Hotfix - Fixed an issue with the CSS and JavaScript option types not being initiating inside of tabs. -* Hotfix - Fixed metabox tab styles for mobile. -* Hotfix - Separate the post formats JS so it does not interfere with the default behavior and loads only as needed. -* Hotfix - Adding the `not-sortable` class to the List Item option type will remove the sortable feature for that option. - -= 2.5.1 = -* Hotfix - Overhaul the Colorpicker Opacity option type so it saves rgba values, not arrays. -* Hotfix - Added the ability to set opacity on any colorpicker with the `ot-colorpicker-opacity` class. -* Hotfix - Don't use `esc_url_raw` to filter the Upload option type when it's saving an attachment ID. Contributors via github @RistoNiinemets. -* Hotfix - Show an error message to user if unable to write to the `dynamic.css` file. Contributors via github @johnh10, and @valendesigns. -* Hotfix - Force the `ot_google_fonts` array to be rebuilt when switching between themes. -* Hotfix - Stop theme check from nagging about using `add_menu_page` in `ot-cleanup-api.php`. - -= 2.5.0 = -* Added the Google Fonts option type. Contributors via github @maimairel, and @valendesigns. -* Added the Border option type. Contributors via github @doitmax, and @valendesigns. -* Added the Box Shadow option type. Contributors via github @doitmax, and @valendesigns. -* Added the Colorpicker Opacity option type. Contributors via github @doitmax, and @valendesigns. -* Added the Dimension option type. Contributors via github @doitmax, and @valendesigns. -* Added the JavaScript option type. -* Added the Link Color option type. Contributors via github @doitmax, and @valendesigns. -* Added the Spacing option type. Contributors via github @doitmax, and @valendesigns. -* Fixed an issue where the Colorpicker was not parsing conditions on `change` or `clear`. -* Fixed the Colorpicker styles on mobile devices. -* Show the Colorpicker setting ID inside the error message string when the value is invalid. -* Added an 'on change' trigger to the Numeric Slider's hidden input. Contributors via github @cubell. -* Stop Theme Check from complaining about the `register_post_type()` function being used in Theme Mode. -* Added styles that clean up the appearance of the included Font Awesome icons in section tabs. -* Fixed jQuery UI style conflicts created by the WP Review plugin. -* Changed the sanitization function from `sanitize_text_field` to `esc_url_raw` for the Upload option type. -* Added filter `ot_dequeue_jquery_ui_css_screen_ids` to dequeue `jquery-ui-css` by screen ID. -* Added filter `ot_on_off_switch_on_value` to filter the value of the On button. Contributors via github @BassemN, and @valendesigns. -* Added filter `ot_on_off_switch_on_label` to filter the label of the On button. Contributors via github @BassemN, and @valendesigns. -* Added filter `ot_on_off_switch_off_value` to filter the value of the Off button. Contributors via github @BassemN, and @valendesigns. -* Added filter `ot_on_off_switch_off_label` to filter the label of the Off button. Contributors via github @BassemN, and @valendesigns. -* Added filter `ot_on_off_switch_width` to filter the width of the On/Off switch. -* Added filter `ot_type_date_picker_readonly` to filter the addition of the readonly attribute. -* Added filter `ot_type_date_time_picker_readonly` to filter the addition of the readonly attribute. -* Added filter `ot_admin_menu_priority` to filter the `admin_menu` action hook priority. -* Added Estonian translation. Contributors via github @tjuris, and @RistoNiinemets. -* Fixed an issue where changes to `theme-options.php` required a second page load. -* Fixed the clean up script, it only displays when there's something to clean up. No more menu item! -* Update demo files with the latest option types. -* Changed where `ot_css_file_paths` is saved when `is_multisite` for better `dynamic.css` file support. -* Changed the default `dynamic.css` file path in multisite to be `dynamic-{current-blog-id}.css`. - -= 2.4.6 = -* Hotfix - Added a clean up script to consolidate orphaned media posts and remove the old and unused `wp_option_tree` table. -* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was never able to set the value of the `ot_media_post_ID` option because it was already set to empty. Causing the `ot_create_media_post()` function to create multiple media posts. - -= 2.4.5 = -* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was setting the value of the `ot_media_post_ID` option to `null`. Causing the `ot_create_media_post()` function to create multiple media posts. A clean up script will be added to `2.5.0`. - -= 2.4.4 = -* Hotfix - Fixed undefined index caused by shorthand conditional. -* Hotfix - Fixed jQuery UI style conflicts created by the Easy Digital Downloads plugin. -* Hotfix - Added placeholder to background-image. Contributors via github @BassemN. - -= 2.4.3 = -* Hotfix - WordPress 4.0 compatible. -* Hotfix - Fixed an issue where all media was being attached to the default OptionTree media post. -* Hotfix - Removed the deprecated `screen_icon()` function. -* Hotfix - Fixed the `ot_line_height_range_interval` filter being misnamed as `ot_line_height_unit_type`. Contributors via github @youri--. -* Hotfix - Fixed a conflict with "Frontend Publishing Pro" when using the media uploader on the front-end. -* Hotfix - Increase condition performance. Contributors via github @designst. -* Hotfix - Add custom style classes to list-item settings. Contributors via github @designst. -* Hotfix - Check for `post_title` instead of `post_name` in `ot_get_media_post_ID()`. Contributors via github @clifgriffin. -* Hotfix - Store the return value of `ot_get_media_post_ID()` in the options table as `ot_media_post_ID`. -* Hotfix - Added padding to List Items options to reflect the same UI as individual options. Contributors via github @valendesigns and @designst. -* Hotfix - Fixed a bug that caused the Social Links option type to not properly import. - -= 2.4.2 = -* Hotfix - Fixed a PHP notice that was created when `background-size` in the Background option type is undefined. -* Hotfix - Fixed an issue with the Upload option type, in attachment ID mode, not storing its value. -* Hotfix - Replaced `load_template` with `require` throught the documentation. -* Hotfix - Added a settings ID auto-fill that is based on the text of the settings label in the Theme Options UI Builder. Contributors via github @valendesigns and @Ore4444. -* Hotfix - Added filter `ot_override_forced_textarea_simple` to allow the Textarea option type to be moved in the DOM and not replaced with the Textarea Simple option type in meta boxes and list items. - -= 2.4.1 = -* Hotfix - Fixed a typo in the demo Theme Options related to the `social-links`. -* Hotfix - Fixed the language directory path conflict between IIS and Linux while in Theme Mode. -* Hotfix - Fixed a style issue where select fields would overflow their parent elements. -* Hotfix - Fixed a PHP notice that was created when the Measurement option type did not have a saved value. - -= 2.4.0 = -* Added filter 'ot_post_formats' which loads meta boxes specifically for post formats. -* Added the Social Links option type. -* Fixed OptionTree being conflicted due to having both the plugin and theme version activated. Contributors via github @valendesigns and @bitcommit. -* Added an admin notice when the UI Builder is being overridden by custom theme options. -* Allow the Upload option type to be stored as an attachment ID by adding `ot-upload-attachment-id` to the elements `class` attribute. Contributors via github @valendesigns and @krisarsov. -* Fixed an issue with the CSS option type not showing the Ace editor in a metabox that is broken into tabbed content. -* Fixed missing option type translation strings. Contributors via github @RistoNiinemets. -* Replaced mysql functions with the wpdb equivalent. Contributors via github @joshlevinson. -* Fixed search order of the `contains` condition string. Contributors via github @designst. -* Added meta box field wrapper class if a custom field class is defined in the settings. Contributors via github @designst. -* Added filter 'ot_type_select_choices' to dynamically change select choices. Contributors via github @maimairel and @valendesigns. -* Fixed a bug that added an unnecessary directory separator to the `load_theme_textdomain()` `$path` variable. Contributors via github @PatrickDelancy and @valendesigns. -* Fixed the state of metabox radio buttons after a Drag & Drop event. Contributors via github @themovation and @valendesigns. -* Fixed conditions not working correctly within list items. -* Fixed the min-height issue when using tabs in metaboxes. -* Added filter `ot_recognized_font_sizes` to dynamically change the font sizes by field ID. -* Added filter `ot_recognized_letter_spacing` to dynamically change the letter spacing by field ID. -* Added filter `ot_recognized_line_heights` to dynamically change the line heights by field ID. -* Fixed a style issue where list item labels in metaboxes were not displaying correctly. -* Fixed an issue where the WooCommerce plugin would alter the style of metabox tabs on product pages. - -= 2.3.4 = -* Hotfix - Fixed an issue where condition number values were being treated like strings and not returning a correct boolean response. - -= 2.3.3 = -* Hotfix - Fixed subfolder compatibility with versions of Windows that use backslashes instead of forward slashes. Contributors via github @primozcigler and @valendesigns. -* Hotfix - Fixed missing text domain in demo files. Contributors via github @jetonr. -* Hotfix - Added filter `ot_migrate_settings_id` to migrate themes that used `option_tree_settings` and now use a custom settings ID. -* Hotfix - Added filter `ot_migrate_options_id` to migrate themes that used `option_tree` and now use a custom options ID. -* Hotfix - Added filter `ot_migrate_layouts_id` to migrate themes that used `option_tree_layouts` and now use a custom layouts ID. - -= 2.3.2 = -* Hotfix - Fixed an issue with the `ot_create_media_post` function creating multiple `option-tree` posts. -* Hotfix - Change the icon used by the layout management option type to differentiate it from the edit button. -* Hotfix - Suppress PHP warning in the Background option type "Invalid argument supplied for foreach()". Contributors via github @tomkwok. -* Hotfix - Added filter `ot_type_date_picker_date_format` to change the date format of the Date Picker option type. -* Hotfix - Added filter `ot_type_date_time_picker_date_format` to change the date format of the Date Time Picker option type. - -= 2.3.1 = -* Hotfix - Fixed a bug with the Gallery option type that would show attachments in the media window when none had been added yet. -* Hotfix - Added the option to save the Gallery as a shortcode by adding `ot-gallery-shortcode` to the elements `class` attribute. -* Hotfix - Fixed conditions not being effective in List Items directly after clicking "Add New". Contributors via github @bitcommit. - -= 2.3.0 = -* Added the Tab option type. -* Added Ace Editor to the CSS option type. Contributors via github @imangm and @valendesigns. -* Added support for WordPress 3.8 color schemes. -* Added support for RTL languages. Contributors via github @omid-khd and @valendesigns. -* Added actions before and after the enqueue styles and scripts. -* Added Date Picker option type. Contributors via github @jetonr and @valendesigns. -* Added Date Time Picker option type. Contributors via github @jetonr and @valendesigns. -* Added filter 'ot_list_item_title_label' to change the label for a List Item's required title field. -* Added filter 'ot_list_item_title_desc' to change the description for a List Item's required title field. -* Added filter 'ot_options_id' to change the 'option_tree' option ID to a unique value. -* Added filter 'ot_settings_id' to change the 'option_tree_settings' option ID to a unique value. -* Added filter 'ot_layouts_id' to change the 'option_tree_layouts' option ID to a unique value. -* Added filter 'ot_header_logo_link' to change the logo link inside the header of OptionTree. -* Added filter 'ot_header_version_text' to change the version text inside the header of OptionTree. -* Added action 'ot_header_list' to add additional theme specific list items to the header of OptionTree. -* Added filter 'ot_upload_text' to change the "Send to OptionTree" text. -* Added the CSS Class field value to the parent `.format-settings` div in addition to the class being added to the element. Each class is now appended with `-wrap`. -* Added support for [Composer](https://github.com/composer/composer). Contributors via github @designst. -* Added support for adding I18n text domains to the exported `theme-options.php` file. -* Fixed a bug that kept the UI from displaying when using the `ot_type_background_size_choices` filter. -* Fixed a bug that caused the Gallery option type to save a single space instead of `null`. -* Fixed the return value of the Background, Measurement, and Typography option types. They now return `null` if no values are saved to the array. -* Fixed a bug that resulted in a PHP warning if the choices array was set to an empty string. -* Updated the documentation, including this `readme.txt` and a new demo [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) to parallel OptionTree. -* Added filter 'ot_type_radio_image_src' which allows the Radio Image option type source URI to be changed. Contributors via github @bitcommit. - -= 2.2.3 = -* Hotfix - Allow empty condition values. For example, `field_id:is()` or `field_id:not()` would now be valid syntax. -* Hotfix - Fixed a bug in the `init_upload_fix` JavaScript method. -* Hotfix - Fixed a bug in the `url_exists` javaScript method. The code will no longer will check if a URL exists on another domain. - -= 2.2.2 = -* Hotfix - Added support for both upper and lower case conditions operator. -* Hotfix - Updated the color and font size of inline code. -* Hotfix - Fix an issue with IE filter and updated the style of the On/Off option type. -* Hotfix - Added opacity to radio images to improve distinction. Contributors via github @jetonr. - -= 2.2.1 = -* Hotfix - Fixed a UI bug that caused the layouts input to cover the wp menu. -* Hotfix - Moved the screen shots to the WordPress SVN assets directory. - -= 2.2.0 = -* Added the Gallery option type. -* Added the On/Off option type. -* Replaced the old Color Picker with the default WP Color Picker. -* Added UI support for WordPress 3.8. Contributors via github @AlxMedia, and @valendesigns. -* Added support for conditional toggling of settings fields. Contributors via github @maimairel, @valendesigns, @doitmax, and @imangm. -* Replaced the OptionTree image icon with a font version. -* Added 'background-size' to the Background option type. -* Added fallback text when displaying posts without titles in various option types. -* Added filter 'ot_recognized_background_fields' to show/hide fields for background option types. -* Added filter 'ot_filter_description' that allows the theme option descriptions to be filtered before being displayed. -* Added subfolder compatibility in theme mode. Contributors via github @doitmax, and @valendesigns. -* Fixed a bug caused by using 'home_url' when loading dynamic CSS files. -* Fixed an issue where you could not save metabox text field values as "0". Contributors via github @sparkdevelopment, and @valendesigns. -* Fixed the broken localization directory path in theme mode. Contributors via github @youri--, and @valendesigns. -* Fixed missing custom class for the Numeric Slider. Contributors via github @doitmax. -* Added filter 'ot_type_category_checkbox_query' which allows you to filter the get_categories() args for Category Checkbox. -* Added filter 'ot_type_category_select_query' which allows you to filter the get_categories() args for Category Select. -* Added filter 'ot_type_taxonomy_checkbox_query' which allows you to filter the get_categories() args for Taxonomy Checkbox. -* Added filter 'ot_type_taxonomy_select_query' which allows you to filter the get_categories() args for Taxonomy Select. -* Added the 'ot_echo_option' function. Contributors via github @joshlevinson. -* Added filter 'ot_theme_options_contextual_help' which allows you to filter the Contextual Help on the Theme Options page. -* Added filter 'ot_theme_options_sections' which allows you to filter the Sections on the Theme Options page. Contributors via github @joshlevinson. -* Added filter 'ot_theme_options_settings' which allows you to filter the Settings on the Theme Options page. Contributors via github @joshlevinson. - -= 2.1.4 = -* Hotfix - Fixed the Numeric Slider not work inside of a newly added List item. -* Hotfix - Fixed the numeric slider fallback value being set to 0, it now becomes the minimum value if no standard is set. -* Hotfix - Allow single quotes in std and choice value when exporting theme-options.php. Contributors via github @maimairel. -* Hotfix - Additional Themecheck bypass for required functions. Contributors via github @maimairel. -* Hotfix - Fixed post meta information being lost when loading revisions. Contributors via github @live-mesh. -* Hotfix - Removed template queries in option types. Contributors via github @live-mesh. - -= 2.1.3 = -* Hotfix - Loading OptionTree on the 'init' action proved to be wrong, it now loads on 'after_setup_theme'. -* Hotfix - Layouts were not being imported properly due to using the wrong path variable. - -= 2.1.2 = -* Hotfix - Fixed a JS mistake that caused upload in list items and sliders to not open the media uploader until saved first. -* Hotfix - Load OptionTree on the 'init' action, which allows the UI filters to properly function when not in theme mode. - -= 2.1.1 = -* Hotfix - The OT_SHOW_SETTINGS_EXPORT constant was incorrectly set to false as the default. - -= 2.1 = -* Added support for WordPress 3.6. -* UI got a small but needed update, and is now more inline with WordPress. -* Added WPML support for the Text, Textarea, and Textarea Simple option types, and within list items; even after drag & drop. -* Upload now uses the media uploader introduced in WordPress 3.5. Contributors via github @htvu, @maimairel, and @valendesigns. -* Added a horizontal Numeric Slider option type. Contributors via github @maimairel and @valendesigns. -* Added a Sidebar Select option type. Contributors via github @maimairel. -* Removed additional deprecated assigning of return value in PHP. -* Fix missing "Send to OptionTree" button in CPT. Contributors via github @jomaddim. -* Fix option types that use $count instead of an array key to select the option value. -* Created functions to register the Theme Options & Settings pages, and with better filtering. -* Added relative path support for Radio Image choices. -* Added dynamic replacement of 'OT_URL' & 'OT_THEME_URL' in the Radio Image source path. -* Make '0' possible as a field value. Validate for empty strings instead of empty(). Contributors via github @maimairel. -* The 'ot_theme_options_capability' filter is now working for different capabilities like editor. -* The 'ot_display_by_type' filter is now being assigned to a value. -* Added filter 'ot_show_options_ui' which allows you to hide the Theme Options UI Builder. -* Added filter 'ot_show_settings_import' which allows you to hide the Settings Import options on the Import page. -* Added filter 'ot_show_settings_export' which allows you to hide the Settings Export options on the Export page. -* Added filter 'ot_show_docs' which allows you to hide the Documentation. -* Added filter 'ot_use_theme_options' which allows you to hide the OptionTree Theme Option page (not recommended for beginners). -* Added filter 'ot_list_item_description' which allows you to change the default list item description text. -* Added filter 'ot_type_custom_post_type_checkbox_query' which allows you to filter the get_posts() args for Custom Post Type Checkbox. -* Added filter 'ot_type_custom_post_type_select_query' which allows you to filter the get_posts() args for Custom Post Type Select. -* Added filter 'ot_type_page_checkbox_query' which allows you to filter the get_posts() args for Page Checkbox. -* Added filter 'ot_type_page_select_query' which allows you to filter the get_posts() args for Page Select. -* Added filter 'ot_type_post_checkbox_query' which allows you to filter the get_posts() args for Post Checkbox. -* Added filter 'ot_type_post_select_query' which allows you to filter the get_posts() args for Post Select. - -= 2.0.16 = -* Fixed an urgent JS regression bug that caused the upload option type to break. Code contributed by @anonumus via github. -* Added 'font-color' to the typography filter. - -= 2.0.15 = -* Added support for Child Theme mode. -* Improved handling of standard values when settings are written manually. -* Add filter for CSS insertion value. -* Added 'ot_before_theme_options_save' action hook. -* Fix 'indexOf' JS error when upload is closed without uploading. -* Add textarea std value when option type is 'textarea', 'textarea-simple', or 'css'. -* Remove load_template and revert back to include_once. -* Fixed dynamic.css regression from 2.0.13 that caused the file to not save. - -= 2.0.14 = -* Removed deprecated assigning of return value in PHP. -* Patch to fix PHP notice regression with the use of load_template in a plugin after Theme Check update. -* Fixed missing required arguments in OT_Loader::add_layout. -* Removed esc_attr() on font-family check. -* Added a 'ot_theme_options_parent_slug' filter in ot-ui-theme-options.php -* Fixed WP_Error from the use of wp_get_remote() instead of file_get_contents(). - -= 2.0.13 = -* Removed almost all of the Theme Check nag messages when in 'ot_theme_mode'. -* Fix an issue where Media Upload stopped working on some servers. - -= 2.0.12 = -* Added additional filters to the array that builds the Theme Option UI. -* Made option-tree post type private. -* Revert capabilities back to manage_options in ot-ui-admin.php. -* Upload now sends the URL of the selected image size to OptionTree. -* Added new range interval filter to font-size, letter-spacing, & line-height. -* Allow Typography fields to be filtered out of the UI. - -= 2.0.11 = -* Added filters to the array that builds the Theme Option UI. -* Added .format-setting-wrap div to allow for complex CSS layouts. -* Added better namespacing for the Colorpicker option type. -* Fixed theme-options.php export where it was adding an extra comma. - -= 2.0.10 = -* Fixed a bug where the Textarea row count wasn't working for List Items. -* Added an apply_filter to the exported theme-options.php file. -* Added CSS id's to tabs and settings. -* Allow "New Layout" section to be hidden on the theme options page via a filter. -* Fixed a bug where the Colorpicker was not closing in List Items. -* Change capabilities from manage_options to edit_theme_options. -* Remove Textblock title in List Items & Metaboxes. -* Fixed a List Item bug that incorrectly added ID's based on counting objects - submitted by Spark -* Fixed incorrect text domain paths for both plugin and theme mode. -* Fixed a bug with UI Sortable not properly calculating the container height. -* Fixed Select dropdown selector bug - submitted by Manfred Haltner -* Fixed Radio Image remove class bug - submitted by designst -* Added new typography fields - submitted by darknailblue -* Added dynamic CSS support for new typography fields. -* Added new filters to typography fields, including low/high range & unit types. - -= 2.0.9 = -* Fixed the issue where the Textarea Simple and CSS option types were mysteriously being ran through wpautop. -* Added missing class setting to Textarea, Textarea Simple, & CSS option types. -* Fixed theme-options.php exported array where label values were not correct. -* Change GET to POST for all AJAX calls to fix a bug where some servers would not allow long strings to be passed in GET variables. -* Added the 'ot_after_validate_setting' filter to the validation function. -* Added $field_id to the ot_validate_setting() for more precise filtering. -* Added the ot_reverse_wpautop() function that you can run input through just incase you need it. -* Updated the docs to include information on why WYSIWYG editors are not allowed in meta boxes and that they revert to a Textarea Simple. -* Update option-tree.pot file. - -= 2.0.8 = -* Add auto import for backwards compatibility of old 1.x files. -* Added the ability to export settings into a fully functional theme-options.php. -* Fix typo in docs regarding the filter demo code. -* Removed slashes in the section and contextual help titles. -* Made colorpicker input field alignment more cross browser compatible. - -= 2.0.7 = -* Fixed the load order to be compatible with 1.x version themes that think the get_option_tree() function doesn't exist yet. -* Tested and compatible with Cudazi themes, but the nag message is still visible. - -= 2.0.6 = -* Run the 'option_tree' array through validation when importing data and layouts. -* Fix a bug where list items and sliders were not allowing the user to select the input field. -* Add a filter that allows you to not load resources for meta boxes if you're not going to use them. -* Update option-tree.pot file. - -= 2.0.5 = -* Change the way the 'option_tree_settings' array validates. Strip out those damn slashes! - -= 2.0.4 = -* Run the 'option_tree' array through validation when upgrading from the 1.0 branch to the 2.0 branch for the first time. -* Fix a typo in the slider array where textarea's were not saving the first time due to an incorrect array key. - -= 2.0.3 = -* Had an incorrect conditional statement causing an issue where the plugin was attempting to create the 'option-tree' image attachment page, even though it was already created. -* The above also fixed a conflict with 'The Events Calendar' plugin. - -= 2.0.2 = -* Added I18n support, let the translations begin. The option-tree.pot file is inside the languages directory. -* Trim whitespace on imported choices array. -* Fixed the CSS insert function not having a value to save. - -= 2.0.1 = -* Import from table was not mapping settings correctly. It is now. - -= 2.0 = -* Complete rewrite form the ground up. -* Better Theme Options UI Builder. -* New in-plugin documentation. -* Brand new responsive UI. -* Add new option types, most notable the List Item which should eventually replace the Slider. -* Added the simpler ot_get_option() function to eventually replace get_option_tree(). -* Added support for Meta Boxes. -* Added Theme Mode where you can now include the plugin directly in your theme. -* Better validation on saved data. -* Simplified the import process. -* Added support for contextual help. -* Permanently move the Theme Option to the Appearance tab. -* Added a ton of filters. -* Made huge improvements to the code base and tested rigorously. - -= 1.1.8.1 = -* Removed get_option_tree() in the WordPress admin area due to theme conflicts. -* Removed demo files in the assets folder at the request of WordPress - -= 1.1.8 = -* Fixed scrolling issue on extra tall pages -* Added ability to show/hide settings & documentation via the User Profile page. -* Added Background option type. -* Added Typography option type. -* Added CSS option type. -* Better looking selects with 1=Yes,2=No where '1' is the value and 'Yes' is the text in the select. -* Made the AJAX message CSS more prominent. -* functions.load.php will now only load option type functions if viewing an OT admin page. -* Deregistered the custom jQuery UI in the 'Cispm Mail Contact' plugin when viewing an OptionTree page. -* Can now save layouts from the Theme Options page. -* You can now change the slider fields by targeting a specific "Option Key" -* Modified upload for situations where you manually enter a relative path -* Allow get_option_tree() function to be used in WP admin -* Changed permissions to edit_theme_options - -= 1.1.7.1 = -* Revert functions.load.php, will fix and update in next version - -= 1.1.7 = -* Added layout (theme variation) support with save/delete/activate/import/export capabilities. -* Allow layout change on Theme Options page. -* Full Multisite compatibility by manually adding xml mime type for import options. -* Replaced eregi() with preg_match() for 5.3+ compatibility. -* Changed test data in the assets directory for new layout option. -* Made it so when the slider & upload image changes it's reflected on blur. -* Gave the slider image an upload button. -* Added do_action('option_tree_import_data') to option_tree_import_data() function before exit. -* Added do_action('option_tree_array_save') to option_tree_array_save() function before exit. -* Added do_action('option_tree_save_layout') to option_tree_save_layout() function before exit. -* Added do_action('option_tree_delete_layout') to option_tree_delete_layout() function before exit. -* Added do_action('option_tree_activate_layout') to option_tree_activate_layout() function before exit. -* Added do_action('option_tree_import_layout') to option_tree_import_layout() function before redirect. -* Added do_action('option_tree_admin_header') hook before all admin pages. -* Fixed bug where users could add a color without a hash. -* Only load option type function on Theme Options page -* Loading resources with absolute paths, no longer relative. -* Fixed a bug with uploader creating extra option-tree draft pages. -* Fixed slider toggle bug, now the sliders close when you open another or create new slide. - -= 1.1.6 = -* Theme Integration added. -* Made the upload XML file openbase_dir compliant. - -= 1.1.5 = -* Fixed multiple sliders issue - -= 1.1.4 = -* Patch for get_option_tree() $is_array being false and still returning an array - -= 1.1.3 = -* Added Slider option type with filter for changing the optional fields -* Fixed the text displayed for Measurement option type after options are reset -* Added filter to measurement units -* Code cleanup in the option_tree_array_save() function -* Fixed double quotes on front-end display - -= 1.1.2 = -* Fixed double quotes in Textarea option type -* Added Measurement option type for CSS values -* Fixed Post option type only returning 5 items -* Added a scrolling window for checkboxes > 10 - -= 1.1.1 = -* Fixed the 'remove' icon from showing when nothing's uploaded - -= 1.1 = -* Fixed the Undefined index: notices when WP_DEBUG is set to true - -= 1.0.0 = -* Initial version - -== Upgrade Notice == - -= 2.3.0 = -As with each major release, please install OptionTree on a test server before upgrading your live site. - -= 2.1.4 = -If you're not the developer of this theme, please ask them to test compatibility with version 2.1 before upgrading. If you are the developer, I urge you to do the same in a controlled environment. - -= 2.0.16 = -There was an issue with the upload option type's JavaScript not allowing anything other than images to be sent to the editor. This urgent issue is now fixed and why this version is light on changes. - -= 2.0.12 = -The plugin has undertaken a complete rebuild! If you are not the theme developer, I urge you to contact that person before you upgrade and ask them to test the themes compatibility. - -= 1.1.8.1 = -Removed get_option_tree() in the WordPress admin area due to theme conflicts. - -= 1.1.8 = -Added Typography, Background, & CSS option types. Lots of way to extend them, as well. - -= 1.1.7 = -Lots of additions, none critical just fun. Added layouts & upload to slider. As well, started including action hooks for extending and integrating with other plugins. - -= 1.1.6 = -Added theme integration for developers. It's now possible to have a default XML file included in your theme to populate the theme options and hide the settings and docs pages. Read more about this in the plugins built in documentation. - -= 1.1.5 = -Having multiple sliders caused a naming collision in the JavaScript and is now fixed. Upgrade ASAP to have multiple sliders available in the UI. - -= 1.1.4 = -Fixed the returned value of the get_option_tree() function when $is_array is set to false. If you have created any slider or measurement option types please read the updated documentation for examples on how to use them in your theme. +=== OptionTree === +Contributors: valendesigns +Donate link: https://bit.ly/2TBvksV +Tags: options, theme options, meta boxes +Requires at least: 3.8 +Tested up to: 5.1 +Stable tag: 2.7.0 +License: GPLv3 + +Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. + +== Description == + +OptionTree attempts to bridge the gap between WordPress developers, designers and end-users by creating fully responsive option panels and meta boxes with an ease unlike any other plugin. OptionTree has many advanced features with well placed hooks and filters to adjust every aspect of the user experience. + +Build your Theme Options panel locally with an easy to use drag & drop interface and then export a functioning `theme-options.php` file for production use that is i18n translation ready, with your custom text domain automatically inserted. + +And, in just a few simple lines of code, save settings to the database with a unique array ID so none of your Theme Options conflict with other themes that use OptionTree. + +Also, OptionTree now takes full advantage of the new color schemes introduced in WordPress 3.8, it looks and feels built-in. + +#### Theme Integration +If you're like me, you want to know how everything works. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and see first hand how to integrate OptionTree into your own project. I'll walk you through installing OptionTree and you'll get a chance to see all the various options and filters first hand and in the wild. + +#### Contributing +To contribute or report bugs, please go to the [OptionTree Github](https://github.com/valendesigns/option-tree) repository. + +#### Sponsorship +OptionTree is a project partly sponsored by ThemeForest, the largest WordPress theme marketplace on the web. + +#### Option Types +This is a complete list of all the available option types that come shipped with OptionTree. + +* Background +* Border +* Box Shadow +* Category Checkbox +* Category Select +* Checkbox +* Colorpicker +* Colorpicker Opacity +* CSS +* Custom Post Type Checkbox +* Custom Post Type Select +* Date Picker +* Date Time Picker +* Dimension +* Gallery +* Google Fonts +* JavaScript +* Link Color +* List Item +* Measurement +* Numeric Slider +* On/Off +* Page Checkbox +* Page Select +* Post Checkbox +* Post Select +* Radio +* Radio Image +* Select +* Sidebar Select +* Slider +* Social Links +* Spacing +* Tab +* Tag Checkbox +* Tag Select +* Taxonomy Checkbox +* Taxonomy Select +* Text +* Textarea +* Textarea Simple +* Textblock +* Textblock Titled +* Typography +* Upload + +== Installation == + +**Plugin Mode** + +1. Upload `option-tree` to the `/wp-content/plugins/` directory +1. Activate the plugin through the `Plugins` menu in WordPress +1. Click the `OptionTree->Documentation` link in the WordPress admin sidebar menu for further setup assistance. + +**Theme Mode** + +1. Download the latest version of OptionTree and unarchive the `.zip` directory. +1. Put the `option-tree` directory in the root of your theme. For example, the server path would be `/wp-content/themes/theme-name/option-tree/`. +1. You must deactivate and/or delete the plugin version of OptionTree. +1. Add the following code to the beginning of your `functions.php`. + +`/** + * Required: set 'ot_theme_mode' filter to true. + */ +add_filter( 'ot_theme_mode', '__return_true' ); + +/** + * Required: include OptionTree. + */ +require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );` + +For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode. + +== Frequently Asked Questions == + += Is there a demo theme I can install? = + +There sure is, and I'm glad you asked. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and get some experience setting up OptionTree on your own with detailed directions and tips. + += Why are my translation files not loading? = + +It is important to note that when you use OptionTree as a plugin, you must store your language files in the `option-tree/languages` directory and use file names like `option-tree-es_ES.mo` & `option-tree-es_ES.po`. However, when using OptionTree in Theme Mode you must also create a `theme-mode` directory inside the `option-tree/languages` directory and store your files there with names like `es_ES.mo` & `es_ES.po`. This is due to the different naming conventions of the `load_plugin_textdomain()` and `load_theme_textdomain()` functions. + += I get errors or a blank screen when I activate the plugin. What's the deal? = + +The most likely scenario is your theme already has OptionTree installed in Theme Mode. And since the plugin and theme version can't both be active at the same time without the sky falling on your head, your site has decided to throw in the towel. If that's not your issue, open up a support request and we'll figure it out together. UPDATE: As of OptionTree 2.4.0 the plugin version will not conflict with the Theme Mode version if they are both 2.4.0 or higher. + +== Screenshots == + +1. Theme Options +2. Settings +3. Documentation + +== Changelog == + += 2.7.0 = +* Require PHP 5.3+ +* Fix all PHPCS errors and warnings. +* Fix a vulnerability where Object Injection could take place if someone has a valid nonce. +* Force all settings to be sanitized and escaped before saving and during display. +* Add filter `ot_validate_setting_input_safe` which is used to validate the input value of a custom setting type. All values must be validated! +* Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50 +* Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred +* Fix notice "Only variables should be passed by reference". props @SergeAx +* Add `wordpress-plugin` project type to composer file. props @egifford + += 2.6.0 = +* Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. +* Fix the Google Fonts URL so it passed the W3 Validator. props @BassemN +* Fix `global_admin_css` so it's only enqueued when needed. +* Fix `dynamic.css` so that a child theme doesn't load the styles saved to the parent theme. +* Add filter `ot_recognized_post_format_meta_boxes` to support additional post formats meta boxes. props @BassemN +* Add action `ot_do_settings_fields_before` & `ot_do_settings_fields_after`. props @BassemN, @valendesigns +* Add Text Domain to plugin file to fully support the new translate.wordpress.org Language Packs. +* Fix notice in PHP 7.0.0 props @Zackio + += 2.5.5 = +* Hotfix - Allow a `0` value to be saved with certain option types. Contributors via github @BassemN. +* Hotfix - Stop media from being attached to the OptionTree post type when uploaded from the media manager or customizer. Contributors via github @earnjam, and @valendesigns. +* Hotfix - Added filter `ot_load_dynamic_css` to explicitly turn the feature off if desired. +* Hotfix - Stopped `dynamic.css` created with other themes from being loaded elsewhere. + += 2.5.4 = +* Hotfix - Support for WordPress 4.2 term splitting. +* Hotfix - Removed any potential XSS security issues with `add_query_arg` by escaping it. +* Hotfix - Fixed an issue where Visual Composer was indirectly destroying OptionTree meta box values. +* Hotfix - Fixed an issue where the select field value was not visible. Contributors via github @sabbirk15. + += 2.5.3 = +* Hotfix - Added `inherit` fallback to the `border` option type in dynamic.css. +* Hotfix - Added `none` fallback to the `box-shadow` option type in dynamic.css. +* Hotfix - Added `inherit` fallback to the `colorpicker` option type in dynamic.css. +* Hotfix - Added `inherit` fallback to the `colorpicker-opacity` option type in dynamic.css. +* Hotfix - Added filter `ot_insert_css_with_markers_fallback` to filter the `dynamic.css` fallback value. +* Hotfix - Added filter `ot_type_radio_image_attributes` to filter the image attributes for each radio choice. Contributors via github @BassemN, and @valendesigns. +* Hotfix - Refactored `ot_insert_css_with_markers` to remove confusing & unnecessary PHP statements and fix whitespace. +* Hotfix - Fixed an issue in `ot_insert_css_with_markers` where the `$option_type` variable was not being set properly. +* Hotfix - Fixed an issue where having multiple Google Fonts option types caused the "Add Google Font" button to insert multiple dropdowns. + += 2.5.2 = +* Hotfix - Added `inherit` fallback to the `link-color` option type in dynamic.css. +* Hotfix - Remove `$.browser.msie` JS error caused by function being deprecated. +* Hotfix - Change `hover` to `mouseenter mouseleave` to stop jQuery migrate error message. +* Hotfix - Don't allow duplicate Google Fonts in the `ot-google-fonts-css` enqueue. +* Hotfix - Fixed an issue with the CSS and JavaScript option types not being initiating inside of tabs. +* Hotfix - Fixed metabox tab styles for mobile. +* Hotfix - Separate the post formats JS so it does not interfere with the default behavior and loads only as needed. +* Hotfix - Adding the `not-sortable` class to the List Item option type will remove the sortable feature for that option. + += 2.5.1 = +* Hotfix - Overhaul the Colorpicker Opacity option type so it saves rgba values, not arrays. +* Hotfix - Added the ability to set opacity on any colorpicker with the `ot-colorpicker-opacity` class. +* Hotfix - Don't use `esc_url_raw` to filter the Upload option type when it's saving an attachment ID. Contributors via github @RistoNiinemets. +* Hotfix - Show an error message to user if unable to write to the `dynamic.css` file. Contributors via github @johnh10, and @valendesigns. +* Hotfix - Force the `ot_google_fonts` array to be rebuilt when switching between themes. +* Hotfix - Stop theme check from nagging about using `add_menu_page` in `ot-cleanup-api.php`. + += 2.5.0 = +* Added the Google Fonts option type. Contributors via github @maimairel, and @valendesigns. +* Added the Border option type. Contributors via github @doitmax, and @valendesigns. +* Added the Box Shadow option type. Contributors via github @doitmax, and @valendesigns. +* Added the Colorpicker Opacity option type. Contributors via github @doitmax, and @valendesigns. +* Added the Dimension option type. Contributors via github @doitmax, and @valendesigns. +* Added the JavaScript option type. +* Added the Link Color option type. Contributors via github @doitmax, and @valendesigns. +* Added the Spacing option type. Contributors via github @doitmax, and @valendesigns. +* Fixed an issue where the Colorpicker was not parsing conditions on `change` or `clear`. +* Fixed the Colorpicker styles on mobile devices. +* Show the Colorpicker setting ID inside the error message string when the value is invalid. +* Added an 'on change' trigger to the Numeric Slider's hidden input. Contributors via github @cubell. +* Stop Theme Check from complaining about the `register_post_type()` function being used in Theme Mode. +* Added styles that clean up the appearance of the included Font Awesome icons in section tabs. +* Fixed jQuery UI style conflicts created by the WP Review plugin. +* Changed the sanitization function from `sanitize_text_field` to `esc_url_raw` for the Upload option type. +* Added filter `ot_dequeue_jquery_ui_css_screen_ids` to dequeue `jquery-ui-css` by screen ID. +* Added filter `ot_on_off_switch_on_value` to filter the value of the On button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_on_label` to filter the label of the On button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_off_value` to filter the value of the Off button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_off_label` to filter the label of the Off button. Contributors via github @BassemN, and @valendesigns. +* Added filter `ot_on_off_switch_width` to filter the width of the On/Off switch. +* Added filter `ot_type_date_picker_readonly` to filter the addition of the readonly attribute. +* Added filter `ot_type_date_time_picker_readonly` to filter the addition of the readonly attribute. +* Added filter `ot_admin_menu_priority` to filter the `admin_menu` action hook priority. +* Added Estonian translation. Contributors via github @tjuris, and @RistoNiinemets. +* Fixed an issue where changes to `theme-options.php` required a second page load. +* Fixed the clean up script, it only displays when there's something to clean up. No more menu item! +* Update demo files with the latest option types. +* Changed where `ot_css_file_paths` is saved when `is_multisite` for better `dynamic.css` file support. +* Changed the default `dynamic.css` file path in multisite to be `dynamic-{current-blog-id}.css`. + += 2.4.6 = +* Hotfix - Added a clean up script to consolidate orphaned media posts and remove the old and unused `wp_option_tree` table. +* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was never able to set the value of the `ot_media_post_ID` option because it was already set to empty. Causing the `ot_create_media_post()` function to create multiple media posts. + += 2.4.5 = +* Hotfix - Fixed an issue where `ot_get_media_post_ID()` was setting the value of the `ot_media_post_ID` option to `null`. Causing the `ot_create_media_post()` function to create multiple media posts. A clean up script will be added to `2.5.0`. + += 2.4.4 = +* Hotfix - Fixed undefined index caused by shorthand conditional. +* Hotfix - Fixed jQuery UI style conflicts created by the Easy Digital Downloads plugin. +* Hotfix - Added placeholder to background-image. Contributors via github @BassemN. + += 2.4.3 = +* Hotfix - WordPress 4.0 compatible. +* Hotfix - Fixed an issue where all media was being attached to the default OptionTree media post. +* Hotfix - Removed the deprecated `screen_icon()` function. +* Hotfix - Fixed the `ot_line_height_range_interval` filter being misnamed as `ot_line_height_unit_type`. Contributors via github @youri--. +* Hotfix - Fixed a conflict with "Frontend Publishing Pro" when using the media uploader on the front-end. +* Hotfix - Increase condition performance. Contributors via github @designst. +* Hotfix - Add custom style classes to list-item settings. Contributors via github @designst. +* Hotfix - Check for `post_title` instead of `post_name` in `ot_get_media_post_ID()`. Contributors via github @clifgriffin. +* Hotfix - Store the return value of `ot_get_media_post_ID()` in the options table as `ot_media_post_ID`. +* Hotfix - Added padding to List Items options to reflect the same UI as individual options. Contributors via github @valendesigns and @designst. +* Hotfix - Fixed a bug that caused the Social Links option type to not properly import. + += 2.4.2 = +* Hotfix - Fixed a PHP notice that was created when `background-size` in the Background option type is undefined. +* Hotfix - Fixed an issue with the Upload option type, in attachment ID mode, not storing its value. +* Hotfix - Replaced `load_template` with `require` throught the documentation. +* Hotfix - Added a settings ID auto-fill that is based on the text of the settings label in the Theme Options UI Builder. Contributors via github @valendesigns and @Ore4444. +* Hotfix - Added filter `ot_override_forced_textarea_simple` to allow the Textarea option type to be moved in the DOM and not replaced with the Textarea Simple option type in meta boxes and list items. + += 2.4.1 = +* Hotfix - Fixed a typo in the demo Theme Options related to the `social-links`. +* Hotfix - Fixed the language directory path conflict between IIS and Linux while in Theme Mode. +* Hotfix - Fixed a style issue where select fields would overflow their parent elements. +* Hotfix - Fixed a PHP notice that was created when the Measurement option type did not have a saved value. + += 2.4.0 = +* Added filter 'ot_post_formats' which loads meta boxes specifically for post formats. +* Added the Social Links option type. +* Fixed OptionTree being conflicted due to having both the plugin and theme version activated. Contributors via github @valendesigns and @bitcommit. +* Added an admin notice when the UI Builder is being overridden by custom theme options. +* Allow the Upload option type to be stored as an attachment ID by adding `ot-upload-attachment-id` to the elements `class` attribute. Contributors via github @valendesigns and @krisarsov. +* Fixed an issue with the CSS option type not showing the Ace editor in a metabox that is broken into tabbed content. +* Fixed missing option type translation strings. Contributors via github @RistoNiinemets. +* Replaced mysql functions with the wpdb equivalent. Contributors via github @joshlevinson. +* Fixed search order of the `contains` condition string. Contributors via github @designst. +* Added meta box field wrapper class if a custom field class is defined in the settings. Contributors via github @designst. +* Added filter 'ot_type_select_choices' to dynamically change select choices. Contributors via github @maimairel and @valendesigns. +* Fixed a bug that added an unnecessary directory separator to the `load_theme_textdomain()` `$path` variable. Contributors via github @PatrickDelancy and @valendesigns. +* Fixed the state of metabox radio buttons after a Drag & Drop event. Contributors via github @themovation and @valendesigns. +* Fixed conditions not working correctly within list items. +* Fixed the min-height issue when using tabs in metaboxes. +* Added filter `ot_recognized_font_sizes` to dynamically change the font sizes by field ID. +* Added filter `ot_recognized_letter_spacing` to dynamically change the letter spacing by field ID. +* Added filter `ot_recognized_line_heights` to dynamically change the line heights by field ID. +* Fixed a style issue where list item labels in metaboxes were not displaying correctly. +* Fixed an issue where the WooCommerce plugin would alter the style of metabox tabs on product pages. + += 2.3.4 = +* Hotfix - Fixed an issue where condition number values were being treated like strings and not returning a correct boolean response. + += 2.3.3 = +* Hotfix - Fixed subfolder compatibility with versions of Windows that use backslashes instead of forward slashes. Contributors via github @primozcigler and @valendesigns. +* Hotfix - Fixed missing text domain in demo files. Contributors via github @jetonr. +* Hotfix - Added filter `ot_migrate_settings_id` to migrate themes that used `option_tree_settings` and now use a custom settings ID. +* Hotfix - Added filter `ot_migrate_options_id` to migrate themes that used `option_tree` and now use a custom options ID. +* Hotfix - Added filter `ot_migrate_layouts_id` to migrate themes that used `option_tree_layouts` and now use a custom layouts ID. + += 2.3.2 = +* Hotfix - Fixed an issue with the `ot_create_media_post` function creating multiple `option-tree` posts. +* Hotfix - Change the icon used by the layout management option type to differentiate it from the edit button. +* Hotfix - Suppress PHP warning in the Background option type "Invalid argument supplied for foreach()". Contributors via github @tomkwok. +* Hotfix - Added filter `ot_type_date_picker_date_format` to change the date format of the Date Picker option type. +* Hotfix - Added filter `ot_type_date_time_picker_date_format` to change the date format of the Date Time Picker option type. + += 2.3.1 = +* Hotfix - Fixed a bug with the Gallery option type that would show attachments in the media window when none had been added yet. +* Hotfix - Added the option to save the Gallery as a shortcode by adding `ot-gallery-shortcode` to the elements `class` attribute. +* Hotfix - Fixed conditions not being effective in List Items directly after clicking "Add New". Contributors via github @bitcommit. + += 2.3.0 = +* Added the Tab option type. +* Added Ace Editor to the CSS option type. Contributors via github @imangm and @valendesigns. +* Added support for WordPress 3.8 color schemes. +* Added support for RTL languages. Contributors via github @omid-khd and @valendesigns. +* Added actions before and after the enqueue styles and scripts. +* Added Date Picker option type. Contributors via github @jetonr and @valendesigns. +* Added Date Time Picker option type. Contributors via github @jetonr and @valendesigns. +* Added filter 'ot_list_item_title_label' to change the label for a List Item's required title field. +* Added filter 'ot_list_item_title_desc' to change the description for a List Item's required title field. +* Added filter 'ot_options_id' to change the 'option_tree' option ID to a unique value. +* Added filter 'ot_settings_id' to change the 'option_tree_settings' option ID to a unique value. +* Added filter 'ot_layouts_id' to change the 'option_tree_layouts' option ID to a unique value. +* Added filter 'ot_header_logo_link' to change the logo link inside the header of OptionTree. +* Added filter 'ot_header_version_text' to change the version text inside the header of OptionTree. +* Added action 'ot_header_list' to add additional theme specific list items to the header of OptionTree. +* Added filter 'ot_upload_text' to change the "Send to OptionTree" text. +* Added the CSS Class field value to the parent `.format-settings` div in addition to the class being added to the element. Each class is now appended with `-wrap`. +* Added support for [Composer](https://github.com/composer/composer). Contributors via github @designst. +* Added support for adding I18n text domains to the exported `theme-options.php` file. +* Fixed a bug that kept the UI from displaying when using the `ot_type_background_size_choices` filter. +* Fixed a bug that caused the Gallery option type to save a single space instead of `null`. +* Fixed the return value of the Background, Measurement, and Typography option types. They now return `null` if no values are saved to the array. +* Fixed a bug that resulted in a PHP warning if the choices array was set to an empty string. +* Updated the documentation, including this `readme.txt` and a new demo [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) to parallel OptionTree. +* Added filter 'ot_type_radio_image_src' which allows the Radio Image option type source URI to be changed. Contributors via github @bitcommit. + += 2.2.3 = +* Hotfix - Allow empty condition values. For example, `field_id:is()` or `field_id:not()` would now be valid syntax. +* Hotfix - Fixed a bug in the `init_upload_fix` JavaScript method. +* Hotfix - Fixed a bug in the `url_exists` javaScript method. The code will no longer will check if a URL exists on another domain. + += 2.2.2 = +* Hotfix - Added support for both upper and lower case conditions operator. +* Hotfix - Updated the color and font size of inline code. +* Hotfix - Fix an issue with IE filter and updated the style of the On/Off option type. +* Hotfix - Added opacity to radio images to improve distinction. Contributors via github @jetonr. + += 2.2.1 = +* Hotfix - Fixed a UI bug that caused the layouts input to cover the wp menu. +* Hotfix - Moved the screen shots to the WordPress SVN assets directory. + += 2.2.0 = +* Added the Gallery option type. +* Added the On/Off option type. +* Replaced the old Color Picker with the default WP Color Picker. +* Added UI support for WordPress 3.8. Contributors via github @AlxMedia, and @valendesigns. +* Added support for conditional toggling of settings fields. Contributors via github @maimairel, @valendesigns, @doitmax, and @imangm. +* Replaced the OptionTree image icon with a font version. +* Added 'background-size' to the Background option type. +* Added fallback text when displaying posts without titles in various option types. +* Added filter 'ot_recognized_background_fields' to show/hide fields for background option types. +* Added filter 'ot_filter_description' that allows the theme option descriptions to be filtered before being displayed. +* Added subfolder compatibility in theme mode. Contributors via github @doitmax, and @valendesigns. +* Fixed a bug caused by using 'home_url' when loading dynamic CSS files. +* Fixed an issue where you could not save metabox text field values as "0". Contributors via github @sparkdevelopment, and @valendesigns. +* Fixed the broken localization directory path in theme mode. Contributors via github @youri--, and @valendesigns. +* Fixed missing custom class for the Numeric Slider. Contributors via github @doitmax. +* Added filter 'ot_type_category_checkbox_query' which allows you to filter the get_categories() args for Category Checkbox. +* Added filter 'ot_type_category_select_query' which allows you to filter the get_categories() args for Category Select. +* Added filter 'ot_type_taxonomy_checkbox_query' which allows you to filter the get_categories() args for Taxonomy Checkbox. +* Added filter 'ot_type_taxonomy_select_query' which allows you to filter the get_categories() args for Taxonomy Select. +* Added the 'ot_echo_option' function. Contributors via github @joshlevinson. +* Added filter 'ot_theme_options_contextual_help' which allows you to filter the Contextual Help on the Theme Options page. +* Added filter 'ot_theme_options_sections' which allows you to filter the Sections on the Theme Options page. Contributors via github @joshlevinson. +* Added filter 'ot_theme_options_settings' which allows you to filter the Settings on the Theme Options page. Contributors via github @joshlevinson. + += 2.1.4 = +* Hotfix - Fixed the Numeric Slider not work inside of a newly added List item. +* Hotfix - Fixed the numeric slider fallback value being set to 0, it now becomes the minimum value if no standard is set. +* Hotfix - Allow single quotes in std and choice value when exporting theme-options.php. Contributors via github @maimairel. +* Hotfix - Additional Themecheck bypass for required functions. Contributors via github @maimairel. +* Hotfix - Fixed post meta information being lost when loading revisions. Contributors via github @live-mesh. +* Hotfix - Removed template queries in option types. Contributors via github @live-mesh. + += 2.1.3 = +* Hotfix - Loading OptionTree on the 'init' action proved to be wrong, it now loads on 'after_setup_theme'. +* Hotfix - Layouts were not being imported properly due to using the wrong path variable. + += 2.1.2 = +* Hotfix - Fixed a JS mistake that caused upload in list items and sliders to not open the media uploader until saved first. +* Hotfix - Load OptionTree on the 'init' action, which allows the UI filters to properly function when not in theme mode. + += 2.1.1 = +* Hotfix - The OT_SHOW_SETTINGS_EXPORT constant was incorrectly set to false as the default. + += 2.1 = +* Added support for WordPress 3.6. +* UI got a small but needed update, and is now more inline with WordPress. +* Added WPML support for the Text, Textarea, and Textarea Simple option types, and within list items; even after drag & drop. +* Upload now uses the media uploader introduced in WordPress 3.5. Contributors via github @htvu, @maimairel, and @valendesigns. +* Added a horizontal Numeric Slider option type. Contributors via github @maimairel and @valendesigns. +* Added a Sidebar Select option type. Contributors via github @maimairel. +* Removed additional deprecated assigning of return value in PHP. +* Fix missing "Send to OptionTree" button in CPT. Contributors via github @jomaddim. +* Fix option types that use $count instead of an array key to select the option value. +* Created functions to register the Theme Options & Settings pages, and with better filtering. +* Added relative path support for Radio Image choices. +* Added dynamic replacement of 'OT_URL' & 'OT_THEME_URL' in the Radio Image source path. +* Make '0' possible as a field value. Validate for empty strings instead of empty(). Contributors via github @maimairel. +* The 'ot_theme_options_capability' filter is now working for different capabilities like editor. +* The 'ot_display_by_type' filter is now being assigned to a value. +* Added filter 'ot_show_options_ui' which allows you to hide the Theme Options UI Builder. +* Added filter 'ot_show_settings_import' which allows you to hide the Settings Import options on the Import page. +* Added filter 'ot_show_settings_export' which allows you to hide the Settings Export options on the Export page. +* Added filter 'ot_show_docs' which allows you to hide the Documentation. +* Added filter 'ot_use_theme_options' which allows you to hide the OptionTree Theme Option page (not recommended for beginners). +* Added filter 'ot_list_item_description' which allows you to change the default list item description text. +* Added filter 'ot_type_custom_post_type_checkbox_query' which allows you to filter the get_posts() args for Custom Post Type Checkbox. +* Added filter 'ot_type_custom_post_type_select_query' which allows you to filter the get_posts() args for Custom Post Type Select. +* Added filter 'ot_type_page_checkbox_query' which allows you to filter the get_posts() args for Page Checkbox. +* Added filter 'ot_type_page_select_query' which allows you to filter the get_posts() args for Page Select. +* Added filter 'ot_type_post_checkbox_query' which allows you to filter the get_posts() args for Post Checkbox. +* Added filter 'ot_type_post_select_query' which allows you to filter the get_posts() args for Post Select. + += 2.0.16 = +* Fixed an urgent JS regression bug that caused the upload option type to break. Code contributed by @anonumus via github. +* Added 'font-color' to the typography filter. + += 2.0.15 = +* Added support for Child Theme mode. +* Improved handling of standard values when settings are written manually. +* Add filter for CSS insertion value. +* Added 'ot_before_theme_options_save' action hook. +* Fix 'indexOf' JS error when upload is closed without uploading. +* Add textarea std value when option type is 'textarea', 'textarea-simple', or 'css'. +* Remove load_template and revert back to include_once. +* Fixed dynamic.css regression from 2.0.13 that caused the file to not save. + += 2.0.14 = +* Removed deprecated assigning of return value in PHP. +* Patch to fix PHP notice regression with the use of load_template in a plugin after Theme Check update. +* Fixed missing required arguments in OT_Loader::add_layout. +* Removed esc_attr() on font-family check. +* Added a 'ot_theme_options_parent_slug' filter in ot-ui-theme-options.php +* Fixed WP_Error from the use of wp_get_remote() instead of file_get_contents(). + += 2.0.13 = +* Removed almost all of the Theme Check nag messages when in 'ot_theme_mode'. +* Fix an issue where Media Upload stopped working on some servers. + += 2.0.12 = +* Added additional filters to the array that builds the Theme Option UI. +* Made option-tree post type private. +* Revert capabilities back to manage_options in ot-ui-admin.php. +* Upload now sends the URL of the selected image size to OptionTree. +* Added new range interval filter to font-size, letter-spacing, & line-height. +* Allow Typography fields to be filtered out of the UI. + += 2.0.11 = +* Added filters to the array that builds the Theme Option UI. +* Added .format-setting-wrap div to allow for complex CSS layouts. +* Added better namespacing for the Colorpicker option type. +* Fixed theme-options.php export where it was adding an extra comma. + += 2.0.10 = +* Fixed a bug where the Textarea row count wasn't working for List Items. +* Added an apply_filter to the exported theme-options.php file. +* Added CSS id's to tabs and settings. +* Allow "New Layout" section to be hidden on the theme options page via a filter. +* Fixed a bug where the Colorpicker was not closing in List Items. +* Change capabilities from manage_options to edit_theme_options. +* Remove Textblock title in List Items & Metaboxes. +* Fixed a List Item bug that incorrectly added ID's based on counting objects - submitted by Spark +* Fixed incorrect text domain paths for both plugin and theme mode. +* Fixed a bug with UI Sortable not properly calculating the container height. +* Fixed Select dropdown selector bug - submitted by Manfred Haltner +* Fixed Radio Image remove class bug - submitted by designst +* Added new typography fields - submitted by darknailblue +* Added dynamic CSS support for new typography fields. +* Added new filters to typography fields, including low/high range & unit types. + += 2.0.9 = +* Fixed the issue where the Textarea Simple and CSS option types were mysteriously being ran through wpautop. +* Added missing class setting to Textarea, Textarea Simple, & CSS option types. +* Fixed theme-options.php exported array where label values were not correct. +* Change GET to POST for all AJAX calls to fix a bug where some servers would not allow long strings to be passed in GET variables. +* Added the 'ot_after_validate_setting' filter to the validation function. +* Added $field_id to the ot_validate_setting() for more precise filtering. +* Added the ot_reverse_wpautop() function that you can run input through just incase you need it. +* Updated the docs to include information on why WYSIWYG editors are not allowed in meta boxes and that they revert to a Textarea Simple. +* Update option-tree.pot file. + += 2.0.8 = +* Add auto import for backwards compatibility of old 1.x files. +* Added the ability to export settings into a fully functional theme-options.php. +* Fix typo in docs regarding the filter demo code. +* Removed slashes in the section and contextual help titles. +* Made colorpicker input field alignment more cross browser compatible. + += 2.0.7 = +* Fixed the load order to be compatible with 1.x version themes that think the get_option_tree() function doesn't exist yet. +* Tested and compatible with Cudazi themes, but the nag message is still visible. + += 2.0.6 = +* Run the 'option_tree' array through validation when importing data and layouts. +* Fix a bug where list items and sliders were not allowing the user to select the input field. +* Add a filter that allows you to not load resources for meta boxes if you're not going to use them. +* Update option-tree.pot file. + += 2.0.5 = +* Change the way the 'option_tree_settings' array validates. Strip out those damn slashes! + += 2.0.4 = +* Run the 'option_tree' array through validation when upgrading from the 1.0 branch to the 2.0 branch for the first time. +* Fix a typo in the slider array where textarea's were not saving the first time due to an incorrect array key. + += 2.0.3 = +* Had an incorrect conditional statement causing an issue where the plugin was attempting to create the 'option-tree' image attachment page, even though it was already created. +* The above also fixed a conflict with 'The Events Calendar' plugin. + += 2.0.2 = +* Added I18n support, let the translations begin. The option-tree.pot file is inside the languages directory. +* Trim whitespace on imported choices array. +* Fixed the CSS insert function not having a value to save. + += 2.0.1 = +* Import from table was not mapping settings correctly. It is now. + += 2.0 = +* Complete rewrite form the ground up. +* Better Theme Options UI Builder. +* New in-plugin documentation. +* Brand new responsive UI. +* Add new option types, most notable the List Item which should eventually replace the Slider. +* Added the simpler ot_get_option() function to eventually replace get_option_tree(). +* Added support for Meta Boxes. +* Added Theme Mode where you can now include the plugin directly in your theme. +* Better validation on saved data. +* Simplified the import process. +* Added support for contextual help. +* Permanently move the Theme Option to the Appearance tab. +* Added a ton of filters. +* Made huge improvements to the code base and tested rigorously. + += 1.1.8.1 = +* Removed get_option_tree() in the WordPress admin area due to theme conflicts. +* Removed demo files in the assets folder at the request of WordPress + += 1.1.8 = +* Fixed scrolling issue on extra tall pages +* Added ability to show/hide settings & documentation via the User Profile page. +* Added Background option type. +* Added Typography option type. +* Added CSS option type. +* Better looking selects with 1=Yes,2=No where '1' is the value and 'Yes' is the text in the select. +* Made the AJAX message CSS more prominent. +* functions.load.php will now only load option type functions if viewing an OT admin page. +* Deregistered the custom jQuery UI in the 'Cispm Mail Contact' plugin when viewing an OptionTree page. +* Can now save layouts from the Theme Options page. +* You can now change the slider fields by targeting a specific "Option Key" +* Modified upload for situations where you manually enter a relative path +* Allow get_option_tree() function to be used in WP admin +* Changed permissions to edit_theme_options + += 1.1.7.1 = +* Revert functions.load.php, will fix and update in next version + += 1.1.7 = +* Added layout (theme variation) support with save/delete/activate/import/export capabilities. +* Allow layout change on Theme Options page. +* Full Multisite compatibility by manually adding xml mime type for import options. +* Replaced eregi() with preg_match() for 5.3+ compatibility. +* Changed test data in the assets directory for new layout option. +* Made it so when the slider & upload image changes it's reflected on blur. +* Gave the slider image an upload button. +* Added do_action('option_tree_import_data') to option_tree_import_data() function before exit. +* Added do_action('option_tree_array_save') to option_tree_array_save() function before exit. +* Added do_action('option_tree_save_layout') to option_tree_save_layout() function before exit. +* Added do_action('option_tree_delete_layout') to option_tree_delete_layout() function before exit. +* Added do_action('option_tree_activate_layout') to option_tree_activate_layout() function before exit. +* Added do_action('option_tree_import_layout') to option_tree_import_layout() function before redirect. +* Added do_action('option_tree_admin_header') hook before all admin pages. +* Fixed bug where users could add a color without a hash. +* Only load option type function on Theme Options page +* Loading resources with absolute paths, no longer relative. +* Fixed a bug with uploader creating extra option-tree draft pages. +* Fixed slider toggle bug, now the sliders close when you open another or create new slide. + += 1.1.6 = +* Theme Integration added. +* Made the upload XML file openbase_dir compliant. + += 1.1.5 = +* Fixed multiple sliders issue + += 1.1.4 = +* Patch for get_option_tree() $is_array being false and still returning an array + += 1.1.3 = +* Added Slider option type with filter for changing the optional fields +* Fixed the text displayed for Measurement option type after options are reset +* Added filter to measurement units +* Code cleanup in the option_tree_array_save() function +* Fixed double quotes on front-end display + += 1.1.2 = +* Fixed double quotes in Textarea option type +* Added Measurement option type for CSS values +* Fixed Post option type only returning 5 items +* Added a scrolling window for checkboxes > 10 + += 1.1.1 = +* Fixed the 'remove' icon from showing when nothing's uploaded + += 1.1 = +* Fixed the Undefined index: notices when WP_DEBUG is set to true + += 1.0.0 = +* Initial version + +== Upgrade Notice == + += 2.3.0 = +As with each major release, please install OptionTree on a test server before upgrading your live site. + += 2.1.4 = +If you're not the developer of this theme, please ask them to test compatibility with version 2.1 before upgrading. If you are the developer, I urge you to do the same in a controlled environment. + += 2.0.16 = +There was an issue with the upload option type's JavaScript not allowing anything other than images to be sent to the editor. This urgent issue is now fixed and why this version is light on changes. + += 2.0.12 = +The plugin has undertaken a complete rebuild! If you are not the theme developer, I urge you to contact that person before you upgrade and ask them to test the themes compatibility. + += 1.1.8.1 = +Removed get_option_tree() in the WordPress admin area due to theme conflicts. + += 1.1.8 = +Added Typography, Background, & CSS option types. Lots of way to extend them, as well. + += 1.1.7 = +Lots of additions, none critical just fun. Added layouts & upload to slider. As well, started including action hooks for extending and integrating with other plugins. + += 1.1.6 = +Added theme integration for developers. It's now possible to have a default XML file included in your theme to populate the theme options and hide the settings and docs pages. Read more about this in the plugins built in documentation. + += 1.1.5 = +Having multiple sliders caused a naming collision in the JavaScript and is now fixed. Upgrade ASAP to have multiple sliders available in the UI. + += 1.1.4 = +Fixed the returned value of the get_option_tree() function when $is_array is set to false. If you have created any slider or measurement option types please read the updated documentation for examples on how to use them in your theme. From 93c57b7fe2961ac31a473c5ae134d35e7d5ddfd3 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 22:06:57 -0700 Subject: [PATCH 40/67] Fix tools --- .coveralls.yml | 3 --- .dev-lib | 1 + .travis.yml | 1 - readme.md | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) delete mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 3b85ca4..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -service_name: travis-ci -coverage_clover: build/logs/clover.xml -json_path: build/logs/coveralls-upload.json diff --git a/.dev-lib b/.dev-lib index b2e0c15..fbe32b5 100644 --- a/.dev-lib +++ b/.dev-lib @@ -1,3 +1,4 @@ DEFAULT_BASE_BRANCH=develop PHPCS_IGNORE='vendor/*,tests/wp-tests/*' CHECK_SCOPE=patches +DEV_LIB_SKIP=phpunit diff --git a/.travis.yml b/.travis.yml index 8c5d8e2..121e3b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ cache: - $HOME/phpunit-bin php: - - 5.3 - 5.6 - 7.3 diff --git a/readme.md b/readme.md index c2ea67d..26bc1ef 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Opti **License:** GPLv3 **Donate link:** https://bit.ly/2TBvksV -[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) [![Coverage Status](https://coveralls.io/repos/valendesigns/option-tree/badge.svg?branch=develop)](https://coveralls.io/github/valendesigns/option-tree) +[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) ## Description ## From f34adccb3be7b3e43d2177ce25f2903b5105435b Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 22:58:41 -0700 Subject: [PATCH 41/67] Fix license --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 663dd8e..1532284 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Theme Options UI Builder for WordPress.", "type": "wordpress-plugin", "homepage": "https://github.com/valendesigns/option-tree", - "license": "GPLv3", + "license": "GPL-2.0-or-later", "authors": [ { "name": "Derek Herman", From dc6307efadcd741bee4ed287bd4dc561fbf8b4e0 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 23:04:40 -0700 Subject: [PATCH 42/67] Add license & change to GPLv2 or later --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++ ot-loader.php | 2 +- readme.md | 2 +- readme.txt | 2 +- 4 files changed, 342 insertions(+), 3 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ot-loader.php b/ot-loader.php index 63573c4..5ec2c29 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -6,7 +6,7 @@ * Version: 2.7.0 * Author: Derek Herman * Author URI: http://valendesigns.com - * License: GPLv3 + * License: GPLv2 or later * Text Domain: option-tree * * @package OptionTree diff --git a/readme.md b/readme.md index 26bc1ef..5f4d45e 100644 --- a/readme.md +++ b/readme.md @@ -8,7 +8,7 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Opti **Requires at least:** 3.8 **Tested up to:** 5.1 **Stable tag:** 2.7.0 -**License:** GPLv3 +**License:** GPLv2 or later **Donate link:** https://bit.ly/2TBvksV [![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) diff --git a/readme.txt b/readme.txt index 05d3e61..6db8ecb 100755 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Tags: options, theme options, meta boxes Requires at least: 3.8 Tested up to: 5.1 Stable tag: 2.7.0 -License: GPLv3 +License: GPLv2 or later Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. From 99ab7c2d60bc8e8e331c22335d7f6effb22d5139 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 23:08:09 -0700 Subject: [PATCH 43/67] Update plugin info --- readme.md | 5 +++-- readme.txt | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 5f4d45e..93ed012 100644 --- a/readme.md +++ b/readme.md @@ -4,12 +4,13 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. **Contributors:** [valendesigns](https://profiles.wordpress.org/valendesigns) -**Tags:** [options](https://wordpress.org/plugins/tags/options), [theme options](https://wordpress.org/plugins/tags/theme-options), [meta boxes](https://wordpress.org/plugins/tags/meta-boxes) +**Tags:** [options](https://wordpress.org/plugins/tags/options), [theme options](https://wordpress.org/plugins/tags/theme-options), [meta boxes](https://wordpress.org/plugins/tags/meta-boxes), [settings](https://wordpress.org/plugins/tags/settings) **Requires at least:** 3.8 **Tested up to:** 5.1 **Stable tag:** 2.7.0 -**License:** GPLv2 or later +**License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) **Donate link:** https://bit.ly/2TBvksV +**Requires PHP:** 5.3.0 [![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) diff --git a/readme.txt b/readme.txt index 6db8ecb..c776696 100755 --- a/readme.txt +++ b/readme.txt @@ -1,11 +1,13 @@ === OptionTree === Contributors: valendesigns -Donate link: https://bit.ly/2TBvksV -Tags: options, theme options, meta boxes +Tags: options, theme options, meta boxes, settings Requires at least: 3.8 Tested up to: 5.1 Stable tag: 2.7.0 License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html +Donate link: https://bit.ly/2TBvksV +Requires PHP: 5.3.0 Theme Options UI Builder for WordPress. A simple way to create & save Theme Options and Meta Boxes for free or premium themes. From a25d506ce6c1acdfc079aab6563dd0cb6d9b6b22 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 23:13:19 -0700 Subject: [PATCH 44/67] Fix markdown --- readme.md | 6 ++++-- readme.txt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 93ed012..2bb065a 100644 --- a/readme.md +++ b/readme.md @@ -97,7 +97,8 @@ This is a complete list of all the available option types that come shipped with 1. You must deactivate and/or delete the plugin version of OptionTree. 1. Add the following code to the beginning of your `functions.php`. -`/** +``` +/** * Required: set 'ot_theme_mode' filter to true. */ add_filter( 'ot_theme_mode', '__return_true' ); @@ -105,7 +106,8 @@ add_filter( 'ot_theme_mode', '__return_true' ); /** * Required: include OptionTree. */ -require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );` +require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' ); +``` For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode. diff --git a/readme.txt b/readme.txt index c776696..47cc0e1 100755 --- a/readme.txt +++ b/readme.txt @@ -94,7 +94,8 @@ This is a complete list of all the available option types that come shipped with 1. You must deactivate and/or delete the plugin version of OptionTree. 1. Add the following code to the beginning of your `functions.php`. -`/** +``` +/** * Required: set 'ot_theme_mode' filter to true. */ add_filter( 'ot_theme_mode', '__return_true' ); @@ -102,7 +103,8 @@ add_filter( 'ot_theme_mode', '__return_true' ); /** * Required: include OptionTree. */ -require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' );` +require( trailingslashit( get_template_directory() ) . 'option-tree/ot-loader.php' ); +``` For a list of all the OptionTree UI display filters refer to the `demo-functions.php` file found in the `/assets/theme-mode/` directory of this plugin. This file is the starting point for developing themes with Theme Mode. From d29c3d88281423abde3754560ec2434f769e8aa6 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 23:30:34 -0700 Subject: [PATCH 45/67] Fix colorpicker style closes #679 --- assets/css/ot-admin.css | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/assets/css/ot-admin.css b/assets/css/ot-admin.css index ee6affe..c6e5a99 100755 --- a/assets/css/ot-admin.css +++ b/assets/css/ot-admin.css @@ -2522,6 +2522,9 @@ select.option-tree-ui-select option { .hide-color-picker { display: none; } +.wp-picker-active .hide-color-picker { + display: inline-block; +} .option-tree-ui-colorpicker-input-wrap .option-tree-ui-colorpicker-label { height: 30px; line-height: 30px; @@ -2550,7 +2553,7 @@ select.option-tree-ui-select option { margin: 0 0 5px 0 !important; } .option-tree-ui-colorpicker-input-wrap .wp-color-result { - height: 27px; + height: 29px !important; outline: 0; margin: 0 5px 5px 0px; top: 0px; @@ -2558,7 +2561,8 @@ select.option-tree-ui-select option { -moz-box-shadow: none; box-shadow: none; } -.option-tree-ui-colorpicker-input-wrap .wp-color-result:after { +.option-tree-ui-colorpicker-input-wrap .wp-color-result:after, +.option-tree-ui-colorpicker-input-wrap .wp-color-result-text{ line-height: 27px; } .option-tree-ui-colorpicker-input-wrap .wp-picker-container .iris-picker { From 795bc801e028204179e6f687a829b53f7aef2ba4 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Sun, 10 Mar 2019 23:30:53 -0700 Subject: [PATCH 46/67] Add space --- assets/css/ot-admin.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/ot-admin.css b/assets/css/ot-admin.css index c6e5a99..fbebfe7 100755 --- a/assets/css/ot-admin.css +++ b/assets/css/ot-admin.css @@ -2562,7 +2562,7 @@ select.option-tree-ui-select option { box-shadow: none; } .option-tree-ui-colorpicker-input-wrap .wp-color-result:after, -.option-tree-ui-colorpicker-input-wrap .wp-color-result-text{ +.option-tree-ui-colorpicker-input-wrap .wp-color-result-text { line-height: 27px; } .option-tree-ui-colorpicker-input-wrap .wp-picker-container .iris-picker { From 7f3e594e2f1305fa38b7192f82fdb4f12cfc8ebd Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 11 Mar 2019 00:03:27 -0700 Subject: [PATCH 47/67] Prepare SQL closes #667 --- includes/ot-functions-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 161130e..109876d 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -901,7 +901,7 @@ function ot_get_media_post_ID() { // phpcs:ignore global $wpdb; // Get the media post ID. - $post_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE `post_title` = 'Media' AND `post_type` = 'option-tree' AND `post_status` = 'private'" ); // phpcs:ignore + $post_ID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts p WHERE p.post_title = %s AND p.post_type = %s AND p.post_status = %s", 'Media', 'option-tree', 'private' ) ); // phpcs:ignore // Add to the DB. if ( null !== $post_ID && 0 < $post_ID ) { From 487d4bf39510d0ca620855352c1f1dac197fc96c Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 11 Mar 2019 00:43:13 -0700 Subject: [PATCH 48/67] Fix css insert --- includes/ot-functions-admin.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 109876d..7926655 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -3298,7 +3298,9 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa } // Remove CSS from file, but ensure the file is actually CSS first. - if ( is_writeable( $filepath ) && 'css' === end( explode( '.', basename( $filepath ) ) ) ) { + $file_parts = explode( '.', basename( $filepath ) ); + $file_ext = end( $file_parts ); + if ( is_writeable( $filepath ) && 'css' === $file_ext ) { $insertion = ot_normalize_css( $insertion ); $regex = '/{{([a-zA-Z0-9\_\-\#\|\=]+)}}/'; @@ -3370,8 +3372,14 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa // Box Shadow. } elseif ( 'box-shadow' === $option_type ) { + $value_safe = array(); + foreach ( $value as $val ) { + if ( ! empty( $val ) ) { + $value_safe[] = $val; + } + } // Set $value with box-shadow properties or empty string. - $value = ! empty( $value ) ? implode( ' ', $value ) : ''; + $value = ! empty( $value_safe ) ? implode( ' ', $value_safe ) : ''; // Dimension. } elseif ( 'dimension' === $option_type ) { @@ -3516,7 +3524,7 @@ function ot_insert_css_with_markers( $field_id = '', $insertion = '', $meta = fa $value .= "background-size: $size;"; } } - } else { + } elseif ( ! empty( $value[ $option_key ] ) ) { $value = $value[ $option_key ]; } } From 7fdb15764e24c251cfbca62a7067a1629f580280 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 11 Mar 2019 02:33:39 -0700 Subject: [PATCH 49/67] Update changelog --- readme.md | 3 ++- readme.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2bb065a..0ed5c69 100644 --- a/readme.md +++ b/readme.md @@ -137,7 +137,8 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50 * Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred * Fix notice "Only variables should be passed by reference". props @SergeAx -* Add `wordpress-plugin` project type to composer file. props @egifford +* Add `wordpress-plugin` project type to composer file. props @egifford +* Removed translation files. ### 2.6.0 ### * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. diff --git a/readme.txt b/readme.txt index 47cc0e1..b840ee4 100755 --- a/readme.txt +++ b/readme.txt @@ -140,6 +140,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred * Fix notice "Only variables should be passed by reference". props @SergeAx * Add `wordpress-plugin` project type to composer file. props @egifford +* Removed translation files. = 2.6.0 = * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. From ce0de5a8b519fa40e5b643cf6ad797f6bcf6fc3c Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 14:57:04 -0700 Subject: [PATCH 50/67] Fix list-item value --- includes/class-ot-settings.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-ot-settings.php b/includes/class-ot-settings.php index 456e325..69d7664 100755 --- a/includes/class-ot-settings.php +++ b/includes/class-ot-settings.php @@ -604,7 +604,7 @@ public function sanitize_callback( $input ) { // Convert the settings to an array. $settings = isset( $post_global[ $setting['id'] . '_settings_array' ] ) ? ot_decode( $post_global[ $setting['id'] . '_settings_array' ] ) : array(); - // Settings are empty for some odd ass reason get the defaults. + // Settings are empty for some odd reason get the defaults. if ( empty( $settings ) ) { $settings = 'slider' === $setting['type'] ? ot_slider_settings( $setting['id'] ) : ot_list_item_settings( $setting['id'] ); } @@ -631,6 +631,7 @@ public function sanitize_callback( $input ) { // Validate setting. $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ] = ot_validate_setting( $input[ $setting['id'] ][ $k ][ $sub_setting['id'] ], $sub_setting['type'], $sub_setting['id'], $wpml_id ); + $has_value = true; } } From 6f06752264604f55d67e6d9c8131a2fe88d15ef4 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 15:22:57 -0700 Subject: [PATCH 51/67] Sanitize unknown setting types --- includes/ot-functions-admin.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 7926655..87d3872 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -711,6 +711,31 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { if ( ! empty( $input ) ) { $input_safe = esc_url_raw( $input ); } + } else { + + $input_safe = ''; + + // We don't know what the setting type is, so fallback to `sanitize_textarea_field` on all values. + if ( is_string( $input ) ) { + $input_safe = sanitize_textarea_field( $input ); + } elseif ( is_array( $input ) ) { + + /** + * Filter the array values recursively. + * + * @param array $values The value to sanitize. + * + * @return array + */ + function _sanitize_recursive( $values = array() ) { + $result = array(); + foreach ( $values as $key => $value ) { + $result[ $key ] = is_array( $value ) ? _sanitize_recursive( $value ) : sanitize_textarea_field( $value ); + } + return $result; + } + $input_safe = _sanitize_recursive( $input ); + } } // WPML Register and Unregister strings. From ecb11aa85fef4d97c965096bdbd1455d84ec477a Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 21:51:56 -0700 Subject: [PATCH 52/67] Add notice for best-effort data sanitizing --- includes/ot-functions-admin.php | 58 +++++++++++++++++++++++---------- readme.md | 4 +-- readme.txt | 5 +-- 3 files changed, 42 insertions(+), 25 deletions(-) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 87d3872..7dc6c07 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -713,28 +713,49 @@ function ot_validate_setting( $input, $type, $field_id, $wmpl_id = '' ) { } } else { + /* translators: %1$s: the calling function, %2$s the filter name, %3$s the option type, %4$s the version number */ + $string_error = esc_html__( 'Notice: %1$s was called incorrectly. All stored data must be filtered through %2$s, the %3$s option type is not using this filter. This is required since version %4$s.', 'option-tree' ); + + // Log a user notice that things have changed since the last version. + add_settings_error( 'option-tree', 'ot_validate_setting_error', sprintf( $string_error, 'ot_validate_setting', 'ot_validate_setting_input_safe', '' . $type . '', '2.7.0' ), 'error' ); + $input_safe = ''; - // We don't know what the setting type is, so fallback to `sanitize_textarea_field` on all values. - if ( is_string( $input ) ) { - $input_safe = sanitize_textarea_field( $input ); - } elseif ( is_array( $input ) ) { - - /** - * Filter the array values recursively. - * - * @param array $values The value to sanitize. - * - * @return array - */ - function _sanitize_recursive( $values = array() ) { - $result = array(); - foreach ( $values as $key => $value ) { - $result[ $key ] = is_array( $value ) ? _sanitize_recursive( $value ) : sanitize_textarea_field( $value ); + /* + * We don't know what the setting type is, so fallback to `sanitize_textarea_field` + * on all values and do a best-effort sanitize of the user data before saving it. + */ + if ( ! is_object( $input ) ) { + + // Contains an integer, float, string or boolean. + if ( is_scalar( $input ) ) { + $input_safe = sanitize_textarea_field( $input ); + } else { + + /** + * Filter the array values recursively. + * + * @param array $values The value to sanitize. + * + * @return array + */ + function _sanitize_recursive( $values = array() ) { + $result = array(); + foreach ( $values as $key => $value ) { + if ( ! is_object( $value ) ) { + if ( is_scalar( $value ) ) { + $result[ $key ] = sanitize_textarea_field( $value ); + } else { + $result[ $key ] = _sanitize_recursive( $value ); + } + } + } + + return $result; } - return $result; + + $input_safe = _sanitize_recursive( $input ); } - $input_safe = _sanitize_recursive( $input ); } } @@ -758,6 +779,7 @@ function _sanitize_recursive( $values = array() ) { * * It's important to note that the filter does not have access to * the original value and can only modify the validated input value. + * This is a breaking change as of version 2.7.0. * * @param mixed $input_safe The setting field value. * @param string $type The setting field type. diff --git a/readme.md b/readme.md index 0ed5c69..feac7bd 100644 --- a/readme.md +++ b/readme.md @@ -116,9 +116,6 @@ For a list of all the OptionTree UI display filters refer to the `demo-functions ### Is there a demo theme I can install? ### There sure is, and I'm glad you asked. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and get some experience setting up OptionTree on your own with detailed directions and tips. -### Why are my translation files not loading? ### -It is important to note that when you use OptionTree as a plugin, you must store your language files in the `option-tree/languages` directory and use file names like `option-tree-es_ES.mo` & `option-tree-es_ES.po`. However, when using OptionTree in Theme Mode you must also create a `theme-mode` directory inside the `option-tree/languages` directory and store your files there with names like `es_ES.mo` & `es_ES.po`. This is due to the different naming conventions of the `load_plugin_textdomain()` and `load_theme_textdomain()` functions. - ### I get errors or a blank screen when I activate the plugin. What's the deal? ### The most likely scenario is your theme already has OptionTree installed in Theme Mode. And since the plugin and theme version can't both be active at the same time without the sky falling on your head, your site has decided to throw in the towel. If that's not your issue, open up a support request and we'll figure it out together. UPDATE: As of OptionTree 2.4.0 the plugin version will not conflict with the Theme Mode version if they are both 2.4.0 or higher. @@ -134,6 +131,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix a vulnerability where Object Injection could take place if someone has a valid nonce. * Force all settings to be sanitized and escaped before saving and during display. * Add filter `ot_validate_setting_input_safe` which is used to validate the input value of a custom setting type. All values must be validated! +* Add a notice to let users know that a custom setting type is not properly validating saved data and do a best-effort sanitize of the user data before saving it. * Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50 * Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred * Fix notice "Only variables should be passed by reference". props @SergeAx diff --git a/readme.txt b/readme.txt index b840ee4..975e1c5 100755 --- a/readme.txt +++ b/readme.txt @@ -114,10 +114,6 @@ For a list of all the OptionTree UI display filters refer to the `demo-functions There sure is, and I'm glad you asked. Download and activate the [OptionTree Theme](https://github.com/valendesigns/option-tree-theme) and get some experience setting up OptionTree on your own with detailed directions and tips. -= Why are my translation files not loading? = - -It is important to note that when you use OptionTree as a plugin, you must store your language files in the `option-tree/languages` directory and use file names like `option-tree-es_ES.mo` & `option-tree-es_ES.po`. However, when using OptionTree in Theme Mode you must also create a `theme-mode` directory inside the `option-tree/languages` directory and store your files there with names like `es_ES.mo` & `es_ES.po`. This is due to the different naming conventions of the `load_plugin_textdomain()` and `load_theme_textdomain()` functions. - = I get errors or a blank screen when I activate the plugin. What's the deal? = The most likely scenario is your theme already has OptionTree installed in Theme Mode. And since the plugin and theme version can't both be active at the same time without the sky falling on your head, your site has decided to throw in the towel. If that's not your issue, open up a support request and we'll figure it out together. UPDATE: As of OptionTree 2.4.0 the plugin version will not conflict with the Theme Mode version if they are both 2.4.0 or higher. @@ -136,6 +132,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix a vulnerability where Object Injection could take place if someone has a valid nonce. * Force all settings to be sanitized and escaped before saving and during display. * Add filter `ot_validate_setting_input_safe` which is used to validate the input value of a custom setting type. All values must be validated! +* Add a notice to let users know that a custom setting type is not properly validating saved data and do a best-effort sanitize of the user data before saving it. * Fix issue with Composer autoload and only load OptionTree if we have access to WordPress. props @infomaniac50 * Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred * Fix notice "Only variables should be passed by reference". props @SergeAx From 478e38bdb112ab75eefd8b9dabc69eb3b40f6fda Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 22:01:19 -0700 Subject: [PATCH 53/67] Add upgrade notice --- readme.md | 3 +++ readme.txt | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/readme.md b/readme.md index feac7bd..3a69f32 100644 --- a/readme.md +++ b/readme.md @@ -618,6 +618,9 @@ The most likely scenario is your theme already has OptionTree installed in Theme ## Upgrade Notice ## +### 2.7.0 ### +All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen on custom option type when saving. So please update your custom setting types. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! + ### 2.3.0 ### As with each major release, please install OptionTree on a test server before upgrading your live site. diff --git a/readme.txt b/readme.txt index 975e1c5..5c4e0e9 100755 --- a/readme.txt +++ b/readme.txt @@ -618,6 +618,10 @@ The most likely scenario is your theme already has OptionTree installed in Theme == Upgrade Notice == += 2.7.0 = + +All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen on custom option type when saving. So please update your custom setting types. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! + = 2.3.0 = As with each major release, please install OptionTree on a test server before upgrading your live site. From 94df1de2a56b89757bb4f2ed06afa20d7e66902f Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 22:01:53 -0700 Subject: [PATCH 54/67] Remove space --- readme.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/readme.txt b/readme.txt index 5c4e0e9..60e7203 100755 --- a/readme.txt +++ b/readme.txt @@ -619,7 +619,6 @@ The most likely scenario is your theme already has OptionTree installed in Theme == Upgrade Notice == = 2.7.0 = - All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen on custom option type when saving. So please update your custom setting types. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! = 2.3.0 = From b28152b7b75e975f5d7afee68072cac622e57e23 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 22:04:03 -0700 Subject: [PATCH 55/67] Reword message --- readme.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 3a69f32..bc92b69 100644 --- a/readme.md +++ b/readme.md @@ -619,7 +619,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme ## Upgrade Notice ## ### 2.7.0 ### -All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen on custom option type when saving. So please update your custom setting types. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! +All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen with custom setting types when saving — so please update them. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! ### 2.3.0 ### As with each major release, please install OptionTree on a test server before upgrading your live site. diff --git a/readme.txt b/readme.txt index 60e7203..4dc667e 100755 --- a/readme.txt +++ b/readme.txt @@ -619,7 +619,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme == Upgrade Notice == = 2.7.0 = -All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen on custom option type when saving. So please update your custom setting types. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! +All custom setting types must use the `ot_validate_setting_input_safe` filter to sanitize user input data. OptionTree will attempt to sanitize the data, but data loss could happen with custom setting types when saving — so please update them. Additionally, please install OptionTree on a test server, or backup your database, before upgrading your live site. This version contains breaking changes! = 2.3.0 = As with each major release, please install OptionTree on a test server before upgrading your live site. From e01454619506f93705be5d91551003309dc351d1 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 22:13:31 -0700 Subject: [PATCH 56/67] Add info about removing XML file import --- readme.md | 3 ++- readme.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bc92b69..fa42edd 100644 --- a/readme.md +++ b/readme.md @@ -136,7 +136,8 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix deprecated `create_function` notice in PHP 7.2+. props @modesthatred * Fix notice "Only variables should be passed by reference". props @SergeAx * Add `wordpress-plugin` project type to composer file. props @egifford -* Removed translation files. +* Removed translation files. +* Removed the deprecated XML file import method. ### 2.6.0 ### * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. diff --git a/readme.txt b/readme.txt index 4dc667e..eb9bc96 100755 --- a/readme.txt +++ b/readme.txt @@ -138,6 +138,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix notice "Only variables should be passed by reference". props @SergeAx * Add `wordpress-plugin` project type to composer file. props @egifford * Removed translation files. +* Removed the deprecated XML file import method. = 2.6.0 = * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. From c222267f61772a037d6702ed1d2e0c36160e9b81 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Wed, 13 Mar 2019 22:21:27 -0700 Subject: [PATCH 57/67] Update tested up to version --- readme.md | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index fa42edd..6b61a56 100644 --- a/readme.md +++ b/readme.md @@ -6,7 +6,7 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Opti **Contributors:** [valendesigns](https://profiles.wordpress.org/valendesigns) **Tags:** [options](https://wordpress.org/plugins/tags/options), [theme options](https://wordpress.org/plugins/tags/theme-options), [meta boxes](https://wordpress.org/plugins/tags/meta-boxes), [settings](https://wordpress.org/plugins/tags/settings) **Requires at least:** 3.8 -**Tested up to:** 5.1 +**Tested up to:** 5.1.1 **Stable tag:** 2.7.0 **License:** [GPLv2 or later](http://www.gnu.org/licenses/gpl-2.0.html) **Donate link:** https://bit.ly/2TBvksV diff --git a/readme.txt b/readme.txt index eb9bc96..ab2f570 100755 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: valendesigns Tags: options, theme options, meta boxes, settings Requires at least: 3.8 -Tested up to: 5.1 +Tested up to: 5.1.1 Stable tag: 2.7.0 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html From a787c4cd8966657fbe8d784288c3e9d6c94696ef Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Mon, 18 Mar 2019 01:03:18 -0700 Subject: [PATCH 58/67] Add svn deploy to WP.org --- .gitignore | 4 + Gruntfile.js | 55 +++++ license.txt | 674 --------------------------------------------------- package.json | 15 ++ 4 files changed, 74 insertions(+), 674 deletions(-) create mode 100644 Gruntfile.js delete mode 100644 license.txt create mode 100644 package.json diff --git a/.gitignore b/.gitignore index e2c309f..6b39f4b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ # Composer /vendor composer.lock + +# NPM +/node_modules +/build diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..9e3fd32 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,55 @@ +/* global module */ +/* jshint node:true */ +module.exports = function( grunt ) { + 'use strict'; + + grunt.initConfig( { + + // Build a deploy-able plugin + copy: { + build: { + src: [ + '!.*', + '!.*/**', + 'assets/**', + 'includes/**', + 'composer.json', + 'LICENSE', + 'ot-loader.php', + 'readme.txt' + ], + dest: 'build', + expand: true, + dot: true + } + }, + + // Clean up the build + clean: { + build: { + src: [ 'build' ] + } + }, + + // Deploys a git Repo to the WordPress SVN repo + wp_deploy: { + deploy: { + options: { + plugin_slug: 'option-tree', + build_dir: 'build' + } + } + } + } ); + + // Load tasks + grunt.loadNpmTasks( 'grunt-contrib-clean' ); + grunt.loadNpmTasks( 'grunt-contrib-copy' ); + grunt.loadNpmTasks( 'grunt-wp-deploy' ); + + grunt.registerTask( 'deploy', [ + 'copy', + 'wp_deploy', + 'clean' + ] ); +}; diff --git a/license.txt b/license.txt deleted file mode 100644 index 20d40b6..0000000 --- a/license.txt +++ /dev/null @@ -1,674 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ba17566 --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "option-tree", + "version": "2.7.0", + "repository": { + "type": "git", + "url": "https://github.com/valendesigns/option-tree.git" + }, + "license": "GPL-2.0+", + "devDependencies": { + "grunt": "^1.0.3", + "grunt-contrib-clean": "~2.0.0", + "grunt-contrib-copy": "^1.0.0", + "grunt-wp-deploy": "~2.0.0" + } +} From 70bb3c6e60f973bd849dc491ae004efb94ff0337 Mon Sep 17 00:00:00 2001 From: ryanlabelle Date: Wed, 27 Mar 2019 11:27:06 -0700 Subject: [PATCH 59/67] Fixed styling for radio and checkbox inputs. Better alignemnt for gutenberg metaboxes. Tested theme options panel and metaboxes. --- assets/css/ot-admin.css | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/assets/css/ot-admin.css b/assets/css/ot-admin.css index fbebfe7..0675061 100755 --- a/assets/css/ot-admin.css +++ b/assets/css/ot-admin.css @@ -2320,12 +2320,10 @@ select.option-tree-ui-select option { ---------------------------------------------------*/ .format-setting.type-checkbox input, .format-setting.type-radio input { - float: left; - margin: 2px 5px 0 1px; + margin: 2px 5px 0 2px; } .format-setting.type-checkbox label, .format-setting.type-radio label { - float: left; max-width: 90%; padding: 0px; } From 9b7e3b456fc47c0c9b9b8765a8d9bfcad6e25bd4 Mon Sep 17 00:00:00 2001 From: ryanlabelle Date: Wed, 27 Mar 2019 22:03:47 -0700 Subject: [PATCH 60/67] FIX syntax error on plugin activation : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''wp_option_tree' ORDER BY item_sort ASC' at line 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was from ot-functions-admin.php - $wpdb->prepare was wrapping the table name in single quotes and MySQL didn’t like that. I took out the parepare because $wpdb->prefix it not meant to operate on user supplied data. I don’t think $wpdb->prefix should be considered user supplied but I suppose you could wrap some escaping code around $wpdb->prefix if you wanted to. Example from Codex that does this: https://codex.wordpress.org/Class_Reference/wpdb --- includes/ot-functions-admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 7dc6c07..7618962 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -1025,8 +1025,8 @@ function ot_default_settings() { $section_count = 0; $settings_count = 0; $settings = array(); - $table_name = $wpdb->prefix . 'option_tree'; - $old_settings = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s ORDER BY item_sort ASC', $table_name ) ); // phpcs:ignore + $table_name = "{$wpdb->prefix}option_tree"; + $old_settings = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY item_sort ASC"); // phpcs:ignore $find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore if ( $old_settings && $find_table === $table_name ) { From 0004ab9f5eeda5c775aed6364985184f2a0e2753 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 09:58:30 -0700 Subject: [PATCH 61/67] Merge changes and add caching to SQL query --- .phpcs.ruleset.xml | 1 + includes/ot-functions-admin.php | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.phpcs.ruleset.xml b/.phpcs.ruleset.xml index ac49c2a..8f652b2 100644 --- a/.phpcs.ruleset.xml +++ b/.phpcs.ruleset.xml @@ -9,6 +9,7 @@ . + /node_modules/* /vendor/* /tests/wp-tests/* /assets/theme-mode/* diff --git a/includes/ot-functions-admin.php b/includes/ot-functions-admin.php index 7618962..727ed01 100755 --- a/includes/ot-functions-admin.php +++ b/includes/ot-functions-admin.php @@ -1025,11 +1025,25 @@ function ot_default_settings() { $section_count = 0; $settings_count = 0; $settings = array(); - $table_name = "{$wpdb->prefix}option_tree"; - $old_settings = $wpdb->get_results( "SELECT * FROM $table_name ORDER BY item_sort ASC"); // phpcs:ignore - $find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore + $table_name = $wpdb->prefix . 'option_tree'; - if ( $old_settings && $find_table === $table_name ) { + $find_table = wp_cache_get( 'find_table', 'option_tree' ); + if ( false === $find_table ) { + $find_table = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table_name ) ); // phpcs:ignore + wp_cache_set( 'find_table', $find_table, 'option_tree', 86400 ); + } + + if ( $find_table === $table_name ) { + + $old_settings = wp_cache_get( 'old_settings', 'option_tree' ); + if ( false === $old_settings ) { + $old_settings = $wpdb->get_results( "SELECT * FROM ${table_name} ORDER BY item_sort ASC" ); // phpcs:ignore + wp_cache_set( 'old_settings', $old_settings, 'option_tree', 86400 ); + } + + if ( ! $old_settings ) { + return; + } foreach ( $old_settings as $setting ) { From 9a76fab630d847b7289206f9bd52f5219d240da7 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 09:59:45 -0700 Subject: [PATCH 62/67] Add props --- readme.md | 5 +++-- readme.txt | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 6b61a56..34c486a 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Opti **Donate link:** https://bit.ly/2TBvksV **Requires PHP:** 5.3.0 -[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) +[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com) ## Description ## @@ -137,7 +137,8 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Fix notice "Only variables should be passed by reference". props @SergeAx * Add `wordpress-plugin` project type to composer file. props @egifford * Removed translation files. -* Removed the deprecated XML file import method. +* Removed the deprecated XML file import method. +* Fix SQL syntax issue. props @ryanlabelle ### 2.6.0 ### * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. diff --git a/readme.txt b/readme.txt index ab2f570..3dd79c0 100755 --- a/readme.txt +++ b/readme.txt @@ -139,6 +139,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Add `wordpress-plugin` project type to composer file. props @egifford * Removed translation files. * Removed the deprecated XML file import method. +* Fix SQL syntax issue. props @ryanlabelle = 2.6.0 = * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. From 70c9c45aa44beda08e42d831cd6c624740d9d077 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 10:20:01 -0700 Subject: [PATCH 63/67] Add props --- readme.md | 3 ++- readme.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 34c486a..deac2ee 100644 --- a/readme.md +++ b/readme.md @@ -138,7 +138,8 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Add `wordpress-plugin` project type to composer file. props @egifford * Removed translation files. * Removed the deprecated XML file import method. -* Fix SQL syntax issue. props @ryanlabelle +* Fix SQL syntax issue. props @ryanlabelle +* Fix metabox radio & checkbox style issues. props @ryanlabelle ### 2.6.0 ### * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. diff --git a/readme.txt b/readme.txt index 3dd79c0..d7824e9 100755 --- a/readme.txt +++ b/readme.txt @@ -140,6 +140,7 @@ The most likely scenario is your theme already has OptionTree installed in Theme * Removed translation files. * Removed the deprecated XML file import method. * Fix SQL syntax issue. props @ryanlabelle +* Fix metabox radio & checkbox style issues. props @ryanlabelle = 2.6.0 = * Fix a reflected XSS vulnerability with the `add_list_item` & `add_social_links` Ajax requests. From 573eea5c065cb863ad2bce6ad5fce45156c2638f Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 10:24:38 -0700 Subject: [PATCH 64/67] Update Composer packages and fix grunt badge --- .gitignore | 1 - composer.json | 2 +- composer.lock | 1362 +++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 2 +- 4 files changed, 1364 insertions(+), 3 deletions(-) create mode 100644 composer.lock diff --git a/.gitignore b/.gitignore index 6b39f4b..800b5b3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ # Composer /vendor -composer.lock # NPM /node_modules diff --git a/composer.json b/composer.json index 1532284..c6659c4 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php-coveralls/php-coveralls": "^2.1", "slowprog/composer-copy-file": "0.2.1", "wp-coding-standards/wpcs": "*", - "xwp/wp-dev-lib": "^1.0.0" + "xwp/wp-dev-lib": "^1.1.0" }, "scripts": { "phpcs": [ diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..5b82ef3 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1362 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "9cd1d80c5a764fabf90d1d65896d7abe", + "packages": [], + "packages-dev": [ + { + "name": "brainmaestro/composer-git-hooks", + "version": "v2.6.1", + "source": { + "type": "git", + "url": "https://github.com/BrainMaestro/composer-git-hooks.git", + "reference": "137dd2aec2be494918f8bdfb18f57b55ff20015e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/BrainMaestro/composer-git-hooks/zipball/137dd2aec2be494918f8bdfb18f57b55ff20015e", + "reference": "137dd2aec2be494918f8bdfb18f57b55ff20015e", + "shasum": "" + }, + "require": { + "php": "^5.6 || >=7.0", + "symfony/console": "^3.2 || ^4.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.9", + "phpunit/phpunit": "^5.7|^7.0" + }, + "bin": [ + "cghooks" + ], + "type": "library", + "extra": { + "hooks": { + "pre-commit": "composer check-style", + "pre-push": [ + "composer test", + "appver=$(grep -o -P '\\d.\\d.\\d' cghooks)", + "tag=$(git tag --sort=-v:refname | head -n 1 | tr -d v)", + "if [ \"$tag\" != \"$appver\" ]; then", + "echo \"The most recent tag v$tag does not match the application version $appver\n\"", + "sed -i -E \"s/$appver/$tag/\" cghooks", + "exit 1", + "fi" + ] + } + }, + "autoload": { + "psr-4": { + "BrainMaestro\\GitHooks\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ezinwa Okpoechi", + "email": "brainmaestro@outlook.com" + } + ], + "description": "Easily manage git hooks in your composer config", + "keywords": [ + "HOOK", + "composer", + "git" + ], + "time": "2018-12-28T14:57:06+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v0.5.0", + "source": { + "type": "git", + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", + "reference": "e749410375ff6fb7a040a68878c656c2e610b132", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0", + "php": "^5.3|^7", + "squizlabs/php_codesniffer": "^2|^3" + }, + "require-dev": { + "composer/composer": "*", + "phpcompatibility/php-compatibility": "^9.0", + "sensiolabs/security-checker": "^4.1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "time": "2018-10-26T13:21:45+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-04-22T15:46:56+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.5.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "9f83dded91781a01c63574e387eaa769be769115" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", + "reference": "9f83dded91781a01c63574e387eaa769be769115", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2018-12-04T20:46:45+00:00" + }, + { + "name": "php-coveralls/php-coveralls", + "version": "v2.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-coveralls/php-coveralls.git", + "reference": "3b00c229726f892bfdadeaf01ea430ffd04a939d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-coveralls/php-coveralls/zipball/3b00c229726f892bfdadeaf01ea430ffd04a939d", + "reference": "3b00c229726f892bfdadeaf01ea430ffd04a939d", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.0", + "php": "^5.5 || ^7.0", + "psr/log": "^1.0", + "symfony/config": "^2.1 || ^3.0 || ^4.0", + "symfony/console": "^2.1 || ^3.0 || ^4.0", + "symfony/stopwatch": "^2.0 || ^3.0 || ^4.0", + "symfony/yaml": "^2.0 || ^3.0 || ^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0" + }, + "suggest": { + "symfony/http-kernel": "Allows Symfony integration" + }, + "bin": [ + "bin/php-coveralls" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "psr-4": { + "PhpCoveralls\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp", + "role": "Original creator" + }, + { + "name": "Takashi Matsuo", + "email": "tmatsuo@google.com" + }, + { + "name": "Google Inc" + }, + { + "name": "Dariusz Ruminski", + "email": "dariusz.ruminski@gmail.com", + "homepage": "https://github.com/keradus" + }, + { + "name": "Contributors", + "homepage": "https://github.com/php-coveralls/php-coveralls/graphs/contributors" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/php-coveralls/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2018-05-22T23:11:08+00:00" + }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.1.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/2b63c5d284ab8857f7b1d5c240ddb507a6b2293c", + "reference": "2b63c5d284ab8857f7b1d5c240ddb507a6b2293c", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + }, + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "time": "2018-12-30T23:16:27+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-paragonie", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityParagonie.git", + "reference": "9160de79fcd683b5c99e9c4133728d91529753ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityParagonie/zipball/9160de79fcd683b5c99e9c4133728d91529753ea", + "reference": "9160de79fcd683b5c99e9c4133728d91529753ea", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.4 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A set of rulesets for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by the Paragonie polyfill libraries.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "paragonie", + "phpcs", + "polyfill", + "standards" + ], + "time": "2018-12-16T19:10:44+00:00" + }, + { + "name": "phpcompatibility/phpcompatibility-wp", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", + "reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/cb303f0067cd5b366a41d4fb0e254fb40ff02efd", + "reference": "cb303f0067cd5b366a41d4fb0e254fb40ff02efd", + "shasum": "" + }, + "require": { + "phpcompatibility/php-compatibility": "^9.0", + "phpcompatibility/phpcompatibility-paragonie": "^1.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Wim Godden", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "lead" + } + ], + "description": "A ruleset for PHP_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.", + "homepage": "http://phpcompatibility.com/", + "keywords": [ + "compatibility", + "phpcs", + "standards", + "wordpress" + ], + "time": "2018-10-07T18:31:37+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2018-11-20T15:27:04+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" + }, + { + "name": "slowprog/composer-copy-file", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/slowprog/CopyFile.git", + "reference": "400c2b7c9f9f8ed8195217ae143ffbf3fec84c31" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/slowprog/CopyFile/zipball/400c2b7c9f9f8ed8195217ae143ffbf3fec84c31", + "reference": "400c2b7c9f9f8ed8195217ae143ffbf3fec84c31", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "mikey179/vfsstream": "~1", + "phpunit/phpunit": "~5.0", + "symfony/filesystem": "~2.7", + "symfony/finder": "~2.7" + }, + "type": "library", + "autoload": { + "psr-4": { + "SlowProg\\CopyFile\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andrey Tyshev", + "email": "slowprog@gmail.com" + } + ], + "description": "Composer script copying your files after install", + "homepage": "https://github.com/SlowProg/composer-copy-file", + "keywords": [ + "copy file" + ], + "time": "2017-12-07T13:18:47+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.4.2", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2019-04-10T23:49:02+00:00" + }, + { + "name": "symfony/config", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "177a276c01575253c95cefe0866e3d1b57637fe0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/177a276c01575253c95cefe0866e3d1b57637fe0", + "reference": "177a276c01575253c95cefe0866e3d1b57637fe0", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Config Component", + "homepage": "https://symfony.com", + "time": "2019-02-23T15:06:07+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "15a9104356436cb26e08adab97706654799d31d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/15a9104356436cb26e08adab97706654799d31d8", + "reference": "15a9104356436cb26e08adab97706654799d31d8", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Console\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Console Component", + "homepage": "https://symfony.com", + "time": "2019-04-08T09:29:13+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "681afbb26488903c5ac15e63734f1d8ac430c9b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/681afbb26488903c5ac15e63734f1d8ac430c9b9", + "reference": "681afbb26488903c5ac15e63734f1d8ac430c9b9", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/http-kernel": "~2.8|~3.0|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2019-04-11T09:48:14+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/acf99758b1df8e9295e6b85aa69f294565c9fedb", + "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2019-02-04T21:34:32+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "82ebae02209c21113908c229e9883c419720738a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + }, + { + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/stopwatch", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "2a651c2645c10bbedd21170771f122d935e0dd58" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/2a651c2645c10bbedd21170771f122d935e0dd58", + "reference": "2a651c2645c10bbedd21170771f122d935e0dd58", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2019-01-16T09:39:14+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.4.25", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "reference": "212a27b731e5bfb735679d1ffaac82bd6a1dc996", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2019-03-25T07:48:46+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", + "reference": "8c7a2e7682de9ef5955251874b639deda51ef470" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8c7a2e7682de9ef5955251874b639deda51ef470", + "reference": "8c7a2e7682de9ef5955251874b639deda51ef470", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.3.1" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", + "phpcompatibility/php-compatibility": "^9.0", + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "wordpress" + ], + "time": "2019-04-08T10:53:57+00:00" + }, + { + "name": "xwp/wp-dev-lib", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/xwp/wp-dev-lib.git", + "reference": "4caaf0f554778bb59062c8797755999b5fae400d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/xwp/wp-dev-lib/zipball/4caaf0f554778bb59062c8797755999b5fae400d", + "reference": "4caaf0f554778bb59062c8797755999b5fae400d", + "shasum": "" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Weston Ruter", + "email": "weston@xwp.co", + "homepage": "https://weston.ruter.net" + }, + { + "name": "XWP", + "email": "engage@xwp.co", + "homepage": "https://xwp.co" + } + ], + "description": "Common code used during development of WordPress plugins and themes", + "homepage": "https://github.com/xwp/wp-dev-lib", + "keywords": [ + "wordpress" + ], + "time": "2019-04-06T06:37:44+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": ">=5.3" + }, + "platform-dev": [] +} diff --git a/readme.md b/readme.md index deac2ee..89f71e8 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ Theme Options UI Builder for WordPress. A simple way to create & save Theme Opti **Donate link:** https://bit.ly/2TBvksV **Requires PHP:** 5.3.0 -[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) [![Built with Grunt](https://cdn.gruntjs.com/builtwith.svg)](http://gruntjs.com) +[![Build Status](https://travis-ci.org/valendesigns/option-tree.svg?branch=develop)](https://travis-ci.org/valendesigns/option-tree) [![Built with Grunt](https://gruntjs.com/cdn/builtwith.svg)](http://gruntjs.com) ## Description ## From 6d0948c2c08e7e8c314aac1e6d0b8a5ae41450c1 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 10:47:01 -0700 Subject: [PATCH 65/67] Format demo files --- assets/theme-mode/demo-meta-boxes.php | 142 +- assets/theme-mode/demo-theme-options.php | 1596 +++++++++++----------- 2 files changed, 871 insertions(+), 867 deletions(-) diff --git a/assets/theme-mode/demo-meta-boxes.php b/assets/theme-mode/demo-meta-boxes.php index 5b71fbd..9a79296 100755 --- a/assets/theme-mode/demo-meta-boxes.php +++ b/assets/theme-mode/demo-meta-boxes.php @@ -1,7 +1,10 @@ 'demo_meta_box', - 'title' => __( 'Demo Meta Box', 'theme-text-domain' ), - 'desc' => '', - 'pages' => array( 'post' ), - 'context' => 'normal', - 'priority' => 'high', - 'fields' => array( - array( - 'label' => __( 'Conditions', 'theme-text-domain' ), - 'id' => 'demo_conditions', - 'type' => 'tab' - ), - array( - 'label' => __( 'Show Gallery', 'theme-text-domain' ), - 'id' => 'demo_show_gallery', - 'type' => 'on-off', - 'desc' => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), 'on' ), - 'std' => 'off' - ), - array( - 'label' => '', - 'id' => 'demo_textblock', - 'type' => 'textblock', - 'desc' => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ), - 'operator' => 'and', - 'condition' => 'demo_show_gallery:is(on),demo_gallery:not()' - ), - array( - 'label' => __( 'Gallery', 'theme-text-domain' ), - 'id' => 'demo_gallery', - 'type' => 'gallery', - 'desc' => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), 'demo_show_gallery:is(on)' ), - 'condition' => 'demo_show_gallery:is(on)' - ), - array( - 'label' => __( 'More Options', 'theme-text-domain' ), - 'id' => 'demo_more_options', - 'type' => 'tab' - ), - array( - 'label' => __( 'Text', 'theme-text-domain' ), - 'id' => 'demo_text', - 'type' => 'text', - 'desc' => __( 'This is a demo Text field.', 'theme-text-domain' ) - ), - array( - 'label' => __( 'Textarea', 'theme-text-domain' ), - 'id' => 'demo_textarea', - 'type' => 'textarea', - 'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' ) - ) - ) - ); - - /** - * Register our meta boxes using the - * ot_register_meta_box() function. - */ - if ( function_exists( 'ot_register_meta_box' ) ) - ot_register_meta_box( $my_meta_box ); -} \ No newline at end of file + /** + * Create a custom meta boxes array that we pass to + * the OptionTree Meta Box API Class. + */ + $my_meta_box = array( + 'id' => 'demo_meta_box', + 'title' => __( 'Demo Meta Box', 'theme-text-domain' ), + 'desc' => '', + 'pages' => array( 'post' ), + 'context' => 'normal', + 'priority' => 'high', + 'fields' => array( + array( + 'label' => __( 'Conditions', 'theme-text-domain' ), + 'id' => 'demo_conditions', + 'type' => 'tab', + ), + array( + 'label' => __( 'Show Gallery', 'theme-text-domain' ), + 'id' => 'demo_show_gallery', + 'type' => 'on-off', + 'desc' => sprintf( __( 'Shows the Gallery when set to %s.', 'theme-text-domain' ), 'on' ), + 'std' => 'off', + ), + array( + 'label' => '', + 'id' => 'demo_textblock', + 'type' => 'textblock', + 'desc' => __( 'Congratulations, you created a gallery!', 'theme-text-domain' ), + 'operator' => 'and', + 'condition' => 'demo_show_gallery:is(on),demo_gallery:not()', + ), + array( + 'label' => __( 'Gallery', 'theme-text-domain' ), + 'id' => 'demo_gallery', + 'type' => 'gallery', + 'desc' => sprintf( __( 'This is a Gallery option type. It displays when %s.', 'theme-text-domain' ), 'demo_show_gallery:is(on)' ), + 'condition' => 'demo_show_gallery:is(on)', + ), + array( + 'label' => __( 'More Options', 'theme-text-domain' ), + 'id' => 'demo_more_options', + 'type' => 'tab', + ), + array( + 'label' => __( 'Text', 'theme-text-domain' ), + 'id' => 'demo_text', + 'type' => 'text', + 'desc' => __( 'This is a demo Text field.', 'theme-text-domain' ), + ), + array( + 'label' => __( 'Textarea', 'theme-text-domain' ), + 'id' => 'demo_textarea', + 'type' => 'textarea', + 'desc' => __( 'This is a demo Textarea field.', 'theme-text-domain' ), + ), + ), + ); + + /** + * Register our meta boxes using the + * ot_register_meta_box() function. + */ + if ( function_exists( 'ot_register_meta_box' ) ) { + ot_register_meta_box( $my_meta_box ); + } +} diff --git a/assets/theme-mode/demo-theme-options.php b/assets/theme-mode/demo-theme-options.php index 00f5ea5..99c3eee 100755 --- a/assets/theme-mode/demo-theme-options.php +++ b/assets/theme-mode/demo-theme-options.php @@ -1,812 +1,814 @@ array( - 'content' => array( - array( - 'id' => 'option_types_help', - 'title' => __( 'Option Types', 'theme-text-domain' ), - 'content' => '

      ' . __( 'Help content goes here!', 'theme-text-domain' ) . '

      ' - ) - ), - 'sidebar' => '

      ' . __( 'Sidebar content goes here!', 'theme-text-domain' ) . '

      ' - ), - 'sections' => array( - array( - 'id' => 'option_types', - 'title' => __( 'Option Types', 'theme-text-domain' ) - ) - ), - 'settings' => array( - array( - 'id' => 'demo_background', - 'label' => __( 'Background', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %s to remove unwanted fields from all Background options or an individual one. You can also filter %s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), 'ot_get_option()', 'ot_recognized_background_fields', 'ot_recognized_background_repeat, ot_recognized_background_attachment, ot_recognized_background_position, ' . __( 'and', 'theme-text-domain' ) . ' ot_type_background_size_choices' ), - 'std' => '', - 'type' => 'background', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_border', - 'label' => __( 'Border', 'theme-text-domain' ), - 'desc' => __( 'The Border option type is used to set width, unit, style, and color values.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'border', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_box_shadow', - 'label' => __( 'Box Shadow', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Box Shadow option type is used to set %s, %s, %s, %s, %s, and %s values.', 'theme-text-domain' ), 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color' ), - 'std' => '', - 'type' => 'box-shadow', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_category_checkbox', - 'label' => __( 'Category Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'category-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_category_select', - 'label' => __( 'Category Select', 'theme-text-domain' ), - 'desc' => __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'category-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_checkbox', - 'label' => __( 'Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and', - 'choices' => array( - array( - 'value' => 'no', - 'label' => __( 'No', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'Yes', - 'label' => __( 'Yes', 'theme-text-domain' ), - 'src' => '' - ) - ) - ), - array( - 'id' => 'demo_colorpicker', - 'label' => __( 'Colorpicker', 'theme-text-domain' ), - 'desc' => __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'colorpicker', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_colorpicker_opacity', - 'label' => __( 'Colorpicker Opacity', 'theme-text-domain' ), - 'desc' => __( 'Colorpicker Opacity', 'option-tree-theme' ), - 'desc' => sprintf( __( 'The Colorpicker Opacity option type saves an rgba color value for use in CSS. To add opacity to other colorpickers add the %s class to the %s array.', 'option-tree' ), 'ot-colorpicker-opacity', '$args' ), - 'std' => '', - 'type' => 'colorpicker-opacity', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_css', - 'label' => __( 'CSS', 'theme-text-domain' ), - 'desc' => '

      ' . sprintf( __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %s at the root level of your theme and change permissions using %s so the server can write to the file. I have had the most success setting this single file to %s but feel free to play around with permissions until everything is working. A good starting point is %s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'theme-text-domain' ), 'dynamic.css', 'chmod', '0777', '0666' ) . '

      ' . sprintf( __( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'theme-text-domain' ), 'demo_background', 'dynamic.css' ) . '

      ', - 'std' => '#custom { + /** + * Custom settings array that will eventually be + * passes to the OptionTree Settings API Class. + */ + $custom_settings = array( + 'contextual_help' => array( + 'content' => array( + array( + 'id' => 'option_types_help', + 'title' => __( 'Option Types', 'theme-text-domain' ), + 'content' => '

      ' . __( 'Help content goes here!', 'theme-text-domain' ) . '

      ', + ), + ), + 'sidebar' => '

      ' . __( 'Sidebar content goes here!', 'theme-text-domain' ) . '

      ', + ), + 'sections' => array( + array( + 'id' => 'option_types', + 'title' => __( 'Option Types', 'theme-text-domain' ), + ), + ), + 'settings' => array( + array( + 'id' => 'demo_background', + 'label' => __( 'Background', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Background option type is for adding background styles to your theme either dynamically via the CSS option type below or manually with %1$s. The Background option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), 'ot_get_option()', 'ot_recognized_background_fields', 'ot_recognized_background_repeat, ot_recognized_background_attachment, ot_recognized_background_position, ' . __( 'and', 'theme-text-domain' ) . ' ot_type_background_size_choices' ), + 'std' => '', + 'type' => 'background', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_border', + 'label' => __( 'Border', 'theme-text-domain' ), + 'desc' => __( 'The Border option type is used to set width, unit, style, and color values.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'border', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_box_shadow', + 'label' => __( 'Box Shadow', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Box Shadow option type is used to set %1$s, %2$s, %3$s, %4$s, %5$s, and %6$s values.', 'theme-text-domain' ), 'inset', 'offset-x', 'offset-y', 'blur-radius', 'spread-radius', 'color' ), + 'std' => '', + 'type' => 'box-shadow', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_category_checkbox', + 'label' => __( 'Category Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Category Checkbox option type displays a list of category IDs. It allows the user to check multiple category IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'category-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_category_select', + 'label' => __( 'Category Select', 'theme-text-domain' ), + 'desc' => __( 'The Category Select option type displays a list of category IDs. It allows the user to select only one category ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'category-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_checkbox', + 'label' => __( 'Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Checkbox option type displays a group of choices. It allows the user to check multiple choices and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + 'choices' => array( + array( + 'value' => 'no', + 'label' => __( 'No', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'Yes', + 'label' => __( 'Yes', 'theme-text-domain' ), + 'src' => '', + ), + ), + ), + array( + 'id' => 'demo_colorpicker', + 'label' => __( 'Colorpicker', 'theme-text-domain' ), + 'desc' => __( 'The Colorpicker option type saves a hexadecimal color code for use in CSS. Use it to modify the color of something in your theme.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'colorpicker', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_colorpicker_opacity', + 'label' => __( 'Colorpicker Opacity', 'theme-text-domain' ), + 'desc' => __( 'Colorpicker Opacity', 'option-tree-theme' ), + 'desc' => sprintf( __( 'The Colorpicker Opacity option type saves an rgba color value for use in CSS. To add opacity to other colorpickers add the %1$s class to the %2$s array.', 'option-tree' ), 'ot-colorpicker-opacity', '$args' ), + 'std' => '', + 'type' => 'colorpicker-opacity', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_css', + 'label' => __( 'CSS', 'theme-text-domain' ), + 'desc' => '

      ' . sprintf( __( 'The CSS option type is a textarea that when used properly can add dynamic CSS to your theme from within OptionTree. Unfortunately, due server limitations you will need to create a file named %1$s at the root level of your theme and change permissions using %2$s so the server can write to the file. I have had the most success setting this single file to %3$s but feel free to play around with permissions until everything is working. A good starting point is %4$s. When the server can save to the file, CSS will automatically be updated when you save your Theme Options.', 'theme-text-domain' ), 'dynamic.css', 'chmod', '0777', '0666' ) . '

      ' . sprintf( __( 'This example assumes you have an option with the ID of %1$s. Which means this option will automatically insert the value of %1$s into the %2$s when the Theme Options are saved.', 'theme-text-domain' ), 'demo_background', 'dynamic.css' ) . '

      ', + 'std' => '#custom { {{demo_background}} }', - 'type' => 'css', - 'section' => 'option_types', - 'rows' => '20', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_custom_post_type_checkbox', - 'label' => __( 'Custom Post Type Checkbox', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), 'post_type' ), - 'std' => '', - 'type' => 'custom-post-type-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => 'post', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_custom_post_type_select', - 'label' => __( 'Custom Post Type Select', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), 'post_type' ), - 'std' => '', - 'type' => 'custom-post-type-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => 'post', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_date_picker', - 'label' => __( 'Date Picker', 'theme-text-domain' ), - 'desc' => __( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'date-picker', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_date_time_picker', - 'label' => __( 'Date Time Picker', 'theme-text-domain' ), - 'desc' => __( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'date-time-picker', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_dimension', - 'label' => __( 'Dimension', 'theme-text-domain' ), - 'desc' => __( 'The Dimension option type is used to set width and height values.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'dimension', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_gallery', - 'label' => __( 'Gallery', 'theme-text-domain' ), - 'desc' => __( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'gallery', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_gallery_shortcode', - 'label' => __( 'Gallery Shortcode', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Gallery option type can also be saved as a shortcode by adding %s to the class attribute. Using the Gallery option type in this manner will result in a better user experience as you\'re able to save the link, column, and order settings.', 'theme-text-domain' ), 'ot-gallery-shortcode' ), - 'std' => '', - 'type' => 'gallery', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => 'ot-gallery-shortcode', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_google_fonts', - 'label' => __( 'Google Fonts', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'theme-text-domain' ), 'HEAD', 'font-family', 'ot_google_font_stack', '$font_stack', '$family', '$field_id', 'ot_recognized_font_families' ), - 'std' => array( - array( - 'family' => 'opensans', - 'variants' => array( '300', '300italic', 'regular', 'italic', '600', '600italic' ), - 'subsets' => array( 'latin' ) - ) - ), - 'type' => 'google-fonts', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_javascript', - 'label' => __( 'JavaScript', 'theme-text-domain' ), - 'desc' => '

      ' . sprintf( __( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'theme-text-domain' ), 'ace.js' ) . '

      ', - 'std' => '', - 'type' => 'javascript', - 'section' => 'option_types', - 'rows' => '20', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_link_color', - 'label' => __( 'Link Color', 'theme-text-domain' ), - 'desc' => __( 'The Link Color option type is used to set all link color states.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'link-color', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_list_item', - 'label' => __( 'List Item', 'theme-text-domain' ), - 'desc' => __( 'The List Item option type allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'list-item', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and', - 'settings' => array( - array( - 'id' => 'demo_list_item_content', - 'label' => __( 'Content', 'theme-text-domain' ), - 'desc' => '', - 'std' => '', - 'type' => 'textarea-simple', - 'rows' => '10', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ) - ) - ), - array( - 'id' => 'demo_measurement', - 'label' => __( 'Measurement', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %s, %s, %s, and %s. However, you can change them with the %s filter.', 'theme-text-domain' ), 'px', '%', 'em', 'pt', 'ot_measurement_unit_types' ), - 'std' => '', - 'type' => 'measurement', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_numeric_slider', - 'label' => __( 'Numeric Slider', 'theme-text-domain' ), - 'desc' => __( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'numeric-slider', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '-500,5000,100', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_on_off', - 'label' => __( 'On/Off', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %s or %s.', 'theme-text-domain' ), 'on', 'off' ), - 'std' => '', - 'type' => 'on-off', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_page_checkbox', - 'label' => __( 'Page Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'page-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_page_select', - 'label' => __( 'Page Select', 'theme-text-domain' ), - 'desc' => __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'page-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_post_checkbox', - 'label' => __( 'Post Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'post-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_post_select', - 'label' => __( 'Post Select', 'theme-text-domain' ), - 'desc' => __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'post-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_radio', - 'label' => __( 'Radio', 'theme-text-domain' ), - 'desc' => __( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'radio', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and', - 'choices' => array( - array( - 'value' => 'yes', - 'label' => __( 'Yes', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'no', - 'label' => __( 'No', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'maybe', - 'label' => __( 'Maybe', 'theme-text-domain' ), - 'src' => '' - ) - ) - ), - array( - 'id' => 'demo_radio_image', - 'label' => __( 'Radio Image', 'theme-text-domain' ), - 'desc' => sprintf( __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'theme-text-domain' ), 'ot_radio_images' ), - 'std' => 'right-sidebar', - 'type' => 'radio-image', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_select', - 'label' => __( 'Select', 'theme-text-domain' ), - 'desc' => __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and', - 'choices' => array( - array( - 'value' => '', - 'label' => __( '-- Choose One --', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'yes', - 'label' => __( 'Yes', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'no', - 'label' => __( 'No', 'theme-text-domain' ), - 'src' => '' - ), - array( - 'value' => 'maybe', - 'label' => __( 'Maybe', 'theme-text-domain' ), - 'src' => '' - ) - ) - ), - array( - 'id' => 'demo_sidebar_select', - 'label' => __( 'Sidebar Select', 'theme-text-domain' ), - 'desc' => '

      ' . sprintf( __( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %s, and %s we can be selective about which sidebars are available on a specific content area.', 'theme-text-domain' ), 'ot_recognized_sidebars', 'ot_recognized_sidebars_{$field_id}' ) . '

      ' . sprintf( __( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'theme-text-domain' ), 'footer-sidebar-$i' ) . '

      ', - 'std' => '', - 'type' => 'sidebar-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_social_links', - 'label' => __( 'Social Links', 'theme-text-domain' ), - 'desc' => '

      ' . sprintf( __( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %s filter to %s and turn off loading default values. Use the %s filter to change the default values that are loaded. To filter the settings array use the %s filter.', 'theme-text-domain' ), 'ot_type_social_links_load_defaults', 'false', 'ot_type_social_links_defaults', 'ot_social_links_settings' ) . '

      ', - 'std' => '', - 'type' => 'social-links', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_spacing', - 'label' => __( 'Spacing', 'theme-text-domain' ), - 'desc' => __( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'spacing', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_tag_checkbox', - 'label' => __( 'Tag Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'tag-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_tag_select', - 'label' => __( 'Tag Select', 'theme-text-domain' ), - 'desc' => __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'tag-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_taxonomy_checkbox', - 'label' => __( 'Taxonomy Checkbox', 'theme-text-domain' ), - 'desc' => __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'taxonomy-checkbox', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => 'category,post_tag', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_taxonomy_select', - 'label' => __( 'Taxonomy Select', 'theme-text-domain' ), - 'desc' => __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'taxonomy-select', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => 'category,post_tag', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_text', - 'label' => __( 'Text', 'theme-text-domain' ), - 'desc' => __( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'text', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_textarea', - 'label' => __( 'Textarea', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %s, %s, %s, and %s.', 'theme-text-domain' ), 'wpautop', 'media_buttons', 'tinymce', 'quicktags' ), - 'std' => '', - 'type' => 'textarea', - 'section' => 'option_types', - 'rows' => '15', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_textarea_simple', - 'label' => __( 'Textarea Simple', 'theme-text-domain' ), - 'desc' => __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'textarea-simple', - 'section' => 'option_types', - 'rows' => '10', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_textblock', - 'label' => __( 'Textblock', 'theme-text-domain' ), - 'desc' => __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'textblock', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_textblock_titled', - 'label' => __( 'Textblock Titled', 'theme-text-domain' ), - 'desc' => __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ), - 'std' => '', - 'type' => 'textblock-titled', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_typography', - 'label' => __( 'Typography', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %s to remove unwanted fields from all Background options or an individual one. You can also filter %s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), 'ot_get_option()', 'ot_recognized_typography_fields', 'ot_recognized_font_families, ot_recognized_font_sizes, ot_recognized_font_styles, ot_recognized_font_variants, ot_recognized_font_weights, ot_recognized_letter_spacing, ot_recognized_line_heights, ot_recognized_text_decorations ' . __( 'and', 'theme-text-domain' ) . ' ot_recognized_text_transformations' ), - 'std' => '', - 'type' => 'typography', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_upload', - 'label' => __( 'Upload', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %s any media to your new server and change the URIs if necessary.', 'theme-text-domain' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'theme-text-domain' ) ), 'FTP' ), - 'std' => '', - 'type' => 'upload', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => '', - 'condition' => '', - 'operator' => 'and' - ), - array( - 'id' => 'demo_upload_attachment_id', - 'label' => __( 'Upload Attachment ID', 'theme-text-domain' ), - 'desc' => sprintf( __( 'The Upload option type can also be saved as an attachment ID by adding %s to the class attribute.', 'theme-text-domain' ), 'ot-upload-attachment-id' ), - 'std' => '', - 'type' => 'upload', - 'section' => 'option_types', - 'rows' => '', - 'post_type' => '', - 'taxonomy' => '', - 'min_max_step'=> '', - 'class' => 'ot-upload-attachment-id', - 'condition' => '', - 'operator' => 'and' - ) - ) - ); - - /* allow settings to be filtered before saving */ - $custom_settings = apply_filters( ot_settings_id() . '_args', $custom_settings ); - - /* settings are not the same update the DB */ - if ( $saved_settings !== $custom_settings ) { - update_option( ot_settings_id(), $custom_settings ); - } - - /* Lets OptionTree know the UI Builder is being overridden */ - global $ot_has_custom_theme_options; - $ot_has_custom_theme_options = true; - -} \ No newline at end of file + 'type' => 'css', + 'section' => 'option_types', + 'rows' => '20', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_custom_post_type_checkbox', + 'label' => __( 'Custom Post Type Checkbox', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It allows the user to check multiple post IDs for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), 'post_type' ), + 'std' => '', + 'type' => 'custom-post-type-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => 'post', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_custom_post_type_select', + 'label' => __( 'Custom Post Type Select', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Custom Post Type Select option type displays a list of IDs from any available WordPress post type or custom post type. It will return a single post ID for use in a custom function or loop. Requires at least one valid %1$s in the %1$s field.', 'theme-text-domain' ), 'post_type' ), + 'std' => '', + 'type' => 'custom-post-type-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => 'post', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_date_picker', + 'label' => __( 'Date Picker', 'theme-text-domain' ), + 'desc' => __( 'The Date Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date when focus is given to the input field. The returned value is a date formatted string.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'date-picker', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_date_time_picker', + 'label' => __( 'Date Time Picker', 'theme-text-domain' ), + 'desc' => __( 'The Date Time Picker option type is tied to a standard form input field which displays a calendar pop-up that allow the user to pick any date and time when focus is given to the input field. The returned value is a date and time formatted string.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'date-time-picker', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_dimension', + 'label' => __( 'Dimension', 'theme-text-domain' ), + 'desc' => __( 'The Dimension option type is used to set width and height values.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'dimension', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_gallery', + 'label' => __( 'Gallery', 'theme-text-domain' ), + 'desc' => __( 'The Gallery option type saves a comma separated list of image attachment IDs. You will need to create a front-end function to display the images in your theme.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'gallery', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_gallery_shortcode', + 'label' => __( 'Gallery Shortcode', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Gallery option type can also be saved as a shortcode by adding %s to the class attribute. Using the Gallery option type in this manner will result in a better user experience as you\'re able to save the link, column, and order settings.', 'theme-text-domain' ), 'ot-gallery-shortcode' ), + 'std' => '', + 'type' => 'gallery', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => 'ot-gallery-shortcode', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_google_fonts', + 'label' => __( 'Google Fonts', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Google Fonts option type will dynamically enqueue any number of Google Web Fonts into the document %1$s. As well, once the option has been saved each font family will automatically be inserted into the %2$s array for the Typography option type. You can further modify the font stack by using the %3$s filter, which is passed the %4$s, %5$s, and %6$s parameters. The %6$s parameter is being passed from %7$s, so it will be the ID of a Typography option type. This will allow you to add additional web safe fonts to individual font families on an as-need basis.', 'theme-text-domain' ), 'HEAD', 'font-family', 'ot_google_font_stack', '$font_stack', '$family', '$field_id', 'ot_recognized_font_families' ), + 'std' => array( + array( + 'family' => 'opensans', + 'variants' => array( '300', '300italic', 'regular', 'italic', '600', '600italic' ), + 'subsets' => array( 'latin' ), + ), + ), + 'type' => 'google-fonts', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_javascript', + 'label' => __( 'JavaScript', 'theme-text-domain' ), + 'desc' => '

      ' . sprintf( __( 'The JavaScript option type is a textarea that uses the %s code editor to highlight your JavaScript and display errors as you type.', 'theme-text-domain' ), 'ace.js' ) . '

      ', + 'std' => '', + 'type' => 'javascript', + 'section' => 'option_types', + 'rows' => '20', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_link_color', + 'label' => __( 'Link Color', 'theme-text-domain' ), + 'desc' => __( 'The Link Color option type is used to set all link color states.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'link-color', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_list_item', + 'label' => __( 'List Item', 'theme-text-domain' ), + 'desc' => __( 'The List Item option type allows for a great deal of customization. You can add settings to the List Item and those settings will be displayed to the user when they add a new List Item. Typical use is for creating sliding content or blocks of code for custom layouts.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'list-item', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + 'settings' => array( + array( + 'id' => 'demo_list_item_content', + 'label' => __( 'Content', 'theme-text-domain' ), + 'desc' => '', + 'std' => '', + 'type' => 'textarea-simple', + 'rows' => '10', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + ), + ), + array( + 'id' => 'demo_measurement', + 'label' => __( 'Measurement', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Measurement option type is a mix of input and select fields. The text input excepts a value and the select lets you choose the unit of measurement to add to that value. Currently the default units are %1$s, %2$s, %3$s, and %4$s. However, you can change them with the %5$s filter.', 'theme-text-domain' ), 'px', '%', 'em', 'pt', 'ot_measurement_unit_types' ), + 'std' => '', + 'type' => 'measurement', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_numeric_slider', + 'label' => __( 'Numeric Slider', 'theme-text-domain' ), + 'desc' => __( 'The Numeric Slider option type displays a jQuery UI slider. It will return a single numerical value for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'numeric-slider', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '-500,5000,100', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_on_off', + 'label' => __( 'On/Off', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The On/Off option type displays a simple switch that can be used to turn things on or off. The saved return value is either %1$s or %2$s.', 'theme-text-domain' ), 'on', 'off' ), + 'std' => '', + 'type' => 'on-off', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_page_checkbox', + 'label' => __( 'Page Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Page Checkbox option type displays a list of page IDs. It allows the user to check multiple page IDs for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'page-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_page_select', + 'label' => __( 'Page Select', 'theme-text-domain' ), + 'desc' => __( 'The Page Select option type displays a list of page IDs. It will return a single page ID for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'page-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_post_checkbox', + 'label' => __( 'Post Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Post Checkbox option type displays a list of post IDs. It allows the user to check multiple post IDs for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'post-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_post_select', + 'label' => __( 'Post Select', 'theme-text-domain' ), + 'desc' => __( 'The Post Select option type displays a list of post IDs. It will return a single post ID for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'post-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_radio', + 'label' => __( 'Radio', 'theme-text-domain' ), + 'desc' => __( 'The Radio option type displays a group of choices. It allows the user to choose one and will return that value as a string for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'radio', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + 'choices' => array( + array( + 'value' => 'yes', + 'label' => __( 'Yes', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'no', + 'label' => __( 'No', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'maybe', + 'label' => __( 'Maybe', 'theme-text-domain' ), + 'src' => '', + ), + ), + ), + array( + 'id' => 'demo_radio_image', + 'label' => __( 'Radio Image', 'theme-text-domain' ), + 'desc' => sprintf( __( 'the Radio Images option type is primarily used for layouts. However, you can filter the image list using %s. As well, you can add your own custom images using the choices array.', 'theme-text-domain' ), 'ot_radio_images' ), + 'std' => 'right-sidebar', + 'type' => 'radio-image', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_select', + 'label' => __( 'Select', 'theme-text-domain' ), + 'desc' => __( 'The Select option type is used to list anything you want that would be chosen from a select list.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + 'choices' => array( + array( + 'value' => '', + 'label' => __( '-- Choose One --', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'yes', + 'label' => __( 'Yes', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'no', + 'label' => __( 'No', 'theme-text-domain' ), + 'src' => '', + ), + array( + 'value' => 'maybe', + 'label' => __( 'Maybe', 'theme-text-domain' ), + 'src' => '', + ), + ), + ), + array( + 'id' => 'demo_sidebar_select', + 'label' => __( 'Sidebar Select', 'theme-text-domain' ), + 'desc' => '

      ' . sprintf( __( 'This option type makes it possible for users to select a WordPress registered sidebar to use on a specific area. By using the two provided filters, %1$s, and %2$s we can be selective about which sidebars are available on a specific content area.', 'theme-text-domain' ), 'ot_recognized_sidebars', 'ot_recognized_sidebars_{$field_id}' ) . '

      ' . sprintf( __( 'For example, if we create a WordPress theme that provides the ability to change the Blog Sidebar and we don\'t want to have the footer sidebars available on this area, we can unset those sidebars either manually or by using a regular expression if we have a common name like %s.', 'theme-text-domain' ), 'footer-sidebar-$i' ) . '

      ', + 'std' => '', + 'type' => 'sidebar-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_social_links', + 'label' => __( 'Social Links', 'theme-text-domain' ), + 'desc' => '

      ' . sprintf( __( 'The Social Links option type utilizes a drag & drop interface to create a list of social links. There are a few filters that make extending this option type easy. You can set the %1$s filter to %2$s and turn off loading default values. Use the %3$s filter to change the default values that are loaded. To filter the settings array use the %4$s filter.', 'theme-text-domain' ), 'ot_type_social_links_load_defaults', 'false', 'ot_type_social_links_defaults', 'ot_social_links_settings' ) . '

      ', + 'std' => '', + 'type' => 'social-links', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_spacing', + 'label' => __( 'Spacing', 'theme-text-domain' ), + 'desc' => __( 'The Spacing option type is used to set spacing values such as padding or margin in the form of top, right, bottom, and left.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'spacing', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_tag_checkbox', + 'label' => __( 'Tag Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Tag Checkbox option type displays a list of tag IDs. It allows the user to check multiple tag IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'tag-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_tag_select', + 'label' => __( 'Tag Select', 'theme-text-domain' ), + 'desc' => __( 'The Tag Select option type displays a list of tag IDs. It allows the user to select only one tag ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'tag-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_taxonomy_checkbox', + 'label' => __( 'Taxonomy Checkbox', 'theme-text-domain' ), + 'desc' => __( 'The Taxonomy Checkbox option type displays a list of taxonomy IDs. It allows the user to check multiple taxonomy IDs and will return that value as an array for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'taxonomy-checkbox', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => 'category,post_tag', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_taxonomy_select', + 'label' => __( 'Taxonomy Select', 'theme-text-domain' ), + 'desc' => __( 'The Taxonomy Select option type displays a list of taxonomy IDs. It allows the user to select only one taxonomy ID and will return that value for use in a custom function or loop.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'taxonomy-select', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => 'category,post_tag', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_text', + 'label' => __( 'Text', 'theme-text-domain' ), + 'desc' => __( 'The Text option type is used to save string values. For example, any optional or required text that is of reasonably short character length.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'text', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_textarea', + 'label' => __( 'Textarea', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Textarea option type is a large string value used for custom code or text in the theme and has a WYSIWYG editor that can be filtered to change the how it is displayed. For example, you can filter %1$s, %2$s, %3$s, and %4$s.', 'theme-text-domain' ), 'wpautop', 'media_buttons', 'tinymce', 'quicktags' ), + 'std' => '', + 'type' => 'textarea', + 'section' => 'option_types', + 'rows' => '15', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_textarea_simple', + 'label' => __( 'Textarea Simple', 'theme-text-domain' ), + 'desc' => __( 'The Textarea Simple option type is a large string value used for custom code or text in the theme. The Textarea Simple does not have a WYSIWYG editor.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'textarea-simple', + 'section' => 'option_types', + 'rows' => '10', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_textblock', + 'label' => __( 'Textblock', 'theme-text-domain' ), + 'desc' => __( 'The Textblock option type is used only on the Theme Option page. It will allow you to create & display HTML, but has no title above the text block. You can then use the Textblock to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'textblock', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_textblock_titled', + 'label' => __( 'Textblock Titled', 'theme-text-domain' ), + 'desc' => __( 'The Textblock Titled option type is used only on the Theme Option page. It will allow you to create & display HTML, and has a title above the text block. You can then use the Textblock Titled to add a more detailed set of instruction on how the options are used in your theme. You would never use this in your themes template files as it does not save a value.', 'theme-text-domain' ), + 'std' => '', + 'type' => 'textblock-titled', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_typography', + 'label' => __( 'Typography', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Typography option type is for adding typography styles to your theme either dynamically via the CSS option type above or manually with %1$s. The Typography option type has filters that allow you to remove fields or change the defaults. For example, you can filter %2$s to remove unwanted fields from all Background options or an individual one. You can also filter %3$s. These filters allow you to fine tune the select lists for your specific needs.', 'theme-text-domain' ), 'ot_get_option()', 'ot_recognized_typography_fields', 'ot_recognized_font_families, ot_recognized_font_sizes, ot_recognized_font_styles, ot_recognized_font_variants, ot_recognized_font_weights, ot_recognized_letter_spacing, ot_recognized_line_heights, ot_recognized_text_decorations ' . __( 'and', 'theme-text-domain' ) . ' ot_recognized_text_transformations' ), + 'std' => '', + 'type' => 'typography', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_upload', + 'label' => __( 'Upload', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Upload option type is used to upload any WordPress supported media. After uploading, users are required to press the "%1$s" button in order to populate the input with the URI of that media. There is one caveat of this feature. If you import the theme options and have uploaded media on one site the old URI will not reflect the URI of your new site. You will have to re-upload or %2$s any media to your new server and change the URIs if necessary.', 'theme-text-domain' ), apply_filters( 'ot_upload_text', __( 'Send to OptionTree', 'theme-text-domain' ) ), 'FTP' ), + 'std' => '', + 'type' => 'upload', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => '', + 'condition' => '', + 'operator' => 'and', + ), + array( + 'id' => 'demo_upload_attachment_id', + 'label' => __( 'Upload Attachment ID', 'theme-text-domain' ), + 'desc' => sprintf( __( 'The Upload option type can also be saved as an attachment ID by adding %s to the class attribute.', 'theme-text-domain' ), 'ot-upload-attachment-id' ), + 'std' => '', + 'type' => 'upload', + 'section' => 'option_types', + 'rows' => '', + 'post_type' => '', + 'taxonomy' => '', + 'min_max_step' => '', + 'class' => 'ot-upload-attachment-id', + 'condition' => '', + 'operator' => 'and', + ), + ), + ); + + // Allow settings to be filtered before saving. + $custom_settings = apply_filters( ot_settings_id() . '_args', $custom_settings ); + + // Settings are not the same update the DB. + if ( $saved_settings !== $custom_settings ) { + update_option( ot_settings_id(), $custom_settings ); + } + + // Lets OptionTree know the UI Builder is being overridden. + global $ot_has_custom_theme_options; + $ot_has_custom_theme_options = true; +} From 30701c8e4b3e42718e129052284ad46011a790eb Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 10:56:08 -0700 Subject: [PATCH 66/67] Ensure WP is loaded before adding notice --- ot-loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ot-loader.php b/ot-loader.php index 5ec2c29..f8f0c57 100755 --- a/ot-loader.php +++ b/ot-loader.php @@ -12,7 +12,7 @@ * @package OptionTree */ -if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && true === OT_PLUGIN_MODE ) { +if ( class_exists( 'OT_Loader' ) && defined( 'OT_PLUGIN_MODE' ) && true === OT_PLUGIN_MODE && defined( 'ABSPATH' ) ) { add_filter( 'ot_theme_mode', '__return_false', 999 ); From ac9c71016eb0b53b57358353f3bd81841ca79a77 Mon Sep 17 00:00:00 2001 From: Derek Herman Date: Tue, 16 Apr 2019 10:59:55 -0700 Subject: [PATCH 67/67] Ignore demo files during Travis build --- .dev-lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dev-lib b/.dev-lib index fbe32b5..306159c 100644 --- a/.dev-lib +++ b/.dev-lib @@ -1,4 +1,4 @@ DEFAULT_BASE_BRANCH=develop -PHPCS_IGNORE='vendor/*,tests/wp-tests/*' +PHPCS_IGNORE='vendor/*,tests/wp-tests/*,assets/theme-mode/*' CHECK_SCOPE=patches DEV_LIB_SKIP=phpunit