Changeset 1921451
- Timestamp:
- 08/08/2018 09:02:36 AM (8 years ago)
- Location:
- plenigo/trunk
- Files:
-
- 14 edited
-
plenigo_i18n/plenigo-de_DE.mo (modified) (previous)
-
plenigo_i18n/plenigo-en_US.mo (modified) (previous)
-
plenigo_plugin/PlenigoContentManager.php (modified) (6 diffs)
-
plenigo_plugin/PlenigoSDKManager.php (modified) (1 diff)
-
plenigo_plugin/settings/PlenigoWPSetting.php (modified) (2 diffs)
-
plenigo_plugin/settings/SettingCategoryTagDB.php (modified) (2 diffs)
-
plenigo_plugin/settings/SettingCurtainBuyTextDB.php (modified) (3 diffs)
-
plenigo_plugin/settings/SettingCustomCurtainDB.php (modified) (1 diff)
-
plenigo_plugin/settings/SettingPreventTag.php (modified) (2 diffs)
-
plenigo_plugin/settings/SettingProductGroupOneDB.php (modified) (1 diff)
-
plenigo_plugin/settings/SettingProductGroupTwoDB.php (modified) (1 diff)
-
plenigo_plugin/settings/SettingProductTagDB.php (modified) (2 diffs)
-
plenigo_wordpress.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
plenigo/trunk/plenigo_plugin/PlenigoContentManager.php
r1920340 r1921451 368 368 $typesPluginPaywall = function_exists('types_render_field') && types_render_field("paywall"); 369 369 // Do not paywall if nothing is configured 370 370 371 if (trim($plenigoTagDB) === '' && trim($plenigoCatTagDB) === '' && !$typesPluginPaywall) { 371 372 plenigo_log_message("NO TAGS CONFIGURED"); 372 373 return FALSE; 373 374 } 375 376 // var_dump(PlenigoSDKManager::get()->isPayWallEnabled()); 374 377 375 378 // If Paywall is disabled, we dont check anything … … 431 434 } 432 435 433 /** 434 * This method checks for category IDs that need to be added to the category list 435 * so it can be checked for bought products. Returns FALSE if there is no tag 436 * found on the article that reflects a tag in the plenigo settings 437 * 438 * @return bool Returns TRUE if a tag has been found and the category list is in the cache 439 */ 440 public function hasAnyCategoryTag() { 441 if (isset($this->reqCache["hasAnyCategoryTag"])) { 442 $this->addDebugLine("[Cached] has Category Tag: " . $this->reqCache["hasAnyCategoryTag"]); 443 return $this->reqCache["hasAnyCategoryTag"]; 444 } 445 $catTagList = (isset($this->options['plenigo_cat_tag_db']) ? $this->options['plenigo_cat_tag_db'] : ''); 446 $res = FALSE; 447 //TAGS WITH CATEGORY IDS 448 $rowSplit = explode("\n", $catTagList); 436 protected function postHasTerm($configRow) { 437 $strTag = explode("->", $configRow); 438 $arrToken = array(); 439 //Obtain the {slug} or {id} 440 preg_match('/{(.*?)}/', $strTag[0], $arrToken); 441 442 if (is_numeric($arrToken[1])) { 443 $categories = $this->getCategoryChildren(intval($arrToken[1])); 444 } else { 445 $categories = $arrToken[1]; 446 } 447 448 return ($strTag !== FALSE && count($strTag) == 2 && count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($categories))); 449 } 450 451 /** 452 * @param string $tagList 453 * @param string $type 454 * @return bool 455 */ 456 protected function hasTerm($tagList, $type = 'Product') { 457 $shortType = $type === 'Product' ? 'Prod' : 'Cat'; 458 $rowSplit = explode("\n", $tagList); 459 $res = false; 449 460 if ($rowSplit === FALSE || count($rowSplit) == 0) { 450 $rowSplit = array($catTagList); 451 } 461 $rowSplit = array($tagList); 462 } 463 452 464 foreach ($rowSplit as $tagRow) { 453 465 $strTag = explode("->", $tagRow); 454 466 $arrToken = array(); 455 //Obtain the {slug} 467 //Obtain the {slug} or {id} 456 468 preg_match('/{(.*?)}/', $strTag[0], $arrToken); 457 if ($strTag !== FALSE && count($strTag) == 2 && count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($arrToken[1]))) { 458 plenigo_log_message("Category TAG! TAG=" . $strTag[0] . " CategoryID(s):" . $strTag[1]); 459 $this->addDebugLine("Category match: " . $strTag[0]); 469 470 if (is_numeric($arrToken[1])) { 471 $categories = $this->getCategoryChildren(intval($arrToken[1])); 472 } else { 473 $categories = $arrToken[1]; 474 } 475 476 if ($strTag !== FALSE && count($strTag) == 2 && count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($categories))) { 477 plenigo_log_message("{$type} TAG! TAG=" . $strTag[0] . " {$type}ID(s):" . $strTag[1]); 478 $this->addDebugLine("{$type} match: " . $strTag[0]); 460 479 $arrCats = array(); 461 480 //Support for multiple ids in one tag … … 466 485 } 467 486 foreach ($arrCats as $cid) { 468 if (!isset($this->reqCache["last CatId"])) {469 $this->reqCache["last CatId"] = trim($cid);470 $this->reqCache["last CatTag"] = trim($arrToken[1]);487 if (!isset($this->reqCache["last{$shortType}Id"])) { 488 $this->reqCache["last{$shortType}Id"] = trim($cid); 489 $this->reqCache["last{$shortType}Tag"] = trim($arrToken[1]); 471 490 } 472 array_push($this->reqCache["list CatId"], trim($cid));473 array_push($this->reqCache["list CatTag"], trim($arrToken[1]));491 array_push($this->reqCache["list{$shortType}Id"], trim($cid)); 492 array_push($this->reqCache["list{$shortType}Tag"], trim($arrToken[1])); 474 493 $res = TRUE; 475 494 } 476 495 } 477 496 } 497 return $res; 498 } 499 500 /** 501 * This method checks for category IDs that need to be added to the category list 502 * so it can be checked for bought products. Returns FALSE if there is no tag 503 * found on the article that reflects a tag in the plenigo settings 504 * 505 * @return bool Returns TRUE if a tag has been found and the category list is in the cache 506 */ 507 public function hasAnyCategoryTag() { 508 if (isset($this->reqCache["hasAnyCategoryTag"])) { 509 $this->addDebugLine("[Cached] has Category Tag: " . $this->reqCache["hasAnyCategoryTag"]); 510 return $this->reqCache["hasAnyCategoryTag"]; 511 } 512 $catTagList = (isset($this->options['plenigo_cat_tag_db']) ? $this->options['plenigo_cat_tag_db'] : ''); 513 $res = FALSE; 514 //TAGS WITH CATEGORY IDS 515 516 if (!empty($catTagList)) { 517 $res = $this->hasTerm($catTagList, 'Category'); 518 } 519 478 520 if ($res === TRUE) { 479 521 $this->addDebugLine("Categories: " . var_export($this->reqCache["listCatId"], TRUE)); … … 497 539 $arrToken = array(); 498 540 preg_match('/{(.*?)}/', $prevTag, $arrToken); 499 if (count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($arrToken[1]))) { 541 542 if (is_numeric($arrToken[1])) { 543 $categories = $this->getCategoryChildren(intval($arrToken[1])); 544 } else { 545 $categories = $arrToken[1]; 546 } 547 548 if (count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($categories))) { 500 549 plenigo_log_message("Prevent TAG! TAG=" . $prevTag); 501 550 $this->addDebugLine("Prevent Tag: " . $prevTag); … … 508 557 } 509 558 $this->reqCache["hasPreventTag"] = $res; 559 510 560 return $res; 561 } 562 563 private function getCategoryChildren($id) { 564 565 $categories = array(); 566 $categories[$id] = $id; 567 568 $cats = get_categories( array( 'parent' => $id )); 569 570 if (empty($cats)) { 571 return $categories; 572 } 573 574 foreach ($cats as $category) { 575 $categories[$category->term_id] = $category->term_id; 576 $sub = $this->getCategoryChildren($category->term_id); 577 if (!empty($sub)) { 578 $categories = array_merge($categories, $sub); 579 } 580 } 581 582 return $categories; 511 583 } 512 584 … … 526 598 $res = FALSE; 527 599 //TAGS WITH PRODUCT IDS 528 $rowSplit = explode("\n", $prodTagList); 529 if ($rowSplit == FALSE || count($rowSplit) == 0) { 530 $rowSplit = array($prodTagList); 531 } 532 533 foreach ($rowSplit as $tagRow) { 534 $strTag = explode("->", $tagRow); 535 $arrToken = array(); 536 //Obtain the {slug} 537 preg_match('/{(.*?)}/', $strTag[0], $arrToken); 538 539 if ($strTag !== FALSE && count($strTag) == 2 && count($arrToken) == 2 && (has_tag($arrToken[1]) || has_category($arrToken[1]))) { 540 plenigo_log_message("Product TAG! TAG=" . $strTag[0] . " ProductID(s):" . $strTag[1]); 541 $this->addDebugLine("Product match: " . $strTag[0]); 542 $arrProds = array(); 543 //Support for multiple ids in one tag 544 if (stristr($strTag[1], ',')) { 545 $arrProds = explode(',', $strTag[1]); 546 } else { 547 $arrProds = array($strTag[1]); 548 } 549 foreach ($arrProds as $pid) { 550 if (!isset($this->reqCache["lastProdId"])) { 551 $this->reqCache["lastProdId"] = trim($pid); 552 $this->reqCache["lastProdTag"] = trim($arrToken[1]); 553 } 554 array_push($this->reqCache["listProdId"], trim($pid)); 555 array_push($this->reqCache["listProdTag"], trim($arrToken[1])); 556 557 $res = TRUE; 558 } 559 } 560 } 600 601 if (!empty($prodTagList)) { 602 603 $res = $this->hasTerm($prodTagList, 'Product'); 604 605 } 606 561 607 if ($res === TRUE) { 562 608 $this->addDebugLine("Products: " . var_export($this->reqCache["listProdId"], TRUE)); -
plenigo/trunk/plenigo_plugin/PlenigoSDKManager.php
r1919357 r1921451 35 35 * Holds values for the SDK requests, so they are made just once per request 36 36 */ 37 private $reqCache = array();37 // private $reqCache = array(); 38 38 39 39 /** -
plenigo/trunk/plenigo_plugin/settings/PlenigoWPSetting.php
r1919357 r1921451 38 38 39 39 private $store = array(); 40 41 protected $reqCache = array(); 40 42 41 43 public function __construct() … … 118 120 } 119 121 122 final protected function getCategoryChildren($id) { 123 124 $categories = array(); 125 $categories[$id] = $id; 126 127 $cats = get_categories( array( 'parent' => $id )); 128 129 var_dump($cats); 130 if (empty($cats)) { 131 return implode('|', $categories); 132 } 133 134 foreach ($cats as $category) { 135 $categories[$category->term_id] = $category->term_id; 136 $sub = $this->getCategoryChildren($category->term_id); 137 if (!empty($sub)) { 138 $categories = array_merge($categories, $sub); 139 } 140 } 141 142 return implode('|', $categories); 143 } 144 145 /** 146 * This method allows the autocomplete field to populate with all the current tag values 147 * 148 * @global type $wpdb The WordPress database object 149 * @return string A comma separated list of all existing tags 150 */ 151 final protected function get_term_data() 152 { 153 if (isset($this->reqCache['term-query'])) { 154 return $this->reqCache['term-query']; 155 } 156 global $wpdb; 157 $res = ''; 158 $type = ''; 159 160 $search_tags = $wpdb->get_results("SELECT a.name,a.slug,a.term_id as id,b.taxonomy FROM " . $wpdb->terms 161 . " a," . $wpdb->term_taxonomy . " b WHERE a.term_id=b.term_id " 162 . " and (b.taxonomy='post_tag' or b.taxonomy='category') "); 163 foreach ($search_tags as $mytag) { 164 if (strlen($res) !== 0) { 165 $res.=","; 166 } 167 $type = $mytag->taxonomy == 'category' ? 'Categories' : 'Tags'; 168 $res.= str_replace('"', '', $mytag->name) . " ({$type}) " . "{" . ($mytag->id) . "}"; 169 } 170 $this->reqCache['term-query'] = $res; 171 return $res; 172 } 173 174 120 175 } -
plenigo/trunk/plenigo_plugin/settings/SettingCategoryTagDB.php
r1920340 r1921451 38 38 * Holds values for storing values, so they are generated just once per request 39 39 */ 40 private $reqCache = array();40 // private $reqCache = array(); 41 41 42 42 /** … … 148 148 } 149 149 150 /**151 * This method allows the autocomplete field to populate with all the current tag values152 *153 * @global type $wpdb The WordPress database object154 * @return string A comma separated list of all existing tags155 */156 private function get_term_data()157 {158 if (isset($this->reqCache['term-query'])) {159 return $this->reqCache['term-query'];160 }161 global $wpdb;162 $res = '';163 $type = '';164 165 $search_tags = $wpdb->get_results("SELECT a.name,a.slug,b.taxonomy FROM " . $wpdb->terms166 . " a," . $wpdb->term_taxonomy . " b WHERE a.term_id=b.term_id "167 . " and (b.taxonomy='post_tag' or b.taxonomy='category') ");168 foreach ($search_tags as $mytag) {169 if (strlen($res) !== 0) {170 $res.=",";171 }172 $type = $mytag->taxonomy == 'category' ? 'Categories' : 'Tags';173 $res.= $mytag->name . " ({$type}) " . "{" . $mytag->slug . "}";174 }175 $this->reqCache['term-query'] = $res;176 return $res;177 }178 179 150 } -
plenigo/trunk/plenigo_plugin/settings/SettingCurtainBuyTextDB.php
r1920340 r1921451 38 38 * Holds values for storing values, so they are generated just once per request 39 39 */ 40 private $reqCache = array();40 // private $reqCache = array(); 41 41 42 42 /** … … 88 88 . 'jQuery(document).ready(function(){' 89 89 . 'var data = "' . $this->get_term_data() . '".split(",");' 90 . 'jQuery("#tag_buy_text_adder").autocomplete({source:data,autoFocus:true}); });'90 . 'jQuery("#tag_buy_text_adder").autocomplete({source:data,autoFocus:true});' 91 91 . 'function addValuesToBuyTextArea(){' 92 92 . 'var strPrev=jQuery("#' . static::SETTING_ID . '").val();' … … 148 148 } 149 149 150 /**151 * This method allows the autocomplete field to populate with all the current tag values152 *153 * @global type $wpdb The WordPress database object154 * @return string A comma separated list of all existing tags155 */156 private function get_term_data()157 {158 if (isset($this->reqCache['term-query'])) {159 return $this->reqCache['term-query'];160 }161 global $wpdb;162 $res = '';163 $type = '';164 165 $search_tags = $wpdb->get_results("SELECT a.name,a.slug,b.taxonomy FROM " . $wpdb->terms166 . " a," . $wpdb->term_taxonomy . " b WHERE a.term_id=b.term_id "167 . " and (b.taxonomy='post_tag' or b.taxonomy='category') ");168 foreach ($search_tags as $mytag) {169 if (strlen($res) !== 0) {170 $res.=",";171 }172 $type = $mytag->taxonomy == 'category' ? 'Categories' : 'Tags';173 $res.= $mytag->name . " ({$type}) " . "{" . $mytag->slug . "}";174 }175 $this->reqCache['term-query'] = $res;176 return $res;177 }178 150 } -
plenigo/trunk/plenigo_plugin/settings/SettingCustomCurtainDB.php
r1919357 r1921451 39 39 * Holds values for the SQL requests, so they are made just once per request 40 40 */ 41 private $reqCache = array();41 // private $reqCache = array(); 42 42 43 43 /** -
plenigo/trunk/plenigo_plugin/settings/SettingPreventTag.php
r1920340 r1921451 38 38 * Holds values for the SQL requests, so they are made just once per request 39 39 */ 40 private $reqCache = array();40 // private $reqCache = array(); 41 41 42 42 /** … … 99 99 } 100 100 101 private function get_term_data()102 {103 if (isset($this->reqCache['term-query'])) {104 return $this->reqCache['term-query'];105 }106 global $wpdb;107 $res = '';108 $type = '';109 110 $search_tags = $wpdb->get_results("SELECT a.name,a.slug,b.taxonomy FROM " . $wpdb->terms111 . " a," . $wpdb->term_taxonomy . " b WHERE a.term_id=b.term_id "112 . " and (b.taxonomy='post_tag' or b.taxonomy='category') ");113 foreach ($search_tags as $mytag) {114 if (strlen($res) !== 0) {115 $res.=",";116 }117 $type = $mytag->taxonomy == 'category' ? 'Categories' : 'Tags';118 $res.= $mytag->name . " ({$type}) " . "{" . $mytag->slug . "}";119 }120 $this->reqCache['term-query'] = $res;121 return $res;122 }123 101 124 102 } -
plenigo/trunk/plenigo_plugin/settings/SettingProductGroupOneDB.php
r1919357 r1921451 37 37 * Holds values for the SQL requests, so they are made just once per request 38 38 */ 39 private $reqCache = array();39 // private $reqCache = array(); 40 40 41 41 /** -
plenigo/trunk/plenigo_plugin/settings/SettingProductGroupTwoDB.php
r1919357 r1921451 37 37 * Holds values for the SQL requests, so they are made just once per request 38 38 */ 39 private $reqCache = array();39 // private $reqCache = array(); 40 40 41 41 /** -
plenigo/trunk/plenigo_plugin/settings/SettingProductTagDB.php
r1919357 r1921451 38 38 * Holds values for the SQL requests, so they are made just once per request 39 39 */ 40 private $reqCache = array();40 // private $reqCache = array(); 41 41 42 42 /** … … 148 148 } 149 149 150 private function get_term_data()151 {152 if (isset($this->reqCache['term-query'])) {153 return $this->reqCache['term-query'];154 }155 global $wpdb;156 $res = '';157 $type = '';158 159 $search_tags = $wpdb->get_results("SELECT a.name,a.slug,b.taxonomy FROM " . $wpdb->terms160 . " a," . $wpdb->term_taxonomy . " b WHERE a.term_id=b.term_id "161 . " and (b.taxonomy='post_tag' or b.taxonomy='category') ");162 foreach ($search_tags as $mytag) {163 if (strlen($res) !== 0) {164 $res.=",";165 }166 $type = $mytag->taxonomy == 'category' ? 'Categories' : 'Tags';167 $res.= $mytag->name . " ({$type}) " . "{" . $mytag->slug . "}";168 }169 $this->reqCache['term-query'] = $res;170 return $res;171 }172 173 150 } -
plenigo/trunk/plenigo_wordpress.php
r1920340 r1921451 5 5 Plugin URI: http://wordpress.org/plugins/plenigo/ 6 6 Description: So far, the technical implementation of paid content has been time-consuming and costly for publishing houses and media companies. plenigo puts an end to this. 7 Version: 1.7. 77 Version: 1.7.8 8 8 Author: Plenigo 9 9 Author URI: https://www.plenigo.com … … 30 30 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 31 31 */ 32 define('PLENIGO_VERSION', '1.7. 7');32 define('PLENIGO_VERSION', '1.7.8'); 33 33 34 34 // Plenigo JavaScript SDK / Services -
plenigo/trunk/readme.txt
r1920340 r1921451 4 4 Requires at least: 4.0.0 5 5 Tested up to: 4.9.1 6 Stable tag: 1.7. 76 Stable tag: 1.7.8 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 299 299 300 300 == Changelog == 301 = 1.7.8 - Fixed Displaying Categories with quotes 302 301 303 = 1.7.7 - Fixed Translations 302 304
Note: See TracChangeset
for help on using the changeset viewer.