Changeset 1532717
- Timestamp:
- 11/12/2016 03:31:57 AM (9 years ago)
- Location:
- tea-page-content
- Files:
-
- 6 added
- 17 edited
-
tags/1.2.2/config.map.php (added)
-
tags/1.2.2/readme.ru_RU.txt (added)
-
tags/1.2.2/templates/default-settings-page.php (added)
-
trunk/assets/css/tea-page-content-admin.css (modified) (1 diff)
-
trunk/assets/js/tea-page-content-admin-notices.js (modified) (1 diff)
-
trunk/assets/js/tea-page-content-admin.js (modified) (2 diffs)
-
trunk/assets/js/tea-page-content-api.js (modified) (3 diffs)
-
trunk/classes/config.class.php (modified) (5 diffs)
-
trunk/classes/helper.class.php (modified) (8 diffs)
-
trunk/config.map.php (added)
-
trunk/config.php (modified) (4 diffs)
-
trunk/languages/tea-page-content-ru_RU.mo (modified) (previous)
-
trunk/languages/tea-page-content-ru_RU.po (modified) (4 diffs)
-
trunk/modules/shortcode.php (modified) (3 diffs)
-
trunk/modules/widget.php (modified) (3 diffs)
-
trunk/readme.ru_RU.txt (added)
-
trunk/readme.txt (modified) (7 diffs)
-
trunk/tea-page-content.class.php (modified) (14 diffs)
-
trunk/tea-page-content.php (modified) (1 diff)
-
trunk/templates/default-settings-page.php (added)
-
trunk/templates/default-widget-admin-dialog-insert-shortcode.php (modified) (1 diff)
-
trunk/templates/default-widget-admin.php (modified) (1 diff)
-
trunk/uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tea-page-content/trunk/assets/css/tea-page-content-admin.css
r1485276 r1532717 380 380 vertical-align: middle; 381 381 } 382 383 .tpc-settings-page { 384 385 } 386 .tpc-settings-page h2 { 387 margin-bottom: 30px !important; 388 } 389 .tpc-form-group { 390 display: block; 391 margin-top: 10px; 392 } 393 .tpc-form-group:first-child { 394 margin-top: 0; 395 } 396 397 .tpc-form-group { 398 font-size: 1.2em; 399 } 400 401 .tpc-form-group span { 402 margin: 10px 0; 403 } 404 .tpc-form-group small { 405 } 406 .tpc-form-group input, 407 .tpc-form-group select { 408 margin-top: 10px; 409 min-width: 250px; 410 } -
tea-page-content/trunk/assets/js/tea-page-content-admin-notices.js
r1485276 r1532717 5 5 $('#tpc-deprecated-notice .notice-dismiss').one('click', function() { 6 6 jQuery.post(ajaxurl, { 7 'action': 'set_notice_seen', 8 'version': '1.2' 7 'action': 'set_notice_seen' 9 8 }, function(response) {}); 10 9 }); -
tea-page-content/trunk/assets/js/tea-page-content-admin.js
r1485963 r1532717 48 48 'resizable': false, 49 49 'closeText': '', 50 'class': 'tpc-ui-modal-wrapper', 50 51 'buttons': [ 51 52 { … … 59 60 } 60 61 ], 61 'close': API.callbacks.dialog_on_close 62 'close': API.callbacks.dialog_on_close, 63 'open': API.callbacks.dialog_on_open, 62 64 }; 63 65 -
tea-page-content/trunk/assets/js/tea-page-content-api.js
r1485276 r1532717 271 271 272 272 setTimeout(function() { 273 //send_to_editor('Nie wieder stress mit');274 275 273 $preloader.addClass('is-hidden'); 276 274 … … 280 278 }, 500); 281 279 }); 282 283 284 280 }, 285 281 … … 330 326 }, 331 327 328 'dialog_on_open': function(event, ui) { 329 var $dialogWrapper = TeaPageContent_API.storage.get('dialog').parent(); 330 var $window = jQuery(window); 331 332 var topMargin = 30; 333 334 if($window.height() >= $dialogWrapper.height() - topMargin) { 335 $dialogWrapper.css('margin-top', topMargin + 'px'); 336 } 337 }, 338 332 339 'media_on_select': function() { 333 340 var $this = jQuery(this); -
tea-page-content/trunk/classes/config.class.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 7 7 class TeaPageContent_Config { 8 8 private static $_instance; 9 9 10 private $_config; 11 private $_helper; 12 private $_map; 10 13 11 14 /** … … 28 31 */ 29 32 private static function initialize() { 30 $config = include(TEA_PAGE_CONTENT_PATH . '/config.php'); 33 $config = require_once(TEA_PAGE_CONTENT_PATH . '/config.php'); 34 $map = require_once(TEA_PAGE_CONTENT_PATH . '/config.map.php'); 35 36 // Create new helper instance 37 self::$_instance->_helper = new TeaPageContent_Helper; 31 38 32 39 if(is_array($config)) { 33 40 self::$_instance->_config = apply_filters('tpc_config_array', $config); 41 42 if(is_array($map)) { 43 self::$_instance->_map = apply_filters('tpc_config_map_array', $map); 44 } 34 45 35 46 unset($config); … … 58 69 59 70 /** 71 * Return the config map which load previously. 72 * 73 * @return array 74 */ 75 public function get_config_map() { 76 return $this->_map; 77 } 78 79 public function sanitizeOption($param, $value) { 80 if(!isset($this->_map[$param])) { 81 return $value; 82 } 83 84 $filter = 'safehtml'; // @todo via config 85 if(isset($this->_map[$param]['filter'])) { 86 $filter = $this->_map[$param]['filter']; 87 } 88 89 switch ($filter) { 90 case 'safehtml': 91 $value = htmlspecialchars($value); 92 break; 93 case 'string': 94 $value = htmlspecialchars(strip_tags($value)); 95 break; 96 } 97 98 return addslashes($value); 99 } 100 101 /** 60 102 * Public getter. Returns a config parameter, 61 103 * if it exists. In other case returns null. … … 63 105 * @param string $params Dot-separated path to needly parameter 64 106 * @param string|array $except Determine parameters that will be excluded 107 * @param boolean $use_option If true, checking for existed self-titled option and return option value 65 108 * 66 109 * @return mixed|null 67 110 */ 68 public function get($param, $except = null ) {111 public function get($param, $except = null, $use_option = false) { 69 112 $pieces = explode('.', $param); 70 113 $piecesCount = count($pieces); 71 114 72 115 $result = null; 116 117 // Force result find. If we use options, find in database and return result if finded. 118 // Please note, excerpts are not supported in options now. 119 if($use_option) { 120 $alias = $this->_helper->convertConfigPathToSetting($param); // @todo make dis shit dry {4} 121 122 if(!is_null($result = get_option($alias, null))) { 123 return $this->sanitizeOption($param, $result); 124 } 125 } 126 127 // If not, find in config stack. 73 128 $stack = $this->_config; 74 129 for ($i = 0; $i <= $piecesCount; $i++) { … … 93 148 return $result; 94 149 } 150 151 public function get_current($param) { 152 return $this->get($param, null, true); 153 } 154 155 public function get_default($param, $except = null) { 156 return $this->get($param, $except, false); 157 } 95 158 } -
tea-page-content/trunk/classes/helper.class.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 130 130 } 131 131 132 // Filter by post status... 133 if(!isset($params['post_status'])) { 134 $params['post_status'] = $this->_config->get_current('defaults.posts.post_status'); 135 } 136 137 // ...and by protected settings too 138 if(!isset($params['has_password'])) { 139 $params['has_password'] = $this->_config->get_current('defaults.posts.has_password'); 140 } 141 132 142 // Filter param array 133 143 $params = apply_filters('tpc_post_params', $params); … … 353 363 } 354 364 365 /** 366 * Get page variables from global (passed) array for one specified entry. 367 * 368 * @param array $page_variables 369 * @param int|null $entry_id 370 * @return array 371 */ 355 372 public function getPageVariables($page_variables, $entry_id = null) { 356 373 $result = array(); … … 381 398 } 382 399 400 /** 401 * Remove prefix before merging page variables with entry properties. 402 * Need this because page variables should override some properties of entry. 403 * 404 * @param array $page_variables 405 * @return array 406 */ 383 407 public function preparePageVariablesForMerge($page_variables) { 384 408 $page_var_prefix = $this->_config->get('system.page-variables.prefix'); … … 468 492 $exploded[1] = wp_get_attachment_url($exploded[1]); 469 493 } else { 470 $exploded[1] = wp_get_attachment_image($exploded[1], 'post-thumbnail'); // @todo в конфиг 494 $thumbnail_size = 'post-thumbnail'; // @todo в конфиг 495 $thumbnail_size = apply_filters('tpc_thumbnail_size', $thumbnail_size, $exploded[1], $entry_id); 496 497 $exploded[1] = wp_get_attachment_image($exploded[1], $thumbnail_size); 471 498 } 472 499 } … … 492 519 * @return array 493 520 */ 494 public function extractPageVariables($attrs, $ apply_rules = true) {521 public function extractPageVariables($attrs, $entry_id = null, $apply_rules = true) { 495 522 $existed_variables = $this->_config->get('defaults.page-variables'); 496 523 … … 506 533 $value = wp_get_attachment_url($value); 507 534 } else { 508 $value = wp_get_attachment_image($value, 'post-thumbnail'); // @todo в конфиг 535 $thumbnail_size = 'post-thumbnail'; // @todo в конфиг 536 $thumbnail_size = apply_filters('tpc_thumbnail_size', $thumbnail_size, $value, $entry_id); 537 538 $value = wp_get_attachment_image($value, $thumbnail_size); 509 539 } 510 540 } … … 551 581 return $templates; 552 582 } 583 584 public function getMappedSettings() { 585 $result = array(); 586 587 $map = $this->_config->get_config_map(); 588 589 foreach ($map as $config_path => $params) { 590 $alias = $this->convertConfigPathToSetting($config_path); 591 592 $default_value = $this->_config->get_current($config_path); 593 594 $params['default'] = $default_value; 595 596 $result[$alias] = $params; 597 } 598 599 return $result; 600 } 601 602 public function convertSettingToConfigPath($setting) { 603 if(!is_string($setting)) { 604 return false; 605 } 606 607 return str_replace(array('tpc_', '__'), array('', '.'), $setting); // @todo make dis shit dry {4} 608 // get tpc_ via config 609 } 610 611 public function convertConfigPathToSetting($config_path) { 612 if(!is_string($config_path)) { 613 return false; 614 } 615 616 return 'tpc_' . str_replace('.', '__', $config_path); 617 } 618 619 public function updateDeprecatedNoticeOption() { 620 $version = $this->_config->get('system.versions.plugin'); 621 622 if(!get_option('tpc_deprecated_notice')) { 623 add_option('tpc_deprecated_notice', $version, '', 'no'); 624 } else { 625 update_option('tpc_deprecated_notice', $version, 'no'); 626 } 627 } 553 628 } -
tea-page-content/trunk/config.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 37 37 ), 38 38 'post-types' => array( 39 'public' => true 39 'public' => true, 40 ), 41 'posts' => array( 42 'post_status' => 'publish', // may be an array too 43 'has_password' => false, 40 44 ), 41 45 'template-variables' => array( … … 62 66 'system' => array( 63 67 'posts' => array( 64 'types-operator' => 'or' 68 'types-operator' => 'or', 65 69 ), 66 70 'predefined-templates' => array( … … 78 82 'template-directories' => array( 79 83 'plugin' => TEA_PAGE_CONTENT_PATH . '/templates/', 80 'theme' => get_ template_directory() . '/templates/'84 'theme' => get_stylesheet_directory() . '/templates/' 81 85 ), 82 86 'versions' => array( 83 'plugin' => '1.2.0', 84 'scripts' => '1.2', 85 'styles' => '1.2' 86 ) 87 'plugin' => '1.2.2', 88 'scripts' => '1.2.2', 89 'styles' => '1.2.2' 90 ), 91 92 'settings' => array( 93 'include-css' => true, 94 ), 87 95 ) 88 96 ); -
tea-page-content/trunk/languages/tea-page-content-ru_RU.po
r1485276 r1532717 6 6 "Project-Id-Version: tea-page-content\n" 7 7 "Report-Msgid-Bugs-To: Translator Name <[email protected]>\n" 8 "POT-Creation-Date: 2016- 08-29 00:27+0400\n"8 "POT-Creation-Date: 2016-11-11 20:13+0400\n" 9 9 "PO-Revision-Date: \n" 10 10 "Last-Translator: \n" … … 25 25 "X-Poedit-SearchPath-0: .\n" 26 26 27 #: config.php:48 templates/default-widget-admin-dialog-insert-shortcode.php:6 27 #: config.map.php:9 28 msgid "Enable plugin's CSS?" 29 msgstr "Включить CSS плагина?" 30 31 #: config.map.php:10 32 msgid "" 33 "You can exclude css of plugin from output if you do not use default " 34 "templates." 35 msgstr "" 36 "Вы можете отключить css плагина, если вы не используете стандартные шаблоны." 37 38 #: config.php:52 templates/default-widget-admin-dialog-insert-shortcode.php:6 28 39 #: templates/default-widget-admin.php:5 29 40 msgid "Title" 30 41 msgstr "Заголовок" 31 42 32 #: config.php:5 243 #: config.php:56 33 44 msgid "Content" 34 45 msgstr "Контент" 35 46 36 #: config.php: 5647 #: config.php:60 37 48 msgid "Thumbnail" 38 49 msgstr "Миниатюра" 39 50 40 #: modules/widget.php:27 51 #: modules/widget.php:27 tea-page-content.class.php:110 41 52 msgid "Tea Page Content" 42 53 msgstr "Tea Page Content" … … 46 57 msgstr "Позволяет отображать любой контент любой записи." 47 58 48 #: tea-page-content.class.php:67 59 #: tea-page-content.class.php:88 templates/default-settings-page.php:2 60 msgid "Settings" 61 msgstr "Настройки" 62 63 #: tea-page-content.class.php:101 49 64 msgid "Tea Page Content Shortcode" 50 65 msgstr "Шорткод Tea Page Content" 51 66 52 #: tea-page-content.class.php:377 67 #: tea-page-content.class.php:110 68 msgid "Tea Page Content - Settings" 69 msgstr "" 70 71 #: tea-page-content.class.php:437 53 72 msgid "" 54 "Thanks for update! In Tea Page Content 1.2 was added some new features. We"55 " recommend you check out the <a href=\"https://wordpress.org/plugins/tea-page-"56 " content/changelog/\">changelog</a>. <b>This notice appears only once!</b>"73 "Thanks for update! We recommend you check out the <a href=\"https://" 74 "wordpress.org/plugins/tea-page-content/changelog/\">changelog</a>. <b>This " 75 "notice appears only one time.</b>" 57 76 msgstr "" 58 "Спасибо за обновление! В Tea Page Content 1.2 были добавлены новые " 59 "возможности. Мы рекомендуем ознакомиться с ними в <a href=\"https://" 60 "wordpress.org/plugins/tea-page-content/changelog/\">логе изменений</a>. " 61 "<b>Это сообщение появляется только один раз!</b>" 77 "Спасибо за обновление! Мы рекомендуем просмотреть <a href=\"https://" 78 "wordpress.org/plugins/tea-page-content/changelog/\">список обновлений</a>. " 79 "<b>Это уведомление появляется лишь один раз.</b>" 80 81 #: templates/default-settings-page.php:27 82 msgid "Yes" 83 msgstr "Да" 84 85 #: templates/default-settings-page.php:28 86 msgid "No" 87 msgstr "Нет" 88 89 #: templates/default-settings-page.php:51 90 msgid "Submit" 91 msgstr "Отправить" 62 92 63 93 #: templates/default-widget-admin-dialog-insert-shortcode.php:16 … … 135 165 136 166 #~ msgid "" 167 #~ "Thanks for update! In Tea Page Content 1.2 was added some new features. " 168 #~ "We recommend you check out the <a href=\"https://wordpress.org/plugins/" 169 #~ "tea-page-content/changelog/\">changelog</a>. <b>This notice appears only " 170 #~ "once!</b>" 171 #~ msgstr "" 172 #~ "Спасибо за обновление! В Tea Page Content 1.2 были добавлены новые " 173 #~ "возможности. Мы рекомендуем ознакомиться с ними в <a href=\"https://" 174 #~ "wordpress.org/plugins/tea-page-content/changelog/\">логе изменений</a>. " 175 #~ "<b>Это сообщение появляется только один раз!</b>" 176 177 #~ msgid "" 137 178 #~ "Warning! Since Tea Page Content 1.1 some parameters is <b>deprecated</b>, " 138 179 #~ "and will be <b>deleted</b> in the next release. We strongly recommend you " -
tea-page-content/trunk/modules/shortcode.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 104 104 105 105 foreach ($current_posts as $current_post_id) { 106 107 $pageVariables[(int)$current_post_id] = $helper->extractPageVariables($innerAttrs); 106 $pageVariables[(int)$current_post_id] = $helper->extractPageVariables($innerAttrs, (int)$current_post_id); 108 107 } 109 108 … … 130 129 $params = array_merge($params, $helper->getParams($attrs, 'flatten')); 131 130 132 133 131 134 132 } else { // If we haven't content. It means that this is usual shortcode 133 135 134 136 135 // Pre-create template variables, if exists -
tea-page-content/trunk/modules/widget.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 126 126 127 127 foreach ($newInstance[$param] as $page_id => $variable_data) { 128 129 if(trim($variable_data)) { 130 $parsed_data = $this->_helper->decodePageVariables($variable_data, null, false); 131 132 if(empty($parsed_data)) { 133 continue; 134 } 135 128 if(!trim($variable_data)) { // If raw variable data is not empty... 129 continue; 130 } 131 132 // try to parse it for check values of every variable... 133 $parsed_data = $this->_helper->decodePageVariables($variable_data, null, false); 134 135 // ... and, if parsed data is not empty, save page vars 136 if(!empty($parsed_data)) { 136 137 $instance['page_variables'][$page_id] = $variable_data; 138 } else { 139 // if empty, unset page vars 140 unset($instance['page_variables'][$page_id]); 137 141 } 138 139 142 } 140 143 } … … 146 149 147 150 /** 148 * Creates and render a form for 149 * admin part of this widget 151 * Creates and render a form for admin part of this widget 150 152 * 151 153 * @param array $instance -
tea-page-content/trunk/readme.txt
r1485963 r1532717 1 === Tea Page Widget &Content ===1 === Tea Page Content === 2 2 Contributors: Tsjuder 3 3 Tags: plugin, widget, shortcode, posts, post, pages, page, content, template, templates 4 4 Requires at least: 4.0, PHP 5.3 5 5 Tested up to: 4.6 6 Stable tag: 1.2. 16 Stable tag: 1.2.2 7 7 Author URI: https://github.com/Tsjuder 8 8 Plugin URI: http://tsjuder.github.io/tea-page-content/ … … 23 23 * Easy to use and beautiful UI 24 24 25 = Migration Guides =26 Stay tuned with new versions. For make updates safe and fast, check changelog at <a href="https://wordpress.org/plugins/tea-page-content/changelog/">Changelog</a> tab.27 28 25 If you found a bug or have a suggestion, please create topic on forum or send me email (raymondcostner at gmail.com). 29 26 … … 37 34 38 35 == Screenshots == 39 1. Widget UI. Click by gear for open page level variables modal 40 2. Page level variables window (opens after clicking by gear) 41 3. Insert shortcode modal window 36 1. First screen with list of posts and basic parameters 37 2. Second screen after choosing template and list of template variables 42 38 43 39 == Frequently Asked Questions == … … 63 59 64 60 == Changelog == 65 66 = 1.2.1 = 61 = 1.2.1 67 62 * \* Fix bug with non-opening modal window of page level variables 68 63 69 = 1.2.0 =64 = 1.2.0 70 65 * \+ New feature - page-level variables 71 66 * \+ Added button for inserting shortcode in editor … … 86 81 * \+ New template: Bootstrap 3.x 87 82 * \+ Added possibility hide title, content and link it. This feature depends of used template (all built-in templates except deprecated supports it) 88 * \- Default-Padded template, `thumbnail` widget and shortcode parameter, `id` shortcode parameter is **deprecated** . See docs for migration guide89 * \* CSS for frontend part changed, improved paddings, add shover effects83 * \- Default-Padded template, `thumbnail` widget and shortcode parameter, `id` shortcode parameter is **deprecated** 84 * \* CSS for frontend part changed, improved paddings, added some hover effects 90 85 * \* Global code refactoring. We are friendly for developers! 91 86 * \* Bug fixes … … 135 130 * **$count** - Count of all passed entries 136 131 * **$instance** - Array with user defined and default parameters. There is all list of options from self-titled section above. 132 * **$template_variables** - Array with template-level variables. 133 * **$caller** - Special flag that determine a module that called template: from widget or from shortcode. Can be `widget` or `shortcode`. 137 134 * **$entries** - List of posts, pages, etc. 138 135 * **title** - Title of current entry … … 142 139 * **id** - Entry ID 143 140 144 = Details =141 = Details & Filters = 145 142 Because full manual is too long, you can see it at <a href="http://tsjuder.github.io/tea-page-content/">Github Page</a>. Get details and updating information about new features includes filters, template-level variables and more. 146 147 = Migration Guide =148 **From 1.0.x to 1.1.x**149 Since 1.1.x, nothing was deleted. But some options was marked as deprecated. We recommend do these steps:150 * If you're using **default padded** template, change it on **default** with layout what you prefer.151 * If you're using shortcodes, replace parameter `id` to `posts`.152 * If you're using widgets with **turned off** thumbnail option, re-save each of it. -
tea-page-content/trunk/tea-page-content.class.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 28 28 add_action('init', array($this, 'registerShortcodes')); 29 29 add_action('widgets_init', array($this, 'registerWidgets')); 30 31 add_action('init', array($this, 'updateSettings')); 30 32 31 33 // Modify Admin page … … 51 53 add_action('media_buttons', array($this, 'add_my_media_button'), 1000); 52 54 53 // At first time notice user about possible migration54 if(!get_option('tpc_deprecated_notice')) { 55 add_action('admin_notices', array($this, 'displayDeprecatedNotice'));56 } 55 add_action('admin_menu', array($this, 'addMenu'), 100); 56 57 add_filter('plugin_row_meta', array($this, 'addPluginMetaLinks'), 100, 2); 58 57 59 58 60 // Create new helper instance … … 61 63 // Gets instance of the config class 62 64 $this->_config = TeaPageContent_Config::getInstance(); 63 } 64 65 66 67 // At first time notice user about possible migration 68 if 69 ( 70 ($last_version = get_option('tpc_deprecated_notice')) 71 && 72 $last_version !== $this->_config->get('system.versions.plugin') 73 ) 74 { 75 add_action('admin_notices', array($this, 'displayDeprecatedNotice')); 76 } 77 } 78 79 /** 80 * Add meta-link in plugin description on plugin list page. 81 * 82 * @param array $links 83 * @param string $file 84 * @return array 85 */ 86 public function addPluginMetaLinks($links, $file) { 87 if($file == plugin_basename(TEA_PAGE_CONTENT_FILE)) { 88 $links[] = '<a href="options-general.php?page=tea-page-content">' . __('Settings', 'tea-page-content') . '</a>'; 89 } 90 91 return $links; 92 } 93 94 /** 95 * Add button for inserting shortcode above text editor on admin pages. 96 * 97 * @return void 98 */ 65 99 public function add_my_media_button() { 66 100 $mask = '<a href="#" id="tpc-insert-shortcode" data-modal="tpc-call-shortcode-modal" data-button="insert" class="button tpc-button tpc-call-modal-button">%s</a>'; … … 69 103 70 104 /** 105 * Add sub-menu for Options level. 106 * 107 * @return void 108 */ 109 public function addMenu() { 110 add_submenu_page('options-general.php', __('Tea Page Content - Settings', 'tea-page-content'), __('Tea Page Content', 'tea-page-content'), 'edit_dashboard', 'tea-page-content', array($this, 'renderSettingsPage')); 111 } 112 113 /** 71 114 * Register Tea Page Content widget 72 115 * … … 96 139 $url = plugins_url('/assets', TEA_PAGE_CONTENT_FILE); 97 140 98 if($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'edit.php' ) {141 if($hook === 'post.php' || $hook === 'post-new.php' || $hook === 'edit.php' || $hook === 'settings_page_tea-page-content') { 99 142 100 143 wp_enqueue_script( … … 150 193 } 151 194 152 if(!get_option('tpc_deprecated_notice')) { 195 if 196 ( 197 ($last_version = get_option('tpc_deprecated_notice')) 198 && 199 $last_version !== $this->_config->get('system.versions.plugin') 200 ) 201 { 153 202 wp_enqueue_script( 154 203 'tea-page-content-notices-js', … … 170 219 $url = plugins_url('/assets', TEA_PAGE_CONTENT_FILE); 171 220 172 wp_enqueue_style( 173 'tea-page-content-css', 174 $url . '/css/tea-page-content-main.css', 175 array(), 176 $this->_config->get('system.versions.styles'), 177 'all' 178 ); 221 if($this->_config->get_current('system.settings.include-css')) { 222 wp_enqueue_style( 223 'tea-page-content', 224 $url . '/css/tea-page-content-main.css', 225 array(), 226 $this->_config->get('system.versions.styles'), 227 'all' 228 ); 229 } 179 230 } 180 231 … … 193 244 $pair = explode('=', $pair); 194 245 195 $keys = preg_split('/[\[\]]+/', urldecode($pair[0]), -1, PREG_SPLIT_NO_EMPTY);196 197 246 if(!trim($pair[1])) { 198 247 continue; 199 248 } 200 249 250 $keys = preg_split('/[\[\]]+/', urldecode($pair[0]), -1, PREG_SPLIT_NO_EMPTY); 251 252 // $keys[0] is property name (order, page_variables, etc.) 253 // $keys[1] is a page id (as usual) 254 // So, if we haven't property in prepared data, set it up 201 255 if(!array_key_exists($keys[0], $prepared_data)) { 202 256 203 257 if(isset($keys[1])) { 258 // page variables, set it 204 259 $prepared_data[$keys[0]] = array( 205 260 $keys[1] => $pair[1] 206 261 ); 207 262 } else { 263 // just post id, set it too 208 264 $prepared_data[$keys[0]] = array( 209 265 $pair[1] … … 211 267 } 212 268 213 } elseif(isset($keys[1]) && array_key_exists($keys[1], $prepared_data[$keys[0]])) { 214 269 // But, if we have it already and post_id is not in $prepared_data, it means, we set up page variables 270 } elseif(isset($keys[1]) && !array_key_exists($keys[1], $prepared_data[$keys[0]])) { 271 272 // page variables in raw format stored in $pair array 215 273 $prepared_data[$keys[0]][$keys[1]] = $pair[1]; 216 274 275 // And finally, if we haven't property and $keys[1] isn't set... 217 276 } else { 218 277 278 // ...it means, this is just post id that we need set separately 279 // $pair[1] in these times can be just post_id integer 280 // so $keys[0] now is `posts` 219 281 $prepared_data[$keys[0]][] = $pair[1]; 220 282 221 283 } 222 284 } … … 359 421 */ 360 422 public function setNoticeSeenCallback() { 361 $version = $_POST['version']; // @todo get version from config 362 363 if(!get_option('tpc_deprecated_notice')) { 364 add_option('tpc_deprecated_notice', $version, '', 'no'); 365 } 423 $this->_helper->updateDeprecatedNoticeOption(); 366 424 } 367 425 … … 375 433 */ 376 434 public function displayDeprecatedNotice() { 377 $message = __('Thanks for update! In Tea Page Content 1.2 was added some new features. We recommend you check out the <a href="https://wordpress.org/plugins/tea-page-content/changelog/">changelog</a>. <b>This notice appears only once!</b>');435 $message = __('Thanks for update! We recommend you check out the <a href="https://wordpress.org/plugins/tea-page-content/changelog/">changelog</a>. <b>This notice disappear after closing.</b>'); 378 436 $content = '<div id="tpc-deprecated-notice" class="error notice tpc-deprecated-notice is-dismissible"><p>' . $message . '</p></div>'; 379 437 380 438 echo $content; 439 } 440 441 /** 442 * Render settings page. 443 * 444 * @return void 445 */ 446 public function renderSettingsPage() { 447 $params = array( 448 'settings' => $this->_helper->getMappedSettings(), 449 ); 450 451 $template = 'default-settings-page'; // @todo via config 452 453 $templatePath = $this->_helper->getTemplatePath($template); 454 455 echo $this->_helper->renderTemplate($params, $templatePath); 381 456 } 382 457 … … 401 476 } 402 477 478 /** 479 * Print in footer modal window html for inserting shortcode 480 * 481 * @return void 482 */ 403 483 public function addInsertShortcodeModal() { 404 484 $template = 'default-widget-admin-dialog-insert-shortcode'; // @todo через конфиг … … 435 515 echo $content; 436 516 } 517 518 /** 519 * Update settings if POST is not empty 520 * 521 * @return void 522 */ 523 public function updateSettings() { 524 if(!is_admin() || empty($_POST) || !isset($_POST['tpc_settings_update'])) { 525 return; 526 } 527 528 unset($_POST['tpc_settings_update']); 529 530 foreach ($_POST as $setting_name => $setting_value) { 531 if 532 ( 533 strpos($setting_name, 'tpc_') === false // @todo make dis shit dry {4} 534 || 535 preg_match('/[^\w-]/', $setting_name) 536 || 537 !is_scalar($setting_value) 538 ) 539 { 540 continue; 541 } 542 543 $config_path = $this->_helper->convertSettingToConfigPath($setting_name); 544 545 $initial = $this->_config->get_default($config_path); 546 547 if(is_null(get_option($setting_name, null))) { 548 add_option($setting_name, $setting_value, '', 'no'); 549 } elseif($initial == $setting_value) { 550 delete_option($setting_name); 551 } else { 552 update_option($setting_name, $setting_value, 'no'); 553 } 554 } 555 } 437 556 } -
tea-page-content/trunk/tea-page-content.php
r1485967 r1532717 31 31 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 32 32 33 Copyright 201 5 Danil Kosterin33 Copyright 2016 Raymond Costner 34 34 */ 35 35 -
tea-page-content/trunk/templates/default-widget-admin-dialog-insert-shortcode.php
r1485276 r1532717 35 35 <input type="hidden" name="page_variables[<?php echo $postData['id'] ?>]" id="tpc-page_variables-<?php echo $postData['id'] ?>" value="" data-thumbnail-url="" autocomplete="off" /> 36 36 37 <span class="tpc-item-title" ><?php echo $postData['title'] ?></span>37 <span class="tpc-item-title" title="<?php echo $postData['title'] ?>"><?php echo $postData['title'] ?></span> 38 38 </label> 39 39 <?php endforeach; ?> -
tea-page-content/trunk/templates/default-widget-admin.php
r1485276 r1532717 41 41 <input type="hidden" name="<?php echo $bind->get_field_name('page_variables') ?>[<?php echo $postData['id'] ?>]" id="<?php echo $bind->get_field_id('page_variables') . '-' . $postData['id'] ?>" value="<?php echo $raw_page_variables ?>" data-thumbnail-url="<?php echo $data_thumbnail_url ?>" autocomplete="off" /> 42 42 43 <span class="tpc-item-title" ><?php echo $postData['title'] ?></span>43 <span class="tpc-item-title" title="<?php echo $postData['title'] ?>"><?php echo $postData['title'] ?></span> 44 44 </label> 45 45 <?php endforeach; ?> -
tea-page-content/trunk/uninstall.php
r1485963 r1532717 2 2 /** 3 3 * @package Tea Page Content 4 * @version 1.2. 14 * @version 1.2.2 5 5 */ 6 6 … … 8 8 exit(); 9 9 } 10 10 11 $settings_map = include('config.map.php'); 12 13 if(is_array($settings_map) && !empty($settings_map)) { 14 foreach ($settings_map as $setting_name => $setting_params) { 15 $option = 'tpc_' . str_replace('.', '__', $setting_name); 16 17 if(!is_null(get_option($option, null))) { 18 delete_option($option); 19 } 20 } 21 } 22 11 23 delete_option('tpc_deprecated_notice');
Note: See TracChangeset
for help on using the changeset viewer.