| @@ -1,7 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | +namespace MaxButtons; | |
| 2 | 3 | defined('ABSPATH') or die('No direct access permitted'); |
| 3 | 4 | |
| 5 | +use \RecursiveDirectoryIterator as RecursiveDirectoryIterator; | |
| 6 | +use \FilesystemIterator as FilesystemIterator; | |
| 7 | +use \RecursiveIteratorIterator as RecursiveIteratorIterator; | |
| 8 | + | |
| 9 | + | |
| 4 | 10 | class maxCollections |
| 5 | 11 | { |
| 6 | 12 | static $init = false; |
| 7 | 13 | //static $collections = array(); |
| @@ -62,9 +68,10 @@ | ||
| 62 | 68 | { |
| 63 | 69 | // check for admin side, we need not hooks nor queries for this. |
| 64 | 70 | if (is_admin()) |
| 65 | 71 | return; |
| 66 | - | |
| 72 | + | |
| 73 | + | |
| 67 | 74 | global $pagenow; |
| 68 | 75 | if ( in_array($pagenow, array('wp-login.php', 'wp-register.php')) ) |
| 69 | 76 | return; |
| 70 | 77 | |
| @@ -70,9 +77,11 @@ | ||
| 70 | 77 | |
| 71 | 78 | global $wpdb; |
| 72 | 79 | $table = maxUtils::get_collection_table_name(); |
| 73 | 80 | $sql = "select collection_id, collection_key, collection_value from $table where |
| 74 | - collection_key in ('show_homepage','show_page','show_post', 'show_archive') "; | |
| 81 | + collection_key in ('show_homepage','show_page','show_post', 'show_archive') | |
| 82 | + and collection_id IN (select collection_id from $table where collection_key = 'collection_type' | |
| 83 | + and collection_value = 'social' ) "; | |
| 75 | 84 | $results = $wpdb->get_results($sql, ARRAY_A); |
| 76 | 85 | |
| 77 | 86 | $hook_array = array(); |
| 78 | 87 | |
| @@ -105,16 +114,18 @@ | ||
| 105 | 114 | |
| 106 | 115 | |
| 107 | 116 | self::$hooks = $hook_array; |
| 108 | 117 | |
| 118 | + | |
| 119 | + | |
| 109 | 120 | if (isset($hook_array["post"]) && count($hook_array["post"]) > 0) |
| 110 | 121 | { |
| 111 | - add_filter("the_content", array('maxCollections', "doContentHooks")); | |
| 122 | + add_filter("the_content", array(maxUtils::namespaceit('maxCollections'), "doContentHooks")); | |
| 112 | 123 | } |
| 113 | 124 | if (isset($hook_array["once"]) && count($hook_array["once"]) > 0) |
| 114 | 125 | { |
| 115 | 126 | //self::doFooterHooks(); // the stuff that goes once. |
| 116 | - add_action('wp_head', array('maxCollections', 'doFooterHooks')); | |
| 127 | + add_action('wp_head', array(maxUtils::namespaceit('maxCollections'), 'doFooterHooks')); | |
| 117 | 128 | } |
| 118 | 129 | |
| 119 | 130 | if (count($hook_array) > 0) |
| 120 | 131 | return true; // yes, bind action and check |
| @@ -434,10 +445,12 @@ | ||
| 434 | 445 | { |
| 435 | 446 | if (! self::$init) self::init(); |
| 436 | 447 | |
| 437 | 448 | if (isset(self::$collectionClass[$name])) |
| 438 | - return new self::$collectionClass[$name]; | |
| 439 | - | |
| 449 | + { | |
| 450 | + $class = maxUtils::namespaceit(self::$collectionClass[$name]); | |
| 451 | + return new $class; | |
| 452 | + } | |
| 440 | 453 | } |
| 441 | 454 | |
| 442 | 455 | /* This will find an user defined collection from the database by ID */ |
| 443 | 456 | static function getCollectionByID($id) |
| @@ -451,8 +464,11 @@ | ||
| 451 | 464 | |
| 452 | 465 | $type = $results["collection_type"]; |
| 453 | 466 | |
| 454 | 467 | $usecol = self::getCollection($type); |
| 468 | + if (! $usecol) | |
| 469 | + return false; | |
| 470 | + | |
| 455 | 471 | $usecol->set($id); |
| 456 | 472 | return $usecol; |
| 457 | 473 | } |
| 458 | 474 | |
| @@ -487,9 +503,10 @@ | ||
| 487 | 503 | if (! self::$init) self::init(); |
| 488 | 504 | |
| 489 | 505 | if (isset(self::$collectionBlock[$name])) |
| 490 | 506 | { |
| 491 | - return new self::$collectionBlock[$name]; | |
| 507 | + $class = maxUtils::namespaceit(self::$collectionBlock[$name]); | |
| 508 | + return new $class; | |
| 492 | 509 | } |
| 493 | 510 | else return false; |
| 494 | 511 | } |
| 495 | 512 | |