From 881baf24a90b38e3c50f3a3b0b6687abc26f025c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Wed, 9 Mar 2016 12:47:07 +0100 Subject: [PATCH 01/19] Oprava KT_Mailer->addRecipient MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + zrušení, reps. náhrada setRecipients->setRecipient --- core/classes/kt_mailer.inc.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/classes/kt_mailer.inc.php b/core/classes/kt_mailer.inc.php index 325d9b8..f20f494 100644 --- a/core/classes/kt_mailer.inc.php +++ b/core/classes/kt_mailer.inc.php @@ -29,7 +29,7 @@ class KT_Mailer { * @throws invalidArgumentException */ public function __construct($recipientEmail, $recipientName = null, $subject = null) { - $this->setRecipients($recipientEmail, $recipientName)->setSubject($subject); + $this->setRecipient($recipientEmail, $recipientName)->setSubject($subject); } // --- gettery ------------------------- @@ -128,7 +128,7 @@ public function setSubject($subject) { } /** - * Nastaví příjemce emailu - nepřidá, pouze setne + * Nastaví jednoho příjemce emailu - nepřidá, pouze setne * Provede validaci emailové adresy * * @author Tomáš Kocifaj @@ -139,7 +139,7 @@ public function setSubject($subject) { * @return \KT_Mailer * @throws InvalidArgumentException */ - public function setRecipients($recipientEmail, $recipientName = null) { + public function setRecipient($recipientEmail, $recipientName = null) { if (self::isEmail($recipientEmail)) { $this->recipients = self::getHeaderEmail($recipientEmail, $recipientName); return $this; @@ -147,6 +147,15 @@ public function setRecipients($recipientEmail, $recipientName = null) { throw new InvalidArgumentException(sprintf(__("Příjemce \"%s\" není platnný e-mail!", "KT_CORE_DOMAIN"), $recipientEmail)); } + /** + * @deprecated since version 1.8 + * @see setRecipient + * @see addRecipient + */ + public function setRecipients($recipientEmail, $recipientName = null) { + $this->setRecipient($recipientEmail, $recipientName); + } + /** * Nastaví jako odesílatele emailu * Provede validaci emailové adresy @@ -260,7 +269,7 @@ public function addRecipient($recipientEmail, $recipientName = null) { if (self::isEmail($recipientEmail)) { $recipients = $this->getRecipients(); $recipients .= "; " . self::getHeaderEmail($recipientEmail, $recipientName); - $this->setRecipients($recipients); + $this->recipients = $recipients; return $this; } throw new InvalidArgumentException(sprintf(__("Příjmence \"%s\" není platnný e-mail!", "KT_CORE_DOMAIN"), $recipientEmail)); From 72015f8075302b19ea73cd1af2f35a91304432d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Tue, 29 Mar 2016 14:31:59 +0200 Subject: [PATCH 02/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20KT=5FMeta=5FMode?= =?UTF-8?q?l=5FBase->getMetaTranslateId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + rozšíření KT_WP_Options_Base_Model->getOptionTranslateId stejným způsobem i možnost pole --- core/models/kt_meta_model_base.inc.php | 24 ++++++++++++++++++++ core/models/kt_wp_options_base_model.inc.php | 10 +++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/core/models/kt_meta_model_base.inc.php b/core/models/kt_meta_model_base.inc.php index b5f41ca..b6d99a4 100644 --- a/core/models/kt_meta_model_base.inc.php +++ b/core/models/kt_meta_model_base.inc.php @@ -70,6 +70,30 @@ public function getMetaValue($key) { return null; } + /** + * Vrátí buď požadované originální nebo "přeložené" ID pro zadaný post type + * (pozn.: dle aktuálního jazyka + zavislé na pluginu WPML) + * + * @param string $key + * @param string $postType + * @return mixed + */ + public function getMetaTranslateId($key, $postType) { + $value = $this->getMetaValue($key); + if (defined("ICL_LANGUAGE_CODE")) { + if (is_array($value)) { + $ids = array(); + foreach ($value as $id) { + array_push($ids, icl_object_id($id, $postType, true, ICL_LANGUAGE_CODE)); + } + return $ids; + } else { + $value = icl_object_id($value, $postType, true, ICL_LANGUAGE_CODE); + } + } + return $value; + } + /** * @deprecated since version 1.3 * @see getMetaValue diff --git a/core/models/kt_wp_options_base_model.inc.php b/core/models/kt_wp_options_base_model.inc.php index a5690df..980ed46 100644 --- a/core/models/kt_wp_options_base_model.inc.php +++ b/core/models/kt_wp_options_base_model.inc.php @@ -164,7 +164,15 @@ public function getOption($name) { public function getOptionTranslateId($name, $postType) { $value = $this->getOption($name); if (defined("ICL_LANGUAGE_CODE")) { - $value = icl_object_id($value, $postType, true, ICL_LANGUAGE_CODE); + if (is_array($value)) { + $ids = array(); + foreach ($value as $id) { + array_push($ids, icl_object_id($id, $postType, true, ICL_LANGUAGE_CODE)); + } + return $ids; + } else { + $value = icl_object_id($value, $postType, true, ICL_LANGUAGE_CODE); + } } return $value; } From 559608c11b4110f3d3ec527ca0a4aafd0d13e377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Thu, 31 Mar 2016 09:36:31 +0200 Subject: [PATCH 03/19] =?UTF-8?q?Zru=C5=A1en=C3=AD=20v=C3=BDchoz=C3=AD=20a?= =?UTF-8?q?uto=20sanitizace,=20resp.=20filtru=20na=20KT=5FWP=5FEditor=5FFi?= =?UTF-8?q?eldu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../classes/fields/kt_wp_editor_field.inc.php | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/core/classes/fields/kt_wp_editor_field.inc.php b/core/classes/fields/kt_wp_editor_field.inc.php index b564573..6ffd3f0 100644 --- a/core/classes/fields/kt_wp_editor_field.inc.php +++ b/core/classes/fields/kt_wp_editor_field.inc.php @@ -1,43 +1,43 @@ setFilterSanitize(FILTER_DEFAULT); } - - // --- gettery a settery --- - - public function getField() { - $this->renderField(); - } - - public function renderField() { - wp_editor( $this->getValue(), $this->getName(), array( - 'media_buttons' => false, - 'textarea_name' => $this->getNameAttribute(), - 'textarea_rows' => 10, - 'teeny' => false, - 'quicktags' => false - )); - } - - public function getFieldType(){ + + // --- gettery a settery --------------------------- + + public function getFieldType() { return self::FIELD_TYPE; } - + protected function getNameAttribute() { - $html = ""; $afterNameString = static::getAfterNameValue(); - if (KT::issetAndNotEmpty($this->getPostPrefix())) { - $html .= "{$this->getPostPrefix()}[{$this->getName()}]$afterNameString"; + return "{$this->getPostPrefix()}[{$this->getName()}]$afterNameString"; } else { - $html .= "{$this->getName()}$afterNameString"; + return "{$this->getName()}$afterNameString"; } - - return $html; } + + public function getField() { + $this->renderField(); + } + + // --- veřejné metody --------------------------- + + public function renderField() { + wp_editor($this->getValue(), $this->getName(), array( + "media_buttons" => false, + "textarea_name" => $this->getNameAttribute(), + "textarea_rows" => 10, + "teeny" => false, + "quicktags" => false + )); + } + } From 744371c19a342e5a0ea8b33040798b671063e16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Fri, 1 Apr 2016 13:14:27 +0200 Subject: [PATCH 04/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20KT=5FPresenter?= =?UTF-8?q?=5FBase::getIsFrontPageHome()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/presenters/kt_presenter_base.inc.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/presenters/kt_presenter_base.inc.php b/core/presenters/kt_presenter_base.inc.php index 63fefbc..1fbcc31 100644 --- a/core/presenters/kt_presenter_base.inc.php +++ b/core/presenters/kt_presenter_base.inc.php @@ -11,6 +11,7 @@ abstract class KT_Presenter_Base implements KT_Presentable { private $model = null; private static $currentQueryLoopIndex; private static $currentItemsLoopIndex; + private static $isFrontPageHome; public function __construct(KT_Modelable $model = null) { kt_check_loaded(); // kontrola KT Frameworku @@ -58,7 +59,6 @@ public function setModel(KT_Modelable $model) { public static function getCurrentQueryLoopIndex() { return self::$currentQueryLoopIndex; } - /** * Vrátí aktuální číslo v rámci výpisu šablon pomocí @see theQueryLoops @@ -95,7 +95,22 @@ public static function getCurrentItemsLoopIndex() { public static function getCurrentItemsLoopNumber() { return self::getCurrentItemsLoopIndex() + 1; } - + + /** + * Vrátí označení zda je právě aktivní Front nebo Home page + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + * + * @return boolean + */ + public static function getIsFrontPageHome() { + if (isset(self::$isFrontPageHome)) { + return self::$isFrontPageHome; + } + return self::$isFrontPageHome = (is_front_page() || is_home()); + } + // --- veřejné funkce --------------------- /** From 8e1379399f5dcca67a8cc230b9d43d851baa52e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Tue, 5 Apr 2016 10:48:19 +0200 Subject: [PATCH 05/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20metod=20KT::stri?= =?UTF-8?q?ngLineFormat=20a=20KT=5FWP=5FTerm=5FBase=5FModel->isDescription?= =?UTF-8?q?()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit + rozšíření max. délky e-mailu 50->100 na KT_Contact_Form_Base_Configu --- core/classes/kt.inc.php | 20 +++++++++++++++++++ .../kt_contact_form_base_config.inc.php | 4 ++-- core/models/kt_wp_term_base_model.inc.php | 14 ++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/core/classes/kt.inc.php b/core/classes/kt.inc.php index a98587c..de4744d 100644 --- a/core/classes/kt.inc.php +++ b/core/classes/kt.inc.php @@ -1350,6 +1350,26 @@ public static function stringHtmlDecode($text) { return $text; } + /** + * Provede aplikaci (nových HTML) řádků na zadaný text včetně náhrady případných tagů za zastupné + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + * + * @param string $text + * @param array $tags [$tag => $wildcard] + * @return string + */ + public static function stringLineFormat($text, array $tags = null) { + if (self::issetAndNotEmpty($text)) { + foreach ($tags as $tag => $wildcard) { + $text = str_replace($tag, $wildcard, $text); + } + return nl2br($text); + } + return null; + } + /** * Na základě zadaného pole hodnot vrátí odpovídající SQL placeholdery jako string * Pozn. vhodné pro @see WPDB a prepare IN diff --git a/core/configs/kt_contact_form_base_config.inc.php b/core/configs/kt_contact_form_base_config.inc.php index 1120745..cea5cc9 100644 --- a/core/configs/kt_contact_form_base_config.inc.php +++ b/core/configs/kt_contact_form_base_config.inc.php @@ -51,10 +51,10 @@ public static function getFieldset($splittedName = false, $exactedPhone = true) $fieldset->addText(self::EMAIL, __("E-mail*:", "KT_CORE_DOMAIN")) ->setPlaceholder(__("E-mail*", "KT_CORE_DOMAIN")) - ->addAttribute("maxlength", 50) + ->addAttribute("maxlength", 100) ->addRule(KT_Field_Validator::REQUIRED, __("E-mail je povinná položka", "KT_CORE_DOMAIN")) ->addRule(KT_Field_Validator::EMAIL, __("E-mail je ve špatném tvaru", "KT_CORE_DOMAIN")) - ->addRule(KT_Field_Validator::MAX_LENGTH, __("E-mail může mít maximálně 50 znaků", "KT_CORE_DOMAIN"), 50); + ->addRule(KT_Field_Validator::MAX_LENGTH, __("E-mail může mít maximálně 100 znaků", "KT_CORE_DOMAIN"), 100); $phoneField = $fieldset->addText(self::PHONE, __("Telefon*:", "KT_CORE_DOMAIN")) ->setPlaceholder(__("Telefon*", "KT_CORE_DOMAIN")) diff --git a/core/models/kt_wp_term_base_model.inc.php b/core/models/kt_wp_term_base_model.inc.php index d02791e..bff6305 100644 --- a/core/models/kt_wp_term_base_model.inc.php +++ b/core/models/kt_wp_term_base_model.inc.php @@ -210,6 +210,18 @@ public function getMetaValue($key) { return null; } + /** + * Označení, zda je k dispozici, resp. vyplněn popisek + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + * + * @return boolean + */ + public function isDescription() { + return KT::issetAndNotEmpty($this->getDescription()); + } + /** * Vrátí, zda má term přiřazené některé posty * @@ -334,7 +346,7 @@ private function initMetas() { } // --- statické funkce --------- - + /** * Funkcí vrátí všechny parametry příspěvku a to všechny nebo s prefixem * From 141e40737768cde27f9c62d3ec3ccf3720647663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Mon, 18 Apr 2016 16:48:52 +0200 Subject: [PATCH 06/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20KT=5FWP=5FConfig?= =?UTF-8?q?urator::htmlImageLinkClassFilter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aplikace naší CSS classy pro obrázky s odkazem v editoru --- .../configurator/kt_wp_configurator.inc.php | 21 ++++++++++++++++++- .../functions/kt_general_functions.inc.php | 2 -- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/core/classes/configurator/kt_wp_configurator.inc.php b/core/classes/configurator/kt_wp_configurator.inc.php index 32d70c6..ec95571 100644 --- a/core/classes/configurator/kt_wp_configurator.inc.php +++ b/core/classes/configurator/kt_wp_configurator.inc.php @@ -539,8 +539,10 @@ public function initialize() { // archivy post typů v menu if ($postArchiveMenu === true) { add_action("admin_head-nav-menus.php", array($this, "addPostArchivesMenuMetaBox")); + add_filter("image_send_to_editor", array($this, "htmlImageLinkClassFilter"), 10, 8); } elseif ($postArchiveMenu === false) { add_action("admin_head-nav-menus.php", array($this, "addPostArchivesMenuMetaBox")); + remove_filter("image_send_to_editor", array($this, "htmlImageLinkClassFilter"), 10, 8); } } else { // (images) lazy loading @@ -1221,6 +1223,23 @@ public function htmlImageLazyLoadingFilter($html) { return KT::imageReplaceLazySrc($html); } + /** + * Zpracování filtru za účelem aplikace css classy na linky pro obrázky + * NENÍ POTŘEBA VOLAT VEŘEJNĚ + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + */ + public function htmlImageLinkClassFilter($html, $id, $caption, $title, $align, $url, $size, $alt = "") { + $class = "kt-img-link"; + if (preg_match('//', $html)) { + $html = preg_replace('/()/', "$1 {$class}$2", $html); + } else { + $html = preg_replace('/(/', "$1 class=\"$class\" >", $html); + } + return $html; + } + /** * Přidání metaboxu pro archivy post typů v menu * NENÍ POTŘEBA VOLAT VEŘEJNĚ @@ -1382,7 +1401,7 @@ public function renderCookieStatement() { public static function getThemeSettingSlug() { return $baseName = self::THEME_SUBPAGE_PREFIX . self::THEME_SETTING_PAGE_SLUG; } - + /** * Vrátí název WP_Screen base pro (založenou) stránku (KT) WP Cron * diff --git a/core/requires/functions/kt_general_functions.inc.php b/core/requires/functions/kt_general_functions.inc.php index 9629825..1d1e74a 100644 --- a/core/requires/functions/kt_general_functions.inc.php +++ b/core/requires/functions/kt_general_functions.inc.php @@ -95,5 +95,3 @@ function kt_wp_before_admin_bar_render_callback() { "href" => admin_url("themes.php") . "?page=" . KT_WP_Configurator::THEME_SETTING_PAGE_SLUG, )); } - - From cdcaa6130616a1e45a9b2860273bb8853b61610b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kocifaj?= Date: Thu, 21 Apr 2016 16:07:37 +0200 Subject: [PATCH 07/19] =?UTF-8?q?Drobn=C3=A1=20vzhledov=C3=A1=20korekce=20?= =?UTF-8?q?po=20update=20WordPress=20CSS,=20oprava=20validace=20CRUD=20hod?= =?UTF-8?q?noty=20v=20p=C5=99=C3=ADpad=C4=9B,=20=C5=BEe=20se=20jedn=C3=A1?= =?UTF-8?q?=20o=20int=20a=20hodnota=20je=200;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/classes/crud/kt_crud.inc.php | 2 +- core/css/kt-core.css | 20 ++++++++++---------- core/css/kt-core.min.css | 3 +-- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/core/classes/crud/kt_crud.inc.php b/core/classes/crud/kt_crud.inc.php index 50649cc..6b7c472 100644 --- a/core/classes/crud/kt_crud.inc.php +++ b/core/classes/crud/kt_crud.inc.php @@ -650,7 +650,7 @@ private function getColumnsWithFormatsData() { $value = $column->getValue(); $isNullable = $column->getNullable(); - if ($value == null && !$isNullable) { + if (is_null($value) && !$isNullable) { continue; // může "zachránit", resp. vyřešit výchozí hodnota v DB } if ($isNullable && $value == "") { diff --git a/core/css/kt-core.css b/core/css/kt-core.css index 1e5a34c..d5f9a9c 100644 --- a/core/css/kt-core.css +++ b/core/css/kt-core.css @@ -11,7 +11,7 @@ img.kt-loading-image margin: 0 10px; } -.kt-custom-screen-page > h2 +#wpbody-content .kt-custom-screen-page > h2 { background: #222; color: #fff; @@ -20,49 +20,49 @@ img.kt-loading-image font-size: 15px; } -.kt-custom-screen-page div.updated +#wpbody-content .kt-custom-screen-page div.updated { margin-top: 15px; } -.kt-custom-screen-page table.wp-list-table +#wpbody-content .kt-custom-screen-page table.wp-list-table { margin-top: 15px; } -.kt-custom-screen-page table.wp-list-table tr.updated +#wpbody-content .kt-custom-screen-page table.wp-list-table tr.updated { background-color: #DAFF75; } -.kt-custom-screen-page table.wp-list-table tr td +#wpbody-content .kt-custom-screen-page table.wp-list-table tr td { vertical-align: middle; } -.kt-custom-screen-page table.wp-list-table tr td .id-link +#wpbody-content .kt-custom-screen-page table.wp-list-table tr td .id-link { display: inline-block; margin-right: 10px; } -.kt-custom-screen-page table.wp-list-table .row-actions .delete-row +#wpbody-content .kt-custom-screen-page table.wp-list-table .row-actions .delete-row { color: #a00; cursor: pointer; } -.kt-custom-screen-page table.wp-list-table .row-actions .delete-row:hover +#wpbody-content .kt-custom-screen-page table.wp-list-table .row-actions .delete-row:hover { color: red; } -.kt-custom-screen-page #addCrudButtonList +#wpbody-content .kt-custom-screen-page #addCrudButtonList { margin-top: 15px; } -.kt-custom-screen-page table.wp-list-table span.dashicons-menu +#wpbody-content .kt-custom-screen-page table.wp-list-table span.dashicons-menu { cursor: n-resize; } diff --git a/core/css/kt-core.min.css b/core/css/kt-core.min.css index b5246d9..ae46025 100644 --- a/core/css/kt-core.min.css +++ b/core/css/kt-core.min.css @@ -1,2 +1 @@ - -.kt-hidden{display:none!important}img.kt-loading-image{display:inline-block;margin:0 10px}.kt-custom-screen-page>h2{background:#222;color:#fff;text-transform:uppercase;padding:10px 20px;font-size:15px}.kt-custom-screen-page div.updated{margin-top:15px}.kt-custom-screen-page table.wp-list-table{margin-top:15px}.kt-custom-screen-page table.wp-list-table tr.updated{background-color:#daff75}.kt-custom-screen-page table.wp-list-table tr td{vertical-align:middle}.kt-custom-screen-page table.wp-list-table tr td .id-link{display:inline-block;margin-right:10px}.kt-custom-screen-page table.wp-list-table .row-actions .delete-row{color:#a00;cursor:pointer}.kt-custom-screen-page table.wp-list-table .row-actions .delete-row:hover{color:red}.kt-custom-screen-page #addCrudButtonList{margin-top:15px}.kt-custom-screen-page table.wp-list-table span.dashicons-menu{cursor:n-resize}.kt-loading-gif{position:relative}.kt-loading-gif.loading,kt-loading-gif.loading:hover{background:#f0f0ee!important;color:#999!important;border-color:#999!important;box-shadow:none!important}.kt-loading-gif.loading:hover{cursor:progress}.kt-loading-gif:before{content:"";display:block;width:20px;height:20px;display:inline-block;background:url('../images/loading.gif') top left no-repeat;display:none;position:absolute}.kt-loading-gif.loading:before{display:block;position:absolute;top:50%;left:50%;margin-left:-10px;margin-top:-10px}.wp-list-table .column-post_thumbnail{width:40px;max-width:40px}.wp-list-table .column-menu-order{width:60px;max-width:60px}.wp-list-table .visibility-column{width:100px;max-width:100px}form#kt-form input[type="number"],form#kt-form input[type="text"],form#kt-form input[type="email"],form#kt-form input[type="password"],form#kt-form input[type="url"],form#kt-form select,form#kt-form checkobx,form#kt-form textarea{float:left;width:90%}.chosen-search input{float:none!important}form#kt-form .required,table.kt-form-table .required{border:solid #000 1px}table.kt-form-table{width:100%;margin:15px 0}table.kt-form-table tr td:first-child{padding:8px 25px 8px 0;font-weight:bold;width:30%}table.kt-form-table tr td textarea{min-height:150px}div.postbox input#kt-form-submit{margin:20px 0 10px 0}div.validator{height:0;position:relative}span.erorr-s{position:absolute;padding:2px 8px;display:block;left:0;top:25px;white-space:nowrap;height:20px;line-height:20px;border-radius:3px;color:#fff;font-family:verdana;letter-spacing:-1px;font-size:11px;background:#c92a2a}span.erorr-s:after{content:"";display:block;width:0;height:0;position:absolute;top:-5px;left:10px;border-style:solid;border-width:0 5px 10px 5px;border-color:transparent transparent #c92a2a transparent}span.erorr-s.input-checkbox{top:5px}.kt_fieldset input[type="number"],.kt_fieldset input[type="text"],.kt_fieldset input[type="email"],.kt_fieldset input[type="url"],.kt_fieldset select,.kt_fieldset checkobx,.kt_fieldset textarea{float:left;width:90%}.kt_fieldset table{width:100%}.kt_fieldset table tr td:first-child{width:20%}.ui-tooltip{color:#acff1c!important;background:#111!important;box-shadow:none!important;border:solid #fff 1px!important;padding:8px;position:absolute;z-index:9999;max-width:300px;text-align:left}div.file-load-box span.span-url{display:inline-block;color:#fff;margin-right:5px;line-height:1em;vertical-align:middle}div.file-load-box span.span-url span.file{background:#999;padding:4px;line-height:normal;display:inline-block;margin-top:1px}div.file-load-box span.span-url.full{margin-right:15px}div.file-load-box span.span-url>a>span{color:#ff0d0d;cursor:pointer;opacity:.4;transition:opacity .3s ease}div.file-load-box span.span-url>a>span:hover{opacity:1}span.switch-toggle{background:url('../images/switch.png') no-repeat;display:inline-block!important;height:35px;width:86px;padding-left:26px;cursor:pointer;display:none}span.switch-toggle.on{background-position:0 0}span.switch-toggle.off{background-position:0 -35px}span.switch-toggle.hidden{display:none}.sliderInputElement{background:#afc4d0;height:8px;width:89%;border-radius:3px;position:relative;margin-bottom:35px;margiN:0 8px}.sliderInputElement input.hidden{display:none}.sliderInputElement .min{display:block;float:left}.sliderInputElement.ui-widget-content .ui-slider-handle{text-align:center;font-size:12px;background:#2ea2cc;height:20px;line-height:20px;padding:0 4px;width:auto;border:0;color:#fff;outline:0;cursor:pointer;transition:padding .2s ease;text-decoration:none}.sliderInputElement.ui-widget-content .ui-slider-handle.ui-state-active{padding-left:8px;padding-right:8px}p.kt-no-error,p.kt-error{padding:10px 5px;display:inline-block;margin:15px 0;width:100%}p.kt-error{background:#f33;color:#fff}p.kt-no-error{background:#b4ff69;color:#000}span.kt-log-error,span.kt-log-warning,span.kt-log-info,span.kt-log-debug,span.kt-log-trace{font-weight:bold}span.kt-log-error{color:#b30000}span.kt-log-warning{color:#b3b300}span.kt-log-info{color:#005a00}span.kt-log-debug{color:#1919b3}span.kt-log-trace{color:#5a005a}.kt-clearfix:before,.kt-clearfix:after,.postbox .inside:before,.postbox .inside:after{content:" ";display:table}.kt-clearfix:after,.postbox .inside:after{clear:both} \ No newline at end of file +.kt-hidden{display:none!important}img.kt-loading-image{display:inline-block;margin:0 10px}#wpbody-content .kt-custom-screen-page>h2{background:#222;color:#fff;text-transform:uppercase;padding:10px 20px;font-size:15px}#wpbody-content .kt-custom-screen-page div.updated{margin-top:15px}#wpbody-content .kt-custom-screen-page table.wp-list-table{margin-top:15px}#wpbody-content .kt-custom-screen-page table.wp-list-table tr.updated{background-color:#daff75}#wpbody-content .kt-custom-screen-page table.wp-list-table tr td{vertical-align:middle}#wpbody-content .kt-custom-screen-page table.wp-list-table tr td .id-link{display:inline-block;margin-right:10px}#wpbody-content .kt-custom-screen-page table.wp-list-table .row-actions .delete-row{color:#a00;cursor:pointer}#wpbody-content .kt-custom-screen-page table.wp-list-table .row-actions .delete-row:hover{color:red}#wpbody-content .kt-custom-screen-page #addCrudButtonList{margin-top:15px}#wpbody-content .kt-custom-screen-page table.wp-list-table span.dashicons-menu{cursor:n-resize}.kt-loading-gif{position:relative}.kt-loading-gif.loading,kt-loading-gif.loading:hover{background:#f0f0ee!important;color:#999!important;border-color:#999!important;box-shadow:none!important}.kt-loading-gif.loading:hover{cursor:progress}.kt-loading-gif:before{content:"";display:block;width:20px;height:20px;display:inline-block;background:url('../images/loading.gif') top left no-repeat;display:none;position:absolute}.kt-loading-gif.loading:before{display:block;position:absolute;top:50%;left:50%;margin-left:-10px;margin-top:-10px}.wp-list-table .column-post_thumbnail{width:40px;max-width:40px}.wp-list-table .column-menu-order{width:60px;max-width:60px}.wp-list-table .visibility-column{width:100px;max-width:100px}form#kt-form input[type="number"],form#kt-form input[type="text"],form#kt-form input[type="email"],form#kt-form input[type="password"],form#kt-form input[type="url"],form#kt-form select,form#kt-form checkobx,form#kt-form textarea{float:left;width:90%}.chosen-search input{float:none!important}form#kt-form .required,table.kt-form-table .required{border:solid #000 1px}table.kt-form-table{width:100%;margin:15px 0}table.kt-form-table tr td:first-child{padding:8px 25px 8px 0;font-weight:bold;width:30%}table.kt-form-table tr td textarea{min-height:150px}div.postbox input#kt-form-submit{margin:20px 0 10px 0}div.validator{height:0;position:relative}span.erorr-s{position:absolute;padding:2px 8px;display:block;left:0;top:25px;white-space:nowrap;height:20px;line-height:20px;border-radius:3px;color:#fff;font-family:verdana;letter-spacing:-1px;font-size:11px;background:#c92a2a}span.erorr-s:after{content:"";display:block;width:0;height:0;position:absolute;top:-5px;left:10px;border-style:solid;border-width:0 5px 10px 5px;border-color:transparent transparent #c92a2a transparent}span.erorr-s.input-checkbox{top:5px}.kt_fieldset input[type="number"],.kt_fieldset input[type="text"],.kt_fieldset input[type="email"],.kt_fieldset input[type="url"],.kt_fieldset select,.kt_fieldset checkobx,.kt_fieldset textarea{float:left;width:90%}.kt_fieldset table{width:100%}.kt_fieldset table tr td:first-child{width:20%}.ui-tooltip{color:#acff1c!important;background:#111!important;box-shadow:none!important;border:solid #fff 1px!important;padding:8px;position:absolute;z-index:9999;max-width:300px;text-align:left}div.file-load-box span.span-url{display:inline-block;color:#fff;margin-right:5px;line-height:1em;vertical-align:middle}div.file-load-box span.span-url span.file{background:#999;padding:4px;line-height:normal;display:inline-block;margin-top:1px}div.file-load-box span.span-url.full{margin-right:15px}div.file-load-box span.span-url>a>span{color:#ff0d0d;cursor:pointer;opacity:.4;transition:opacity .3s ease}div.file-load-box span.span-url>a>span:hover{opacity:1}span.switch-toggle{background:url('../images/switch.png') no-repeat;display:inline-block!important;height:35px;width:86px;padding-left:26px;cursor:pointer;display:none}span.switch-toggle.on{background-position:0 0}span.switch-toggle.off{background-position:0 -35px}span.switch-toggle.hidden{display:none}.sliderInputElement{background:#afc4d0;height:8px;width:89%;border-radius:3px;position:relative;margin-bottom:35px;margiN:0 8px}.sliderInputElement input.hidden{display:none}.sliderInputElement .min{display:block;float:left}.sliderInputElement.ui-widget-content .ui-slider-handle{text-align:center;font-size:12px;background:#2ea2cc;height:20px;line-height:20px;padding:0 4px;width:auto;border:0;color:#fff;outline:0;cursor:pointer;transition:padding .2s ease;text-decoration:none}.sliderInputElement.ui-widget-content .ui-slider-handle.ui-state-active{padding-left:8px;padding-right:8px}p.kt-no-error,p.kt-error{padding:10px 5px;display:inline-block;margin:15px 0;width:100%}p.kt-error{background:#f33;color:#fff}p.kt-no-error{background:#b4ff69;color:#000}span.kt-log-error,span.kt-log-warning,span.kt-log-info,span.kt-log-debug,span.kt-log-trace{font-weight:bold}span.kt-log-error{color:#b30000}span.kt-log-warning{color:#b3b300}span.kt-log-info{color:#005a00}span.kt-log-debug{color:#1919b3}span.kt-log-trace{color:#5a005a}.kt-clearfix:before,.kt-clearfix:after,.postbox .inside:before,.postbox .inside:after{content:" ";display:table}.kt-clearfix:after,.postbox .inside:after{clear:both} \ No newline at end of file From c5f3c7d16e368c8b27f2a3e5f1244e8bbe617f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Mon, 25 Apr 2016 11:15:17 +0200 Subject: [PATCH 08/19] =?UTF-8?q?=C3=9Apravy=20private=20->=20protected=20?= =?UTF-8?q?pro=20KT=5FHTML=5FTag=5FBase->getClasses()=20a=20instan=C4=8Dn?= =?UTF-8?q?=C3=AD=20prom=C4=9Bnn=C3=A9=20v=20KT=5FContact=5FForm=5FBase=5F?= =?UTF-8?q?Presenter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/classes/kt_html_tag_base.inc.php | 3 +-- core/presenters/kt_contact_form_base_presenter.inc.php | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/core/classes/kt_html_tag_base.inc.php b/core/classes/kt_html_tag_base.inc.php index e8c4a80..005954b 100644 --- a/core/classes/kt_html_tag_base.inc.php +++ b/core/classes/kt_html_tag_base.inc.php @@ -233,11 +233,10 @@ public function removeAttrClass($class) { * * @return array */ - private function getClasses() { + protected function getClasses() { if (array_key_exists(self::CLASS_KEY, $this->getAttributes())) { return $this->attributes[self::CLASS_KEY]; } - return array(); } diff --git a/core/presenters/kt_contact_form_base_presenter.inc.php b/core/presenters/kt_contact_form_base_presenter.inc.php index ca7c1aa..b908ea8 100644 --- a/core/presenters/kt_contact_form_base_presenter.inc.php +++ b/core/presenters/kt_contact_form_base_presenter.inc.php @@ -11,9 +11,9 @@ class KT_Contact_Form_Base_Presenter extends KT_Presenter_Base { const FORM_ID = "kt-contact-form"; const PROCESSED_PARAM = "contact-processed"; - private $form; - private $fieldset; - private $wasProcessed; + protected $form; + protected $fieldset; + protected $wasProcessed; /** * Obecný presenter pro obsluhu kontakního formuláře From e784af7410bcb9ce651865eddf140b800046794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Tue, 26 Apr 2016 09:31:12 +0200 Subject: [PATCH 09/19] =?UTF-8?q?Oprava=20v=C3=BDchoz=C3=AD=20hodnoty=20pa?= =?UTF-8?q?rametru=20$tags=20v=20metod=C4=9B=20KT::stringLineFormat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/classes/kt.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/classes/kt.inc.php b/core/classes/kt.inc.php index de4744d..9b021a7 100644 --- a/core/classes/kt.inc.php +++ b/core/classes/kt.inc.php @@ -1360,7 +1360,7 @@ public static function stringHtmlDecode($text) { * @param array $tags [$tag => $wildcard] * @return string */ - public static function stringLineFormat($text, array $tags = null) { + public static function stringLineFormat($text, array $tags = array()) { if (self::issetAndNotEmpty($text)) { foreach ($tags as $tag => $wildcard) { $text = str_replace($tag, $wildcard, $text); From 81ebb3d6ed145fdba573c92b9a32dd257fdd027c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Tue, 26 Apr 2016 13:54:20 +0200 Subject: [PATCH 10/19] =?UTF-8?q?Vlastn=C3=AD=20nastaven=C3=AD=20pro=20apl?= =?UTF-8?q?ikaci=20(css)=20class=20na=20odkazy=20obr=C3=A1zk=C5=AF=20p?= =?UTF-8?q?=C5=99i=20editaci=20v=20administraci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KT_WP_Configurator->(get/set)ImagesLinkClasses() --- .../configurator/kt_wp_configurator.inc.php | 58 +++++++++++++------ 1 file changed, 41 insertions(+), 17 deletions(-) diff --git a/core/classes/configurator/kt_wp_configurator.inc.php b/core/classes/configurator/kt_wp_configurator.inc.php index ec95571..f103101 100644 --- a/core/classes/configurator/kt_wp_configurator.inc.php +++ b/core/classes/configurator/kt_wp_configurator.inc.php @@ -37,6 +37,7 @@ final class KT_WP_Configurator { private $displayLogo = true; private $assetsConfigurator = null; private $imagesLazyLoading = null; + private $imagesLinkClasses = null; private $postArchiveMenu = null; private $allowSession = false; private $allowCookieStatement = false; @@ -151,6 +152,13 @@ private function getImagesLazyLoading() { return $this->imagesLazyLoading; } + /** + * @return boolean + */ + private function getImagesLinkClasses() { + return $this->imagesLinkClasses; + } + /** * @return boolean */ @@ -191,7 +199,7 @@ public function getFacebookManager() { } /** - * + * * @return boolean */ public function getEmojiSwitch() { @@ -202,10 +210,10 @@ public function getEmojiSwitch() { /** * Nastaví KT_WP_Metabox_Remover_Configurátor do objektu - * + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * * @param KT_WP_Metabox_Remover_Configurator $metaboxRemover * @return \KT_WP_Configurator */ @@ -217,10 +225,10 @@ private function setMetaboxRemover(KT_WP_Metabox_Remover_Configurator $metaboxRe /** * Nastaví KT_WP_Page_Remover_Configurator do objektu - * + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * * @param KT_WP_Page_Remover_Configurator $pageRemover * @return \KT_WP_Configurator */ @@ -232,10 +240,10 @@ private function setPageRemover(KT_WP_Page_Remover_Configurator $pageRemover) { /** * Nastaví KT_WP_Widget_Remover_Configurator do objektu - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz - * + * * @param KT_WP_Widget_Remover_Configurator $widgetRemover * @return \KT_WP_Configurator */ @@ -246,10 +254,10 @@ private function setWidgetRemover(KT_WP_Widget_Remover_Configurator $widgetRemov /** * Nastaví KT_WP_Head_Remover_Configurator do objektu - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz - * + * * @param KT_WP_Head_Remover_Configurator $headRemover * @return \KT_WP_Configurator */ @@ -337,10 +345,10 @@ public function setDisplayLogo($displayLogo = true) { /** * Nastaví KT_WP_Asset_Configurator do objektu - * + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * * @param \KT_WP_Asset_Configurator $assetsConfigurator * @return \KT_WP_Configurator */ @@ -351,10 +359,10 @@ public function setAssetsConfigurator(KT_WP_Asset_Configurator $assetsConfigurat /** * Nastaví, zda se má v rámci šablony zapnout SESSION pro WP - * + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * * @param boolean $allowSession * @return \KT_WP_Configurator */ @@ -376,10 +384,10 @@ public function setSessionEnable($sessionEnable = true) { /** * Nastaví, zda se má v rámci šablony zapnout odsouhlasení cookie - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz - * + * * @param boolean $allowCookieStatement * @return \KT_WP_Configurator */ @@ -404,7 +412,7 @@ public function setPostArchiveMenu($postArchiveMenu = true) { /** * Aktivace automatické aplikace lazy loadingu na obrázky pomocí skriptu unveil - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz */ @@ -413,6 +421,17 @@ public function setImagesLazyLoading($imagesLazyLoading) { return $this; } + /** + * Aktivace aplikace (css) class na odkazy obrázků při editaci v administraci + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + */ + public function setImagesLinkClasses($imagesLinkClasses) { + $this->imagesLinkClasses = $imagesLinkClasses; + return $this; + } + /** * Nastaví facebook data manager do configurátoru * @@ -539,9 +558,14 @@ public function initialize() { // archivy post typů v menu if ($postArchiveMenu === true) { add_action("admin_head-nav-menus.php", array($this, "addPostArchivesMenuMetaBox")); - add_filter("image_send_to_editor", array($this, "htmlImageLinkClassFilter"), 10, 8); } elseif ($postArchiveMenu === false) { add_action("admin_head-nav-menus.php", array($this, "addPostArchivesMenuMetaBox")); + } + // (iamges) link classes + $imageLinkClass = $this->getImagesLinkClasses(); + if ($imageLinkClass === true) { + add_filter("image_send_to_editor", array($this, "htmlImageLinkClassFilter"), 10, 8); + } elseif ($imageLinkClass === false) { remove_filter("image_send_to_editor", array($this, "htmlImageLinkClassFilter"), 10, 8); } } else { From 9e2b8d6ddad680ced4d6862571418545087d44d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Wed, 4 May 2016 14:38:48 +0200 Subject: [PATCH 11/19] =?UTF-8?q?N=C3=A1hrada=20WPML=20funkce=20icl=5Fobje?= =?UTF-8?q?ct=5Fid->wpml=5Fobject=5Fid=5Ffilter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pro překlady meta a options modelech --- core/models/kt_meta_model_base.inc.php | 4 ++-- core/models/kt_wp_options_base_model.inc.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/models/kt_meta_model_base.inc.php b/core/models/kt_meta_model_base.inc.php index b6d99a4..61e048a 100644 --- a/core/models/kt_meta_model_base.inc.php +++ b/core/models/kt_meta_model_base.inc.php @@ -84,11 +84,11 @@ public function getMetaTranslateId($key, $postType) { if (is_array($value)) { $ids = array(); foreach ($value as $id) { - array_push($ids, icl_object_id($id, $postType, true, ICL_LANGUAGE_CODE)); + array_push($ids, wpml_object_id_filter($id, $postType, true, ICL_LANGUAGE_CODE)); } return $ids; } else { - $value = icl_object_id($value, $postType, true, ICL_LANGUAGE_CODE); + $value = wpml_object_id_filter($value, $postType, true, ICL_LANGUAGE_CODE); } } return $value; diff --git a/core/models/kt_wp_options_base_model.inc.php b/core/models/kt_wp_options_base_model.inc.php index 980ed46..fd589ca 100644 --- a/core/models/kt_wp_options_base_model.inc.php +++ b/core/models/kt_wp_options_base_model.inc.php @@ -167,11 +167,11 @@ public function getOptionTranslateId($name, $postType) { if (is_array($value)) { $ids = array(); foreach ($value as $id) { - array_push($ids, icl_object_id($id, $postType, true, ICL_LANGUAGE_CODE)); + array_push($ids, wpml_object_id_filter($id, $postType, true, ICL_LANGUAGE_CODE)); } return $ids; } else { - $value = icl_object_id($value, $postType, true, ICL_LANGUAGE_CODE); + $value = wpml_object_id_filter($value, $postType, true, ICL_LANGUAGE_CODE); } } return $value; From c46fc907a90320e5f8deb8e719a5bd48224210bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Fri, 6 May 2016 20:01:26 +0200 Subject: [PATCH 12/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20kontroly=20na=20?= =?UTF-8?q?pouze=20po=C5=BEadovan=C3=BD=20fieldset=20v=20POSTu=20v=20r?= =?UTF-8?q?=C3=A1mci=20zpracov=C3=A1n=C3=AD=20KT=5FContact=5FForm=5FBase?= =?UTF-8?q?=5FPresenteru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/presenters/kt_contact_form_base_presenter.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/presenters/kt_contact_form_base_presenter.inc.php b/core/presenters/kt_contact_form_base_presenter.inc.php index b908ea8..8c9711c 100644 --- a/core/presenters/kt_contact_form_base_presenter.inc.php +++ b/core/presenters/kt_contact_form_base_presenter.inc.php @@ -130,7 +130,7 @@ public function getWasProcessed() { * @link http://www.ktstudio.cz */ public function process() { - if (KT::arrayIssetAndNotEmpty($_POST)) { + if (KT::arrayIssetAndNotEmpty($_POST) && array_key_exists(KT_Contact_Form_Base_Config::FORM_PREFIX, $_POST)) { $form = $this->getForm(); if (!$form->nonceValidate()) { wp_die(__("Chyba zpracování zdrojové adresy...", "KT_CORE_DOMAIN")); From 22cb8325573e2e2702d188b6bba1e6f8dde384c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Mon, 9 May 2016 13:18:28 +0200 Subject: [PATCH 13/19] =?UTF-8?q?Auto=20issery=20na=20modelech,=20resp.=20?= =?UTF-8?q?KT=5FModel=5FBase=20a=20d=C3=A1le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ala auto gettry --- core/models/kt_model_base.inc.php | 95 +++++++++++++------- core/models/kt_wp_options_base_model.inc.php | 11 ++- core/models/kt_wp_post_base_model.inc.php | 11 ++- core/models/kt_wp_term_base_model.inc.php | 11 ++- core/models/kt_wp_user_base_model.inc.php | 11 ++- 5 files changed, 89 insertions(+), 50 deletions(-) diff --git a/core/models/kt_model_base.inc.php b/core/models/kt_model_base.inc.php index d5dee97..6cb49de 100644 --- a/core/models/kt_model_base.inc.php +++ b/core/models/kt_model_base.inc.php @@ -2,94 +2,121 @@ /** * Společný základ pro všechny modely - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz */ abstract class KT_Model_Base implements KT_Modelable { - const MAGIC_GETTER_KEY = "get"; + const MAGIC_ISSER_PREFIX = "is"; + const MAGIC_GETTER_PREFIX = "get"; /** - * Vytvoří jméno constanty na základě názvu funkce a to tak, že rozdělí - * string na základě velkých písmen, vloží mezi slovo podtržítka a převed vše na velké písmena. - * + * Vytvoří jméno constanty na základě názvu funkce a to tak, že rozdělí string + * na základě velkých písmen, vloží mezi slovo podtržítka a převed vše na velké písmena. + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * * @param string $functionName * @return string */ - protected function getConstantFromFunctionName($functionName) { - + protected function getConstantNameFromFunction($functionName) { if (KT::notIssetOrEmpty($functionName)) { return null; } - $parts = preg_split('/(?=[A-Z])/', $functionName, -1, PREG_SPLIT_NO_EMPTY); unset($parts[0]); $constantName = strtoupper(implode($parts, "_")); - return $constantName; } /** * Vytvoří název configu, který odpovídá volanému modelu. - * + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * - * @return type + * + * @return string */ - protected function getConfigFromModelName() { + protected function getConfigNameFromModel() { return $configName = str_replace("Model", "Config", get_called_class()); } /** - * Metoda prověří, zda se jedná o funkci, která začíná znaky "get" pokud ano - * provede vyčtení příslušné hodnoty constanty a vrátí její hodnotu na základě - * volané třídy. - * + * Metoda prověří, zda se jedná o funkci, která začíná znaky "is" pokud ano provede + * vyčtení příslušné hodnoty constanty a vrátí její hodnotu na základě volané třídy. + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + * + * @param string $functionName + * @return string + * @throws KT_Not_Exist_Config_Constant_Exception + */ + protected function getAutoIsserKey($functionName) { + return $this->getAutoMethodKey($functionName, self::MAGIC_ISSER_PREFIX); + } + + /** + * Metoda prověří, zda se jedná o funkci, která začíná znaky "get" pokud ano provede + * vyčtení příslušné hodnoty constanty a vrátí její hodnotu na základě volané třídy. + * * @author Tomáš Kocifaj * @link http://www.ktstudio.cz - * + * + * @param string $functionName * @return string + * @throws KT_Not_Exist_Config_Constant_Exception */ - protected function getConstantValue($functionName) { - - $firstChars = substr($functionName, 0, 3); + protected function getAutoGetterKey($functionName) { + return $this->getAutoMethodKey($functionName, self::MAGIC_GETTER_PREFIX); + } - if ($firstChars != self::MAGIC_GETTER_KEY) { + /** + * Metoda prověří, zda se jedná o funkci, která začíná zadaným prefixem a pokud ano, tak provede + * vyčtení příslušné hodnoty constanty a vrátí její hodnotu na základě volané třídy. + * + * @author Tomáš Kocifaj + * @link http://www.ktstudio.cz + * + * @param string $functionName + * @param string $prefix + * @return string + * @throws KT_Not_Exist_Config_Constant_Exception + */ + private function getAutoMethodKey($functionName, $prefix) { + $firstChars = substr($functionName, 0, strlen($prefix)); + if ($firstChars !== $prefix) { return null; } if (method_exists($this, $functionName)) { return null; } - - $configName = $this->getConfigFromModelName(); - - if(!class_exists($configName)){ + + $configName = $this->getConfigNameFromModel(); + if (!class_exists($configName)) { return null; } - $classRef = new ReflectionClass($configName); - $constantName = $this->getConstantFromFunctionName($functionName); - + $reflectionClass = new ReflectionClass($configName); + $constantName = $this->getConstantNameFromFunction($functionName); if (KT::notIssetOrEmpty($constantName)) { throw new KT_Not_Exist_Config_Constant_Exception($constantName); } - return $constValue = $classRef->getConstant($constantName); + $constantValue = $reflectionClass->getConstant($constantName); + return $constantValue; } /** - * Vypíše (HTML) hodnotu, pokud je zadána a to dle zadaných parametrů + * Vypíše (HTML) hodnotu, pokud je zadána a to dle zadaných parametrů * (tzn. případně vč. tagu. labelu, itemprop a class) - * + * * @author Martin Hlaváč * @link http://www.ktstudio.cz - * + * * @param mixed $value * @param string $tag * @param string $itemprop diff --git a/core/models/kt_wp_options_base_model.inc.php b/core/models/kt_wp_options_base_model.inc.php index fd589ca..d06756f 100644 --- a/core/models/kt_wp_options_base_model.inc.php +++ b/core/models/kt_wp_options_base_model.inc.php @@ -29,10 +29,13 @@ public function __construct($metaPrefix) { * @return mixed */ public function __call($functionName, array $attributes) { - $constValue = $this->getConstantValue($functionName); - - if (KT::issetAndNotEmpty($constValue)) { - return $this->getOption($constValue); + $autoIsserKey = $this->getAutoIsserKey($functionName); + if (KT::issetAndNotEmpty($autoIsserKey)) { + return KT::issetAndNotEmpty($this->getOption($autoIsserKey)); + } + $autoGetterKey = $this->getAutoGetterKey($functionName); + if (KT::issetAndNotEmpty($autoGetterKey)) { + return $this->getOption($autoGetterKey); } } diff --git a/core/models/kt_wp_post_base_model.inc.php b/core/models/kt_wp_post_base_model.inc.php index e37f784..46d5f8a 100644 --- a/core/models/kt_wp_post_base_model.inc.php +++ b/core/models/kt_wp_post_base_model.inc.php @@ -54,10 +54,13 @@ function __construct(WP_Post $post = null, $metaPrefix = null) { * @return mixed */ public function __call($functionName, array $attributes) { - $constValue = $this->getConstantValue($functionName); - - if (KT::issetAndNotEmpty($constValue)) { - return $this->getMetaValue($constValue); + $autoIsserKey = $this->getAutoIsserKey($functionName); + if (KT::issetAndNotEmpty($autoIsserKey)) { + return KT::issetAndNotEmpty($this->getMetaValue($autoIsserKey)); + } + $autoGetterKey = $this->getAutoGetterKey($functionName); + if (KT::issetAndNotEmpty($autoGetterKey)) { + return $this->getMetaValue($autoGetterKey); } } diff --git a/core/models/kt_wp_term_base_model.inc.php b/core/models/kt_wp_term_base_model.inc.php index bff6305..577027a 100644 --- a/core/models/kt_wp_term_base_model.inc.php +++ b/core/models/kt_wp_term_base_model.inc.php @@ -63,10 +63,13 @@ public function __construct($term, $taxonomy = null, $metaPrefix = null) { * @return mixed */ public function __call($functionName, array $attributes) { - $constValue = $this->getConstantValue($functionName); - - if (KT::issetAndNotEmpty($constValue)) { - return $this->getMetaValue($constValue); + $autoIsserKey = $this->getAutoIsserKey($functionName); + if (KT::issetAndNotEmpty($autoIsserKey)) { + return KT::issetAndNotEmpty($this->getMetaValue($autoIsserKey)); + } + $autoGetterKey = $this->getAutoGetterKey($functionName); + if (KT::issetAndNotEmpty($autoGetterKey)) { + return $this->getMetaValue($autoGetterKey); } } diff --git a/core/models/kt_wp_user_base_model.inc.php b/core/models/kt_wp_user_base_model.inc.php index 7b10d81..3699696 100644 --- a/core/models/kt_wp_user_base_model.inc.php +++ b/core/models/kt_wp_user_base_model.inc.php @@ -37,10 +37,13 @@ function __construct($userId, $metaPrefix = null) { * @return mixed */ public function __call($functionName, array $attributes) { - $constValue = $this->getConstantValue($functionName); - - if (KT::issetAndNotEmpty($constValue)) { - return $this->getMetaValue($constValue); + $autoIsserKey = $this->getAutoIsserKey($functionName); + if (KT::issetAndNotEmpty($autoIsserKey)) { + return KT::issetAndNotEmpty($this->getMetaValue($autoIsserKey)); + } + $autoGetterKey = $this->getAutoGetterKey($functionName); + if (KT::issetAndNotEmpty($autoGetterKey)) { + return $this->getMetaValue($autoGetterKey); } } From 319b8724e8590938259c5b05d301e205b3c17645 Mon Sep 17 00:00:00 2001 From: HonzaSC Date: Tue, 10 May 2016 09:54:21 +0200 Subject: [PATCH 14/19] =?UTF-8?q?Oprava=20zp=C4=9Btn=C3=A9=20kompatibility?= =?UTF-8?q?=20pri=20praci=20s=20termy=20-=20konstrucke=20modelu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/presenters/kt_wp_term_base_presenter.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/presenters/kt_wp_term_base_presenter.inc.php b/core/presenters/kt_wp_term_base_presenter.inc.php index fd27ed6..60d78be 100644 --- a/core/presenters/kt_wp_term_base_presenter.inc.php +++ b/core/presenters/kt_wp_term_base_presenter.inc.php @@ -26,7 +26,7 @@ public function __construct($item = null, $taxonomy = null) { * Kvůli zpětné kompatibilitě, časem bude zrušeno -> používejte modely... */ if (KT::issetAndNotEmpty($item)) { - parent::__construct(new KT_WP_Term_Base_Model($item)); + parent::__construct(new KT_WP_Term_Base_Model($item, $taxonomy)); } else { parent::__construct(new KT_WP_Term_Base_Model(get_queried_object())); } From d8dad5e1eba169c442d624389c553e816b716d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Tue, 10 May 2016 15:51:29 +0200 Subject: [PATCH 15/19] =?UTF-8?q?P=C5=99id=C3=A1na=20kontrola=20na=20v?= =?UTF-8?q?=C3=BDpis=20pr=C3=A1zdn=C3=A9ho=20excerptu=20anebo=20contentu?= =?UTF-8?q?=20v=20r=C3=A1mci=20odpov=C3=ADdaj=C3=ADc=C3=ADch=20metod=20na?= =?UTF-8?q?=20KT=5FWP=5FPost=5FBase=5FModelu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tj. ->getExcerpt() a getContent() --- core/models/kt_wp_post_base_model.inc.php | 24 +++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/models/kt_wp_post_base_model.inc.php b/core/models/kt_wp_post_base_model.inc.php index 46d5f8a..8fb2e90 100644 --- a/core/models/kt_wp_post_base_model.inc.php +++ b/core/models/kt_wp_post_base_model.inc.php @@ -274,10 +274,12 @@ public function getContent($withTheFilter = true) { $post = $this->getPost(); if (KT::issetAndNotEmpty($post)) { $content = $post->post_content; - if ($withTheFilter) { - return apply_filters("the_content", $content); + if (KT::issetAndNotEmpty($content)) { + if ($withTheFilter) { + return apply_filters("the_content", $content); + } + return apply_filters("get_the_content", $content); } - return apply_filters("get_the_content", $content); } return null; } @@ -310,15 +312,17 @@ public function getExcerpt($withTheFilter = true, $customExcerptLength = null, $ } else { $excerpt = $post->post_content; } - $excerptMore = $customExcerptMore ? : apply_filters("excerpt_more", " […]"); - $excerptLength = $customExcerptLength ? : apply_filters("excerpt_length", self::DEFAULT_EXCERPT_LENGTH); - $excerpt = wp_trim_words($excerpt, $excerptLength, $excerptMore); if (KT::issetAndNotEmpty($excerpt)) { - $excerptFilterered = apply_filters("get_the_excerpt", $excerpt); - if ($withTheFilter) { - return apply_filters("the_excerpt", $excerptFilterered); + $excerptMore = $customExcerptMore ?: apply_filters("excerpt_more", " […]"); + $excerptLength = $customExcerptLength ?: apply_filters("excerpt_length", self::DEFAULT_EXCERPT_LENGTH); + $excerpt = wp_trim_words($excerpt, $excerptLength, $excerptMore); + if (KT::issetAndNotEmpty($excerpt)) { + $excerptFilterered = apply_filters("get_the_excerpt", $excerpt); + if ($withTheFilter) { + return apply_filters("the_excerpt", $excerptFilterered); + } + return strip_shortcodes(strip_tags($excerptFilterered)); } - return strip_shortcodes(strip_tags($excerptFilterered)); } } return null; From 77e2169998afae4253199f0c79793cdb205b6b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Wed, 11 May 2016 14:17:49 +0200 Subject: [PATCH 16/19] =?UTF-8?q?=C3=9Aprava=20v=C3=BDpisu,=20resp.=20p?= =?UTF-8?q?=C5=99=C3=ADprava=20ajax=20Cookie=20Statement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nově se vypisuje pouze div container a je třeba ještě implementovat JS skript, který vyvolá (WP) ajax pro načtení obsahu samotného Cookie Statement bloku kvůli (různým) cachovacím pluginům a technikám. --- .../configurator/kt_wp_configurator.inc.php | 29 +++++++++++++------ .../functions/kt_general_functions.inc.php | 13 +++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/core/classes/configurator/kt_wp_configurator.inc.php b/core/classes/configurator/kt_wp_configurator.inc.php index f103101..858707d 100644 --- a/core/classes/configurator/kt_wp_configurator.inc.php +++ b/core/classes/configurator/kt_wp_configurator.inc.php @@ -1392,6 +1392,17 @@ public function endSession() { * @link http://www.ktstudio.cz */ public function renderCookieStatement() { + echo "
"; + } + + /** + * Vrátí obsah proužku s potvrzením cookie (v patičce) + * NENÍ POTŘEBA VOLAT VEŘEJNĚ + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + */ + public static function getCookieStatementHtml() { $cookueStatementKey = KT::arrayTryGetValue($_COOKIE, self::COOKIE_STATEMENT_KEY); if (KT::notIssetOrEmpty($cookueStatementKey)) { $text = __("Tyto stránky využívají Cookies. Používáním těchto stránek vyjadřujete souhlas s používáním Cookies.", "KT_CORE_DOMAIN"); @@ -1399,17 +1410,17 @@ public function renderCookieStatement() { $moreInfoUrl = apply_filters("kt_cookie_statement_more_info_url_filter", "https://www.google.com/policies/technologies/cookies/"); $confirmTitle = __("OK, rozumím", "KT_CORE_DOMAIN"); - $content = "$text"; - $content .= "$moreInfoTitle"; - $content .= "$confirmTitle"; + $html = "$text"; + $html .= "$moreInfoTitle"; + $html .= "$confirmTitle"; - echo ""; - echo "
"; - echo apply_filters("kt_cookie_statement_content_filter", $content); - echo "
"; - echo ""; - echo ""; + $content = apply_filters("kt_cookie_statement_content_filter", $html); + + $output = "
$content
"; + $output .= ""; + return $output; } + return null; } // --- statické funkce -------------- diff --git a/core/requires/functions/kt_general_functions.inc.php b/core/requires/functions/kt_general_functions.inc.php index 1d1e74a..0f25659 100644 --- a/core/requires/functions/kt_general_functions.inc.php +++ b/core/requires/functions/kt_general_functions.inc.php @@ -95,3 +95,16 @@ function kt_wp_before_admin_bar_render_callback() { "href" => admin_url("themes.php") . "?page=" . KT_WP_Configurator::THEME_SETTING_PAGE_SLUG, )); } + +add_action("wp_ajax_kt_load_cookie_statement_content", "kt_load_cookie_statement_content_callback"); +add_action("wp_ajax_nopriv_kt_load_cookie_statement_content", "kt_load_cookie_statement_content_callback"); + +/** + * Funce zajistí načtení, resp. vrácení cookie statement obsahu ajaxem + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + */ +function kt_load_cookie_statement_content_callback() { + die(KT_WP_Configurator::getCookieStatementHtml()); +} From 9e8b5dff7a2246c2d823824d04fd3a89ea533eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Fri, 13 May 2016 08:49:35 +0200 Subject: [PATCH 17/19] =?UTF-8?q?=C3=9Aprava=20kontroly=20inicializace=20v?= =?UTF-8?q?=20getrech=20na=20KT=5FContact=5FForm=5FBase=5FPresenteru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/presenters/kt_contact_form_base_presenter.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/presenters/kt_contact_form_base_presenter.inc.php b/core/presenters/kt_contact_form_base_presenter.inc.php index 8c9711c..a8e0b4a 100644 --- a/core/presenters/kt_contact_form_base_presenter.inc.php +++ b/core/presenters/kt_contact_form_base_presenter.inc.php @@ -52,7 +52,7 @@ public function __construct($withProcessing = true) { * @return \KT_Form */ public function getForm() { - if (KT::issetAndNotEmpty($this->form)) { + if (isset($this->form)) { return $this->form; } return $this->initForm(); @@ -67,7 +67,7 @@ public function getForm() { * @return \KT_Form_Fieldset */ public function getFieldset() { - if (KT::issetAndNotEmpty($this->fieldset)) { + if (isset($this->fieldset)) { return $this->fieldset; } return $this->initFieldset(); From 1b8542976a817918a6b254c10036dafe79555197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Fri, 13 May 2016 13:49:48 +0200 Subject: [PATCH 18/19] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20KT=5FWP=5FConfig?= =?UTF-8?q?urator->setPostsArchiveSlug("blog")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nově je možné jen na základě vlastního slugu aktivovat klasicky archive i pro příspěvky, např. za účelem výpisu blogu --- .../configurator/kt_wp_configurator.inc.php | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/core/classes/configurator/kt_wp_configurator.inc.php b/core/classes/configurator/kt_wp_configurator.inc.php index 858707d..053d866 100644 --- a/core/classes/configurator/kt_wp_configurator.inc.php +++ b/core/classes/configurator/kt_wp_configurator.inc.php @@ -39,6 +39,7 @@ final class KT_WP_Configurator { private $imagesLazyLoading = null; private $imagesLinkClasses = null; private $postArchiveMenu = null; + private $postsArchiveSlug = null; private $allowSession = false; private $allowCookieStatement = false; private $facebookManager = null; @@ -166,6 +167,13 @@ private function getPostArchiveMenu() { return $this->postArchiveMenu; } + /** + * @return string + */ + private function getPostsArchiveSlug() { + return $this->postsArchiveSlug; + } + /** * @return \KT_WP_Asset_Configurator */ @@ -410,6 +418,20 @@ public function setPostArchiveMenu($postArchiveMenu = true) { return $this; } + /** + * Aktivace archivu pro příspěvky na základě vlastního slugu + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + * + * @param string $postsArchiveSlug + * @return \KT_WP_Configurator + */ + public function setPostsArchiveSlug($postsArchiveSlug = "blog") { + $this->postsArchiveSlug = $postsArchiveSlug; + return $this; + } + /** * Aktivace automatické aplikace lazy loadingu na obrázky pomocí skriptu unveil * @@ -554,6 +576,9 @@ public function initialize() { } elseif ($postArchiveMenu === false) { add_filter("wp_get_nav_menu_items", array($this, "postArchivesMenuFilter"), 10); } + if (KT::issetAndNotEmpty($this->getPostsArchiveSlug())) { + add_action("init", array($this, "addPostsArchiveDefinitionRewrite")); + } if (is_admin()) { // archivy post typů v menu if ($postArchiveMenu === true) { @@ -1350,6 +1375,22 @@ public function postArchivesMenuFilter($items) { } return $items; } + + /** + * Provede inicializaci definice post typu a rewritu pro archiv příspěvků + * NENÍ POTŘEBA VOLAT VEŘEJNĚ + * + * @author Martin Hlaváč + * @link http://www.ktstudio.cz + */ + public function addPostsArchiveDefinitionRewrite() { + global $wp_post_types; + + $wp_post_types["post"]->has_archive = $this->getPostsArchiveSlug(); + $wp_post_types["post"]->rewrite = array("with_front" => true, "feeds" => false); + + add_rewrite_rule("{$this->getPostsArchiveSlug()}/?$", sprintf("index.php?post_type=%s", KT_WP_POST_KEY), "top"); + } /** * Provede inicializaci facebook modulu a výpíše OG tagy do hlavičky webu @@ -1415,7 +1456,7 @@ public static function getCookieStatementHtml() { $html .= "$confirmTitle"; $content = apply_filters("kt_cookie_statement_content_filter", $html); - + $output = "
$content
"; $output .= ""; return $output; From ed87741ab6b3c84bf78b1b519aeb6eb6d6e5fda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hlav=C3=A1=C4=8D?= Date: Sun, 22 May 2016 19:37:22 +0200 Subject: [PATCH 19/19] =?UTF-8?q?P=C5=99id=C3=A1na=20mo=C5=BEnost=20=C5=99?= =?UTF-8?q?et=C4=9Bzit=20vol=C3=A1n=C3=AD=20metod=20addColumn=20a=20remove?= =?UTF-8?q?Column=20v=20r=C3=A1mci=20KT=5FAdmin=5FColumns?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/classes/kt_admin_columns.inc.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/classes/kt_admin_columns.inc.php b/core/classes/kt_admin_columns.inc.php index c5eb179..391403a 100644 --- a/core/classes/kt_admin_columns.inc.php +++ b/core/classes/kt_admin_columns.inc.php @@ -177,14 +177,15 @@ public function addColumn($key, $args) { self::INDEX_PARAM_KEY => null, ); $this->columns[$key] = array_merge($defaults, $args); - if ($this->columns[$key][self::SORTABLE_PARAM_KEY]) { $this->sortableColumns[$key] = $this->columns[$key]; } + return $this; } public function removeColumn($key) { $this->removeColumns[] = $key; + return $this; } }