Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
hlavacm committed May 22, 2016
2 parents 41520ca + ed87741 commit a2ea912
Show file tree
Hide file tree
Showing 20 changed files with 383 additions and 147 deletions.
147 changes: 121 additions & 26 deletions core/classes/configurator/kt_wp_configurator.inc.php
Expand Up @@ -37,7 +37,9 @@ final class KT_WP_Configurator {
private $displayLogo = true;
private $assetsConfigurator = null;
private $imagesLazyLoading = null;
private $imagesLinkClasses = null;
private $postArchiveMenu = null;
private $postsArchiveSlug = null;
private $allowSession = false;
private $allowCookieStatement = false;
private $facebookManager = null;
Expand Down Expand Up @@ -151,13 +153,27 @@ private function getImagesLazyLoading() {
return $this->imagesLazyLoading;
}

/**
* @return boolean
*/
private function getImagesLinkClasses() {
return $this->imagesLinkClasses;
}

/**
* @return boolean
*/
private function getPostArchiveMenu() {
return $this->postArchiveMenu;
}

/**
* @return string
*/
private function getPostsArchiveSlug() {
return $this->postsArchiveSlug;
}

/**
* @return \KT_WP_Asset_Configurator
*/
Expand Down Expand Up @@ -191,7 +207,7 @@ public function getFacebookManager() {
}

/**
*
*
* @return boolean
*/
public function getEmojiSwitch() {
Expand All @@ -202,10 +218,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
*/
Expand All @@ -217,10 +233,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
*/
Expand All @@ -232,10 +248,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
*/
Expand All @@ -246,10 +262,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
*/
Expand Down Expand Up @@ -337,10 +353,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
*/
Expand All @@ -351,10 +367,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
*/
Expand All @@ -376,10 +392,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
*/
Expand All @@ -402,9 +418,23 @@ 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
*
*
* @author Martin Hlaváč
* @link http://www.ktstudio.cz
*/
Expand All @@ -413,6 +443,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
*
Expand Down Expand Up @@ -535,13 +576,23 @@ 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) {
add_action("admin_head-nav-menus.php", array($this, "addPostArchivesMenuMetaBox"));
} 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 {
// (images) lazy loading
$imagesLazyLoading = $this->getImagesLazyLoading();
Expand Down Expand Up @@ -1221,6 +1272,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('/<a.*? class=".*?">/', $html)) {
$html = preg_replace('/(<a.*? class=".*?)(".*?>)/', "$1 {$class}$2", $html);
} else {
$html = preg_replace('/(<a.*?)>/', "$1 class=\"$class\" >", $html);
}
return $html;
}

/**
* Přidání metaboxu pro archivy post typů v menu
* NENÍ POTŘEBA VOLAT VEŘEJNĚ
Expand Down Expand Up @@ -1307,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
Expand Down Expand Up @@ -1349,24 +1433,35 @@ public function endSession() {
* @link http://www.ktstudio.cz
*/
public function renderCookieStatement() {
echo "<div id=\"ktCookieStatementContainer\"></div>";
}

/**
* 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");
$moreInfoTitle = __("Zjistit více", "KT_CORE_DOMAIN");
$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 = "<span id=\"ktCookieStatementText\">$text</span>";
$content .= "<span id=\"ktCookieStatementMoreInfo\"><a href=\"$moreInfoUrl\" title=\"$moreInfoTitle\" target=\"_blank\">$moreInfoTitle</a></span>";
$content .= "<span id=\"ktCookieStatementConfirm\">$confirmTitle</span>";
$html = "<span id=\"ktCookieStatementText\">$text</span>";
$html .= "<span id=\"ktCookieStatementMoreInfo\"><a href=\"$moreInfoUrl\" title=\"$moreInfoTitle\" target=\"_blank\">$moreInfoTitle</a></span>";
$html .= "<span id=\"ktCookieStatementConfirm\">$confirmTitle</span>";

$content = apply_filters("kt_cookie_statement_content_filter", $html);

echo "<!-- ktcookiestatement W3TC_DYNAMIC_SECURITY -->";
echo "<div id=\"ktCookieStatement\">";
echo apply_filters("kt_cookie_statement_content_filter", $content);
echo "</div>";
echo "<noscript><style scoped>#ktCookieStatement { display:none; }</style></noscript>";
echo "<!-- /ktcookiestatement W3TC_DYNAMIC_SECURITY -->";
$output = "<div id=\"ktCookieStatement\">$content</div>";
$output .= "<noscript><style scoped>#ktCookieStatement { display:none; }</style></noscript>";
return $output;
}
return null;
}

// --- statické funkce --------------
Expand All @@ -1382,7 +1477,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
*
Expand Down
2 changes: 1 addition & 1 deletion core/classes/crud/kt_crud.inc.php
Expand Up @@ -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 == "") {
Expand Down
56 changes: 28 additions & 28 deletions core/classes/fields/kt_wp_editor_field.inc.php
@@ -1,43 +1,43 @@
<?php

class KT_WP_Editor_Field extends KT_Field{
class KT_WP_Editor_Field extends KT_Field {

const FIELD_TYPE = "wp-editor";

public function __construct($name, $label) {
parent::__construct($name, $label);
$this->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
));
}

}

0 comments on commit a2ea912

Please sign in to comment.