@@ -7,6 +7,6 @@ |
||
| 7 | 7 | exit(1); |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | -require_once __DIR__ . '/composer/autoload_real.php'; |
|
| 10 | +require_once __DIR__.'/composer/autoload_real.php'; |
|
| 11 | 11 | |
| 12 | 12 | return ComposerAutoloaderInit9642ee961b167da95128649b368d802d::getLoader(); |
@@ -4,23 +4,23 @@ |
||
| 4 | 4 | |
| 5 | 5 | $issues = array(); |
| 6 | 6 | |
| 7 | -if (!(PHP_VERSION_ID >= 50600)) { |
|
| 8 | - $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running ' . PHP_VERSION . '.'; |
|
| 7 | +if ( ! (PHP_VERSION_ID >= 50600)) { |
|
| 8 | + $issues[] = 'Your Composer dependencies require a PHP version ">= 5.6.0". You are running '.PHP_VERSION.'.'; |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if ($issues) { |
| 12 | - if (!headers_sent()) { |
|
| 12 | + if ( ! headers_sent()) { |
|
| 13 | 13 | header('HTTP/1.1 500 Internal Server Error'); |
| 14 | 14 | } |
| 15 | - if (!ini_get('display_errors')) { |
|
| 15 | + if ( ! ini_get('display_errors')) { |
|
| 16 | 16 | if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { |
| 17 | - fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); |
|
| 18 | - } elseif (!headers_sent()) { |
|
| 19 | - echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; |
|
| 17 | + fwrite(STDERR, 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.implode(PHP_EOL, $issues).PHP_EOL.PHP_EOL); |
|
| 18 | + } elseif ( ! headers_sent()) { |
|
| 19 | + echo 'Composer detected issues in your platform:'.PHP_EOL.PHP_EOL.str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)).PHP_EOL.PHP_EOL; |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | trigger_error( |
| 23 | - 'Composer detected issues in your platform: ' . implode(' ', $issues), |
|
| 23 | + 'Composer detected issues in your platform: '.implode(' ', $issues), |
|
| 24 | 24 | E_USER_ERROR |
| 25 | 25 | ); |
| 26 | 26 | } |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = dirname($vendorDir); |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'Wordlift\\Modules\\Common\\' => array($baseDir . '/includes'), |
|
| 9 | + 'Wordlift\\Modules\\Common\\' => array($baseDir.'/includes'), |
|
| 10 | 10 | ); |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -22,13 +22,13 @@ discard block |
||
| 22 | 22 | return self::$loader; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - require __DIR__ . '/platform_check.php'; |
|
| 25 | + require __DIR__.'/platform_check.php'; |
|
| 26 | 26 | |
| 27 | 27 | spl_autoload_register(array('ComposerAutoloaderInit9642ee961b167da95128649b368d802d', 'loadClassLoader'), true, true); |
| 28 | 28 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
| 29 | 29 | spl_autoload_unregister(array('ComposerAutoloaderInit9642ee961b167da95128649b368d802d', 'loadClassLoader')); |
| 30 | 30 | |
| 31 | - require __DIR__ . '/autoload_static.php'; |
|
| 31 | + require __DIR__.'/autoload_static.php'; |
|
| 32 | 32 | call_user_func(\Composer\Autoload\ComposerStaticInit9642ee961b167da95128649b368d802d::getInitializer($loader)); |
| 33 | 33 | |
| 34 | 34 | $loader->register(true); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public function getPrefixes() |
| 115 | 115 | { |
| 116 | - if (!empty($this->prefixesPsr0)) { |
|
| 116 | + if ( ! empty($this->prefixesPsr0)) { |
|
| 117 | 117 | return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public function add($prefix, $paths, $prepend = false) |
| 185 | 185 | { |
| 186 | - if (!$prefix) { |
|
| 186 | + if ( ! $prefix) { |
|
| 187 | 187 | if ($prepend) { |
| 188 | 188 | $this->fallbackDirsPsr0 = array_merge( |
| 189 | 189 | (array) $paths, |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | $first = $prefix[0]; |
| 203 | - if (!isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 203 | + if ( ! isset($this->prefixesPsr0[$first][$prefix])) { |
|
| 204 | 204 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; |
| 205 | 205 | |
| 206 | 206 | return; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function addPsr4($prefix, $paths, $prepend = false) |
| 234 | 234 | { |
| 235 | - if (!$prefix) { |
|
| 235 | + if ( ! $prefix) { |
|
| 236 | 236 | // Register directories for the root namespace. |
| 237 | 237 | if ($prepend) { |
| 238 | 238 | $this->fallbackDirsPsr4 = array_merge( |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | (array) $paths |
| 246 | 246 | ); |
| 247 | 247 | } |
| 248 | - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
|
| 248 | + } elseif ( ! isset($this->prefixDirsPsr4[$prefix])) { |
|
| 249 | 249 | // Register directories for a new namespace. |
| 250 | 250 | $length = strlen($prefix); |
| 251 | 251 | if ('\\' !== $prefix[$length - 1]) { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | public function set($prefix, $paths) |
| 281 | 281 | { |
| 282 | - if (!$prefix) { |
|
| 282 | + if ( ! $prefix) { |
|
| 283 | 283 | $this->fallbackDirsPsr0 = (array) $paths; |
| 284 | 284 | } else { |
| 285 | 285 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | public function setPsr4($prefix, $paths) |
| 301 | 301 | { |
| 302 | - if (!$prefix) { |
|
| 302 | + if ( ! $prefix) { |
|
| 303 | 303 | $this->fallbackDirsPsr4 = (array) $paths; |
| 304 | 304 | } else { |
| 305 | 305 | $length = strlen($prefix); |
@@ -493,18 +493,18 @@ discard block |
||
| 493 | 493 | private function findFileWithExtension($class, $ext) |
| 494 | 494 | { |
| 495 | 495 | // PSR-4 lookup |
| 496 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
| 496 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
| 497 | 497 | |
| 498 | 498 | $first = $class[0]; |
| 499 | 499 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 500 | 500 | $subPath = $class; |
| 501 | 501 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
| 502 | 502 | $subPath = substr($subPath, 0, $lastPos); |
| 503 | - $search = $subPath . '\\'; |
|
| 503 | + $search = $subPath.'\\'; |
|
| 504 | 504 | if (isset($this->prefixDirsPsr4[$search])) { |
| 505 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
| 505 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
| 506 | 506 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 507 | - if (file_exists($file = $dir . $pathEnd)) { |
|
| 507 | + if (file_exists($file = $dir.$pathEnd)) { |
|
| 508 | 508 | return $file; |
| 509 | 509 | } |
| 510 | 510 | } |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | // PSR-4 fallback dirs |
| 516 | 516 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 517 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
| 517 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
| 518 | 518 | return $file; |
| 519 | 519 | } |
| 520 | 520 | } |
@@ -526,14 +526,14 @@ discard block |
||
| 526 | 526 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
| 527 | 527 | } else { |
| 528 | 528 | // PEAR-like class name |
| 529 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
| 529 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
| 530 | 530 | } |
| 531 | 531 | |
| 532 | 532 | if (isset($this->prefixesPsr0[$first])) { |
| 533 | 533 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 534 | 534 | if (0 === strpos($class, $prefix)) { |
| 535 | 535 | foreach ($dirs as $dir) { |
| 536 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 536 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 537 | 537 | return $file; |
| 538 | 538 | } |
| 539 | 539 | } |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | |
| 544 | 544 | // PSR-0 fallback dirs |
| 545 | 545 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 546 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
| 546 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
| 547 | 547 | return $file; |
| 548 | 548 | } |
| 549 | 549 | } |
@@ -6,27 +6,27 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInit9642ee961b167da95128649b368d802d |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'W' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'Wordlift\\Modules\\Common\\' => 24, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'Wordlift\\Modules\\Common\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/../..' . '/includes', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/../..'.'/includes', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
| 25 | 25 | ); |
| 26 | 26 | |
| 27 | 27 | public static function getInitializer(ClassLoader $loader) |
| 28 | 28 | { |
| 29 | - return \Closure::bind(function () use ($loader) { |
|
| 29 | + return \Closure::bind(function() use ($loader) { |
|
| 30 | 30 | $loader->prefixLengthsPsr4 = ComposerStaticInit9642ee961b167da95128649b368d802d::$prefixLengthsPsr4; |
| 31 | 31 | $loader->prefixDirsPsr4 = ComposerStaticInit9642ee961b167da95128649b368d802d::$prefixDirsPsr4; |
| 32 | 32 | $loader->classMap = ComposerStaticInit9642ee961b167da95128649b368d802d::$classMap; |
@@ -6,5 +6,5 @@ |
||
| 6 | 6 | $baseDir = dirname($vendorDir); |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
| 9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
| 10 | 10 | ); |
@@ -14,114 +14,114 @@ |
||
| 14 | 14 | |
| 15 | 15 | class Entity_Query_Service { |
| 16 | 16 | |
| 17 | - private static $instance = null; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * The singleton instance. |
|
| 21 | - * |
|
| 22 | - * @return Entity_Query_Service |
|
| 23 | - */ |
|
| 24 | - public static function get_instance() { |
|
| 25 | - if ( ! isset( self::$instance ) ) { |
|
| 26 | - self::$instance = new self(); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - return self::$instance; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - private function query_posts( $query, $schema_types, $limit ) { |
|
| 33 | - return wl_entity_get_by_title( $query, true, true, $limit, $schema_types ); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - private function query_terms( $query, $schema_types, $limit ) { |
|
| 37 | - global $wpdb; |
|
| 38 | - $schema_types = join( |
|
| 39 | - ',', |
|
| 40 | - array_map( |
|
| 41 | - function ( $schema_type ) { |
|
| 42 | - return "'" . esc_sql( strtolower( $schema_type ) ) . "'"; |
|
| 43 | - }, |
|
| 44 | - $schema_types |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - return $wpdb->get_results( |
|
| 49 | - $wpdb->prepare( |
|
| 50 | - "SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm |
|
| 17 | + private static $instance = null; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * The singleton instance. |
|
| 21 | + * |
|
| 22 | + * @return Entity_Query_Service |
|
| 23 | + */ |
|
| 24 | + public static function get_instance() { |
|
| 25 | + if ( ! isset( self::$instance ) ) { |
|
| 26 | + self::$instance = new self(); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + return self::$instance; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + private function query_posts( $query, $schema_types, $limit ) { |
|
| 33 | + return wl_entity_get_by_title( $query, true, true, $limit, $schema_types ); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + private function query_terms( $query, $schema_types, $limit ) { |
|
| 37 | + global $wpdb; |
|
| 38 | + $schema_types = join( |
|
| 39 | + ',', |
|
| 40 | + array_map( |
|
| 41 | + function ( $schema_type ) { |
|
| 42 | + return "'" . esc_sql( strtolower( $schema_type ) ) . "'"; |
|
| 43 | + }, |
|
| 44 | + $schema_types |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + return $wpdb->get_results( |
|
| 49 | + $wpdb->prepare( |
|
| 50 | + "SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm |
|
| 51 | 51 | ON t.term_id=tm.term_id WHERE t.name LIKE %s AND (tm.meta_key = %s AND tm.meta_value IN ($schema_types)) LIMIT %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 52 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 53 | - \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 54 | - $limit |
|
| 55 | - ) |
|
| 56 | - ); |
|
| 57 | - |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * @param $results |
|
| 62 | - * @param $object_type |
|
| 63 | - * |
|
| 64 | - * @return Entity[] |
|
| 65 | - */ |
|
| 66 | - private function transform_posts( $results ) { |
|
| 67 | - return array_map( |
|
| 68 | - function ( $item ) { |
|
| 69 | - return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) ); |
|
| 70 | - }, |
|
| 71 | - $results |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - private function transform_terms( $results ) { |
|
| 76 | - return array_map( |
|
| 77 | - function ( $item ) { |
|
| 78 | - return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
|
| 79 | - }, |
|
| 80 | - $results |
|
| 81 | - ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @param $query |
|
| 86 | - * @param $schema_types |
|
| 87 | - * @param $limit |
|
| 88 | - * |
|
| 89 | - * @return Entity[] |
|
| 90 | - */ |
|
| 91 | - public function query( $query, $schema_types = array(), $limit = 10 ) { |
|
| 92 | - |
|
| 93 | - $results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) ); |
|
| 94 | - |
|
| 95 | - if ( count( $results ) >= $limit ) { |
|
| 96 | - return $results; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) ); |
|
| 100 | - |
|
| 101 | - return $results; |
|
| 102 | - |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - public function get( $linked_entities ) { |
|
| 106 | - return array_filter( |
|
| 107 | - array_map( |
|
| 108 | - function ( $item ) { |
|
| 109 | - $parts = explode( '_', $item ); |
|
| 110 | - $type = Object_Type_Enum::from_string( $parts[0] ); |
|
| 111 | - $identifier = $parts[1]; |
|
| 112 | - |
|
| 113 | - if ( $type === Object_Type_Enum::POST ) { |
|
| 114 | - return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) ); |
|
| 115 | - } elseif ( $type === Object_Type_Enum::TERM ) { |
|
| 116 | - return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) ); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - // return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
|
| 120 | - }, |
|
| 121 | - $linked_entities |
|
| 122 | - ) |
|
| 123 | - ); |
|
| 124 | - |
|
| 125 | - } |
|
| 52 | + '%' . $wpdb->esc_like( $query ) . '%', |
|
| 53 | + \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
| 54 | + $limit |
|
| 55 | + ) |
|
| 56 | + ); |
|
| 57 | + |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * @param $results |
|
| 62 | + * @param $object_type |
|
| 63 | + * |
|
| 64 | + * @return Entity[] |
|
| 65 | + */ |
|
| 66 | + private function transform_posts( $results ) { |
|
| 67 | + return array_map( |
|
| 68 | + function ( $item ) { |
|
| 69 | + return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) ); |
|
| 70 | + }, |
|
| 71 | + $results |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + private function transform_terms( $results ) { |
|
| 76 | + return array_map( |
|
| 77 | + function ( $item ) { |
|
| 78 | + return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
|
| 79 | + }, |
|
| 80 | + $results |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @param $query |
|
| 86 | + * @param $schema_types |
|
| 87 | + * @param $limit |
|
| 88 | + * |
|
| 89 | + * @return Entity[] |
|
| 90 | + */ |
|
| 91 | + public function query( $query, $schema_types = array(), $limit = 10 ) { |
|
| 92 | + |
|
| 93 | + $results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) ); |
|
| 94 | + |
|
| 95 | + if ( count( $results ) >= $limit ) { |
|
| 96 | + return $results; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) ); |
|
| 100 | + |
|
| 101 | + return $results; |
|
| 102 | + |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + public function get( $linked_entities ) { |
|
| 106 | + return array_filter( |
|
| 107 | + array_map( |
|
| 108 | + function ( $item ) { |
|
| 109 | + $parts = explode( '_', $item ); |
|
| 110 | + $type = Object_Type_Enum::from_string( $parts[0] ); |
|
| 111 | + $identifier = $parts[1]; |
|
| 112 | + |
|
| 113 | + if ( $type === Object_Type_Enum::POST ) { |
|
| 114 | + return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) ); |
|
| 115 | + } elseif ( $type === Object_Type_Enum::TERM ) { |
|
| 116 | + return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) ); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + // return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
|
| 120 | + }, |
|
| 121 | + $linked_entities |
|
| 122 | + ) |
|
| 123 | + ); |
|
| 124 | + |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | 127 | } |
@@ -22,24 +22,24 @@ discard block |
||
| 22 | 22 | * @return Entity_Query_Service |
| 23 | 23 | */ |
| 24 | 24 | public static function get_instance() { |
| 25 | - if ( ! isset( self::$instance ) ) { |
|
| 25 | + if ( ! isset(self::$instance)) { |
|
| 26 | 26 | self::$instance = new self(); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | return self::$instance; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - private function query_posts( $query, $schema_types, $limit ) { |
|
| 33 | - return wl_entity_get_by_title( $query, true, true, $limit, $schema_types ); |
|
| 32 | + private function query_posts($query, $schema_types, $limit) { |
|
| 33 | + return wl_entity_get_by_title($query, true, true, $limit, $schema_types); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - private function query_terms( $query, $schema_types, $limit ) { |
|
| 36 | + private function query_terms($query, $schema_types, $limit) { |
|
| 37 | 37 | global $wpdb; |
| 38 | 38 | $schema_types = join( |
| 39 | 39 | ',', |
| 40 | 40 | array_map( |
| 41 | - function ( $schema_type ) { |
|
| 42 | - return "'" . esc_sql( strtolower( $schema_type ) ) . "'"; |
|
| 41 | + function($schema_type) { |
|
| 42 | + return "'".esc_sql(strtolower($schema_type))."'"; |
|
| 43 | 43 | }, |
| 44 | 44 | $schema_types |
| 45 | 45 | ) |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $wpdb->prepare( |
| 50 | 50 | "SELECT DISTINCT t.term_id as id, t.name as title, tm.meta_value as schema_type_name FROM $wpdb->terms t INNER JOIN $wpdb->termmeta tm |
| 51 | 51 | ON t.term_id=tm.term_id WHERE t.name LIKE %s AND (tm.meta_key = %s AND tm.meta_value IN ($schema_types)) LIMIT %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 52 | - '%' . $wpdb->esc_like( $query ) . '%', |
|
| 52 | + '%'.$wpdb->esc_like($query).'%', |
|
| 53 | 53 | \Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
| 54 | 54 | $limit |
| 55 | 55 | ) |
@@ -63,19 +63,19 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return Entity[] |
| 65 | 65 | */ |
| 66 | - private function transform_posts( $results ) { |
|
| 66 | + private function transform_posts($results) { |
|
| 67 | 67 | return array_map( |
| 68 | - function ( $item ) { |
|
| 69 | - return new Entity( $item->schema_type_name, new Wordpress_Content( get_post( $item->id ) ) ); |
|
| 68 | + function($item) { |
|
| 69 | + return new Entity($item->schema_type_name, new Wordpress_Content(get_post($item->id))); |
|
| 70 | 70 | }, |
| 71 | 71 | $results |
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - private function transform_terms( $results ) { |
|
| 75 | + private function transform_terms($results) { |
|
| 76 | 76 | return array_map( |
| 77 | - function ( $item ) { |
|
| 78 | - return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
|
| 77 | + function($item) { |
|
| 78 | + return new Entity($item->schema_type_name, new Wordpress_Content(get_term($item->id))); |
|
| 79 | 79 | }, |
| 80 | 80 | $results |
| 81 | 81 | ); |
@@ -88,32 +88,32 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return Entity[] |
| 90 | 90 | */ |
| 91 | - public function query( $query, $schema_types = array(), $limit = 10 ) { |
|
| 91 | + public function query($query, $schema_types = array(), $limit = 10) { |
|
| 92 | 92 | |
| 93 | - $results = $this->transform_posts( $this->query_posts( $query, $schema_types, $limit ) ); |
|
| 93 | + $results = $this->transform_posts($this->query_posts($query, $schema_types, $limit)); |
|
| 94 | 94 | |
| 95 | - if ( count( $results ) >= $limit ) { |
|
| 95 | + if (count($results) >= $limit) { |
|
| 96 | 96 | return $results; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $results = array_merge( $results, $this->transform_terms( $this->query_terms( $query, $schema_types, $limit ) ) ); |
|
| 99 | + $results = array_merge($results, $this->transform_terms($this->query_terms($query, $schema_types, $limit))); |
|
| 100 | 100 | |
| 101 | 101 | return $results; |
| 102 | 102 | |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - public function get( $linked_entities ) { |
|
| 105 | + public function get($linked_entities) { |
|
| 106 | 106 | return array_filter( |
| 107 | 107 | array_map( |
| 108 | - function ( $item ) { |
|
| 109 | - $parts = explode( '_', $item ); |
|
| 110 | - $type = Object_Type_Enum::from_string( $parts[0] ); |
|
| 108 | + function($item) { |
|
| 109 | + $parts = explode('_', $item); |
|
| 110 | + $type = Object_Type_Enum::from_string($parts[0]); |
|
| 111 | 111 | $identifier = $parts[1]; |
| 112 | 112 | |
| 113 | - if ( $type === Object_Type_Enum::POST ) { |
|
| 114 | - return new Entity( 'Thing', new Wordpress_Content( get_post( $identifier ) ) ); |
|
| 115 | - } elseif ( $type === Object_Type_Enum::TERM ) { |
|
| 116 | - return new Entity( 'Thing', new Wordpress_Content( get_term( $identifier ) ) ); |
|
| 113 | + if ($type === Object_Type_Enum::POST) { |
|
| 114 | + return new Entity('Thing', new Wordpress_Content(get_post($identifier))); |
|
| 115 | + } elseif ($type === Object_Type_Enum::TERM) { |
|
| 116 | + return new Entity('Thing', new Wordpress_Content(get_term($identifier))); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // return new Entity( $item->schema_type_name, new Wordpress_Content( get_term( $item->id ) ) ); |
@@ -21,36 +21,36 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class Wl_Metabox extends Wl_Abstract_Metabox { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * WL_Metabox constructor. |
|
| 26 | - * |
|
| 27 | - * @since 3.1.0 |
|
| 28 | - */ |
|
| 29 | - public function __construct() { |
|
| 30 | - parent::__construct(); |
|
| 31 | - /** |
|
| 32 | - * Filter: wl_feature__enable__metabox. |
|
| 33 | - * |
|
| 34 | - * @param bool whether the metabox should be shown, defaults to true. |
|
| 35 | - * |
|
| 36 | - * @return bool |
|
| 37 | - * @since 3.28.1 |
|
| 38 | - */ |
|
| 39 | - if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 40 | - |
|
| 41 | - // Add hooks to print metaboxes and save submitted data. |
|
| 42 | - add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 43 | - add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 44 | - |
|
| 45 | - // Enqueue js and css. |
|
| 46 | - $this->enqueue_scripts_and_styles(); |
|
| 47 | - |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - public function save_form( $post_id ) { |
|
| 53 | - $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 54 | - } |
|
| 24 | + /** |
|
| 25 | + * WL_Metabox constructor. |
|
| 26 | + * |
|
| 27 | + * @since 3.1.0 |
|
| 28 | + */ |
|
| 29 | + public function __construct() { |
|
| 30 | + parent::__construct(); |
|
| 31 | + /** |
|
| 32 | + * Filter: wl_feature__enable__metabox. |
|
| 33 | + * |
|
| 34 | + * @param bool whether the metabox should be shown, defaults to true. |
|
| 35 | + * |
|
| 36 | + * @return bool |
|
| 37 | + * @since 3.28.1 |
|
| 38 | + */ |
|
| 39 | + if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 40 | + |
|
| 41 | + // Add hooks to print metaboxes and save submitted data. |
|
| 42 | + add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 43 | + add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 44 | + |
|
| 45 | + // Enqueue js and css. |
|
| 46 | + $this->enqueue_scripts_and_styles(); |
|
| 47 | + |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + public function save_form( $post_id ) { |
|
| 53 | + $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | } |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * @return bool |
| 37 | 37 | * @since 3.28.1 |
| 38 | 38 | */ |
| 39 | - if ( apply_filters( 'wl_feature__enable__metabox', true ) && ! apply_filters( 'wl_feature__enable__pods-integration', false ) ) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 39 | + if (apply_filters('wl_feature__enable__metabox', true) && ! apply_filters('wl_feature__enable__pods-integration', false)) { //phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
| 40 | 40 | |
| 41 | 41 | // Add hooks to print metaboxes and save submitted data. |
| 42 | - add_action( 'add_meta_boxes', array( $this, 'add_main_metabox' ) ); |
|
| 43 | - add_action( 'wl_linked_data_save_post', array( $this, 'save_form' ) ); |
|
| 42 | + add_action('add_meta_boxes', array($this, 'add_main_metabox')); |
|
| 43 | + add_action('wl_linked_data_save_post', array($this, 'save_form')); |
|
| 44 | 44 | |
| 45 | 45 | // Enqueue js and css. |
| 46 | 46 | $this->enqueue_scripts_and_styles(); |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function save_form( $post_id ) { |
|
| 53 | - $this->save_form_data( $post_id, Object_Type_Enum::POST ); |
|
| 52 | + public function save_form($post_id) { |
|
| 53 | + $this->save_form_data($post_id, Object_Type_Enum::POST); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | } |