@@ -32,22 +32,22 @@ discard block |
||
| 32 | 32 | use Wordlift\Post\Post_Adapter; |
| 33 | 33 | |
| 34 | 34 | // If this file is called directly, abort. |
| 35 | -if ( ! defined( 'WPINC' ) ) { |
|
| 35 | +if ( ! defined('WPINC')) { |
|
| 36 | 36 | die; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | -define( 'WORDLIFT_VERSION', '3.38.3' ); |
|
| 39 | +define('WORDLIFT_VERSION', '3.38.3'); |
|
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * Filter to disable WLP on any request, defaults to true. |
| 43 | 43 | * |
| 44 | 44 | * @since 3.33.6 |
| 45 | 45 | */ |
| 46 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
| 46 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
| 50 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
| 51 | 51 | |
| 52 | 52 | /* |
| 53 | 53 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -57,15 +57,15 @@ discard block |
||
| 57 | 57 | wordlift_plugin_autoload_register(); |
| 58 | 58 | |
| 59 | 59 | // Include WordLift constants. |
| 60 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
| 60 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
| 61 | 61 | |
| 62 | 62 | // Load modules. |
| 63 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
| 63 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
| 64 | 64 | |
| 65 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
| 65 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
| 66 | 66 | |
| 67 | 67 | // Load early to enable/disable features. |
| 68 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
| 68 | +require_once plugin_dir_path(__FILE__).'wordlift/features/index.php'; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * The code that runs during plugin activation. |
@@ -73,11 +73,11 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | function activate_wordlift() { |
| 75 | 75 | |
| 76 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
| 76 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
| 77 | 77 | |
| 78 | - $log->info( 'Activating WordLift...' ); |
|
| 78 | + $log->info('Activating WordLift...'); |
|
| 79 | 79 | |
| 80 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
| 80 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
| 81 | 81 | Wordlift_Activator::activate(); |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | function deactivate_wordlift() { |
| 106 | 106 | |
| 107 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
| 107 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
| 108 | 108 | Wordlift_Deactivator::deactivate(); |
| 109 | 109 | Wordlift_Http_Api::deactivate(); |
| 110 | 110 | Ttl_Cache_Cleaner::deactivate(); |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
| 126 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
| 125 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
| 126 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * The core plugin class that is used to define internationalization, |
| 130 | 130 | * admin-specific hooks, and public-facing site hooks. |
| 131 | 131 | */ |
| 132 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
| 132 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
| 133 | 133 | |
| 134 | 134 | /** |
| 135 | 135 | * Begins execution of the plugin. |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | * @return bool |
| 150 | 150 | * @since 3.27.6 |
| 151 | 151 | */ |
| 152 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
| 153 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
| 154 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
| 155 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
| 152 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
| 153 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
| 154 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
| 155 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
| 156 | 156 | } |
| 157 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
| 157 | + add_filter('widget_text', 'do_shortcode'); |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * Filter: wl_feature__enable__analysis |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @return bool |
| 165 | 165 | * @since 3.27.6 |
| 166 | 166 | */ |
| 167 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
| 168 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
| 167 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
| 168 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
| 169 | 169 | } else { |
| 170 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
| 170 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | $plugin = new Wordlift(); |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | add_action( |
| 186 | 186 | 'plugins_loaded', |
| 187 | - function () { |
|
| 187 | + function() { |
|
| 188 | 188 | // All features from registry should be initialized here. |
| 189 | 189 | $features_registry = Features_Registry::get_instance(); |
| 190 | 190 | $features_registry->initialize_all_features(); |
@@ -195,27 +195,27 @@ discard block |
||
| 195 | 195 | add_action( |
| 196 | 196 | 'plugins_loaded', |
| 197 | 197 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
| 198 | - function () use ( $plugin ) { |
|
| 198 | + function() use ($plugin) { |
|
| 199 | 199 | |
| 200 | 200 | new Wordlift_Products_Navigator_Shortcode_REST(); |
| 201 | 201 | |
| 202 | 202 | // Register the Dataset module, requires `$api_service`. |
| 203 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
| 204 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
| 203 | + require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php'; |
|
| 204 | + require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php'; |
|
| 205 | 205 | |
| 206 | 206 | /* |
| 207 | 207 | * Require the Entity annotation cleanup module. |
| 208 | 208 | * |
| 209 | 209 | * @since 3.34.6 |
| 210 | 210 | */ |
| 211 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
| 211 | + require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php'; |
|
| 212 | 212 | |
| 213 | 213 | /* |
| 214 | 214 | * Import LOD entities. |
| 215 | 215 | * |
| 216 | 216 | * @since 3.35.0 |
| 217 | 217 | */ |
| 218 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
| 218 | + require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php'; |
|
| 219 | 219 | |
| 220 | 220 | } |
| 221 | 221 | ); |
@@ -233,23 +233,23 @@ discard block |
||
| 233 | 233 | function wordlift_plugin_autoload_register() { |
| 234 | 234 | |
| 235 | 235 | spl_autoload_register( |
| 236 | - function ( $class_name ) { |
|
| 236 | + function($class_name) { |
|
| 237 | 237 | |
| 238 | 238 | // Bail out if these are not our classes. |
| 239 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
| 239 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
| 240 | 240 | return false; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
| 243 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
| 244 | 244 | |
| 245 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
| 245 | + preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
| 246 | 246 | |
| 247 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
| 248 | - $file = 'class-' . $matches[2] . '.php'; |
|
| 247 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
| 248 | + $file = 'class-'.$matches[2].'.php'; |
|
| 249 | 249 | |
| 250 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
| 250 | + $full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file; |
|
| 251 | 251 | |
| 252 | - if ( ! file_exists( $full_path ) ) { |
|
| 252 | + if ( ! file_exists($full_path)) { |
|
| 253 | 253 | return false; |
| 254 | 254 | } |
| 255 | 255 | |
@@ -261,13 +261,13 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | -function wl_block_categories( $categories ) { |
|
| 264 | +function wl_block_categories($categories) { |
|
| 265 | 265 | return array_merge( |
| 266 | 266 | $categories, |
| 267 | 267 | array( |
| 268 | 268 | array( |
| 269 | 269 | 'slug' => 'wordlift', |
| 270 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
| 270 | + 'title' => __('WordLift', 'wordlift'), |
|
| 271 | 271 | ), |
| 272 | 272 | ) |
| 273 | 273 | ); |
@@ -277,22 +277,22 @@ discard block |
||
| 277 | 277 | * This function is created temporarily to handle the legacy library, |
| 278 | 278 | * this has to be removed when removing the legacy fields from the ui. |
| 279 | 279 | */ |
| 280 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
| 280 | +function wl_enqueue_leaflet($in_footer = false) { |
|
| 281 | 281 | // Leaflet. |
| 282 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
| 283 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
| 282 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
| 283 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
| 286 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
| 287 | 287 | |
| 288 | 288 | // Temporary fix for a typo in WooCommerce Extension. |
| 289 | 289 | add_filter( |
| 290 | 290 | 'wl_feature__enable__dataset', |
| 291 | - function ( $value ) { |
|
| 292 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
| 291 | + function($value) { |
|
| 292 | + return apply_filters('wl_features__enable__dataset', $value); |
|
| 293 | 293 | } |
| 294 | 294 | ); |
| 295 | 295 | |
| 296 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
| 297 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
| 298 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
| 296 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
| 297 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
| 298 | +require_once __DIR__.'/modules/pods/load.php'; |
|
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return void |
| 18 | 18 | */ |
| 19 | - public function __construct( $schema ) { |
|
| 19 | + public function __construct($schema) { |
|
| 20 | 20 | $this->schema = $schema; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * |
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | - protected function register_pod( $name, $type, $context ) { |
|
| 31 | - $pod_id = intval( substr( md5( $type . '_' . $name ), 0, 8 ), 16 ); |
|
| 32 | - $pod = $this->pod( $pod_id, $name, $type ); |
|
| 30 | + protected function register_pod($name, $type, $context) { |
|
| 31 | + $pod_id = intval(substr(md5($type.'_'.$name), 0, 8), 16); |
|
| 32 | + $pod = $this->pod($pod_id, $name, $type); |
|
| 33 | 33 | $schema_field_groups = $context->get_custom_fields(); |
| 34 | 34 | |
| 35 | - if ( ! is_array( $schema_field_groups ) ) { |
|
| 35 | + if ( ! is_array($schema_field_groups)) { |
|
| 36 | 36 | return; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - foreach ( $schema_field_groups as $schema_field_group ) { |
|
| 39 | + foreach ($schema_field_groups as $schema_field_group) { |
|
| 40 | 40 | $custom_fields = $schema_field_group->get_custom_fields(); |
| 41 | - if ( is_array( $custom_fields ) && count( $custom_fields ) > 0 ) { |
|
| 41 | + if (is_array($custom_fields) && count($custom_fields) > 0) { |
|
| 42 | 42 | $this->group( |
| 43 | 43 | $schema_field_group->get_schema_type(), |
| 44 | 44 | $pod, |
| 45 | 45 | $this->group_fields( |
| 46 | - ...$this->custom_fields_to_pod_fields( $custom_fields, $pod_id ) |
|
| 46 | + ...$this->custom_fields_to_pod_fields($custom_fields, $pod_id) |
|
| 47 | 47 | ) |
| 48 | 48 | ); |
| 49 | 49 | } |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function relationship( $name, $field_data ) { |
|
| 70 | + protected function relationship($name, $field_data) { |
|
| 71 | 71 | |
| 72 | 72 | $supported_schema_types = $field_data['constraints']['uri_type']; |
| 73 | 73 | |
| 74 | - if ( ! is_array( $supported_schema_types ) ) { |
|
| 75 | - $supported_schema_types = array( $supported_schema_types ); |
|
| 74 | + if ( ! is_array($supported_schema_types)) { |
|
| 75 | + $supported_schema_types = array($supported_schema_types); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | return array( |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - protected function repeatable( $field, $repeatable_label = 'Add New' ) { |
|
| 109 | + protected function repeatable($field, $repeatable_label = 'Add New') { |
|
| 110 | 110 | $field['repeatable'] = 1; |
| 111 | 111 | $field['repeatable_add_new_label'] = $repeatable_label; |
| 112 | 112 | |
@@ -135,12 +135,12 @@ discard block |
||
| 135 | 135 | ); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - protected function group_fields( ...$fields ) { |
|
| 138 | + protected function group_fields(...$fields) { |
|
| 139 | 139 | $result = array(); |
| 140 | 140 | array_map( |
| 141 | - function ( $item ) use ( &$result ) { |
|
| 141 | + function($item) use (&$result) { |
|
| 142 | 142 | $field_name = $item['name']; |
| 143 | - $result[ $field_name ] = $item; |
|
| 143 | + $result[$field_name] = $item; |
|
| 144 | 144 | }, |
| 145 | 145 | $fields |
| 146 | 146 | ); |
@@ -148,21 +148,21 @@ discard block |
||
| 148 | 148 | return $result; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - protected function group( $name, $pod, $group_fields ) { |
|
| 151 | + protected function group($name, $pod, $group_fields) { |
|
| 152 | 152 | $group = array( |
| 153 | 153 | 'name' => $name, |
| 154 | - 'label' => sprintf( 'WordLift - %s', $this->format_label( $name ) ), |
|
| 154 | + 'label' => sprintf('WordLift - %s', $this->format_label($name)), |
|
| 155 | 155 | 'description' => '', |
| 156 | 156 | 'weight' => 0, |
| 157 | 157 | |
| 158 | 158 | ); |
| 159 | - pods_register_group( $group, $pod['name'], $group_fields ); |
|
| 159 | + pods_register_group($group, $pod['name'], $group_fields); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - protected function pod( $pod_id, $name, $type ) { |
|
| 162 | + protected function pod($pod_id, $name, $type) { |
|
| 163 | 163 | $pod = array( |
| 164 | 164 | 'name' => $name, |
| 165 | - 'label' => $this->format_label( $name ), |
|
| 165 | + 'label' => $this->format_label($name), |
|
| 166 | 166 | 'description' => '', |
| 167 | 167 | 'type' => $type, |
| 168 | 168 | 'storage' => 'meta', |
@@ -170,31 +170,31 @@ discard block |
||
| 170 | 170 | 'object' => $name, |
| 171 | 171 | ); |
| 172 | 172 | |
| 173 | - pods_register_type( $pod['type'], $pod['name'], $pod ); |
|
| 173 | + pods_register_type($pod['type'], $pod['name'], $pod); |
|
| 174 | 174 | |
| 175 | 175 | return $pod; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | protected function register_on_all_supported_taxonomies() { |
| 179 | 179 | $taxonomies = Terms_Compat::get_public_taxonomies(); |
| 180 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 181 | - $this->register_pod( $taxonomy, 'taxonomy' ); |
|
| 180 | + foreach ($taxonomies as $taxonomy) { |
|
| 181 | + $this->register_pod($taxonomy, 'taxonomy'); |
|
| 182 | 182 | |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - protected function get_field_by_type( $name, $type, $field_data ) { |
|
| 187 | - if ( 'uri' === $type && isset( $field_data['constraints']['uri_type'] ) ) { |
|
| 188 | - return $this->relationship( $name, $field_data ); |
|
| 189 | - } elseif ( 'uri' === $type ) { |
|
| 186 | + protected function get_field_by_type($name, $type, $field_data) { |
|
| 187 | + if ('uri' === $type && isset($field_data['constraints']['uri_type'])) { |
|
| 188 | + return $this->relationship($name, $field_data); |
|
| 189 | + } elseif ('uri' === $type) { |
|
| 190 | 190 | return $this->website(); |
| 191 | - } elseif ( 'string' === $type ) { |
|
| 191 | + } elseif ('string' === $type) { |
|
| 192 | 192 | return $this->text(); |
| 193 | - } elseif ( 'double' === $type ) { |
|
| 194 | - return $this->number( $name, 2 ); |
|
| 195 | - } elseif ( 'date' === $type ) { |
|
| 193 | + } elseif ('double' === $type) { |
|
| 194 | + return $this->number($name, 2); |
|
| 195 | + } elseif ('date' === $type) { |
|
| 196 | 196 | return $this->datetime(); |
| 197 | - } elseif ( 'multiline' === $type ) { |
|
| 197 | + } elseif ('multiline' === $type) { |
|
| 198 | 198 | return $this->multiline(); |
| 199 | 199 | } else { |
| 200 | 200 | return $this->text(); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | ); |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - protected function number( $name, $decimals = 0 ) { |
|
| 226 | + protected function number($name, $decimals = 0) { |
|
| 227 | 227 | return array( |
| 228 | 228 | 'description' => '', |
| 229 | 229 | 'weight' => 1, |
@@ -262,10 +262,10 @@ discard block |
||
| 262 | 262 | ); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - protected function may_be_repeatable( $custom_field, $field ) { |
|
| 266 | - $repeatable = isset( $custom_field['constraints']['cardinality'] ) && INF === $custom_field['constraints']['cardinality']; |
|
| 267 | - if ( $repeatable ) { |
|
| 268 | - return $this->repeatable( $field ); |
|
| 265 | + protected function may_be_repeatable($custom_field, $field) { |
|
| 266 | + $repeatable = isset($custom_field['constraints']['cardinality']) && INF === $custom_field['constraints']['cardinality']; |
|
| 267 | + if ($repeatable) { |
|
| 268 | + return $this->repeatable($field); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | return $field; |
@@ -275,38 +275,38 @@ discard block |
||
| 275 | 275 | * @return array |
| 276 | 276 | * A function which defines these pods on the edit post screen. |
| 277 | 277 | */ |
| 278 | - protected function custom_field_to_pod_field( $custom_field ) { |
|
| 278 | + protected function custom_field_to_pod_field($custom_field) { |
|
| 279 | 279 | |
| 280 | - $name = str_replace( 'http://schema.org/', '', $custom_field['predicate'] ); |
|
| 281 | - $type = isset( $custom_field['type'] ) ? $custom_field['type'] : 'string'; |
|
| 280 | + $name = str_replace('http://schema.org/', '', $custom_field['predicate']); |
|
| 281 | + $type = isset($custom_field['type']) ? $custom_field['type'] : 'string'; |
|
| 282 | 282 | |
| 283 | - return $this->may_be_repeatable( $custom_field, $this->get_field_by_type( $name, $type, $custom_field ) ); |
|
| 283 | + return $this->may_be_repeatable($custom_field, $this->get_field_by_type($name, $type, $custom_field)); |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - protected function wordlift_css_class( $field ) { |
|
| 286 | + protected function wordlift_css_class($field) { |
|
| 287 | 287 | $field['class'] = 'wordlift'; |
| 288 | 288 | |
| 289 | 289 | return $field; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - protected function custom_fields_to_pod_fields( $custom_fields, $pod_id ) { |
|
| 292 | + protected function custom_fields_to_pod_fields($custom_fields, $pod_id) { |
|
| 293 | 293 | |
| 294 | 294 | $pod_fields = array(); |
| 295 | 295 | |
| 296 | - foreach ( $custom_fields as $name => $custom_field ) { |
|
| 297 | - $pod_fields[] = $this->wordlift_css_class( $this->custom_field_to_pod_field( $custom_field ) ) + array( |
|
| 296 | + foreach ($custom_fields as $name => $custom_field) { |
|
| 297 | + $pod_fields[] = $this->wordlift_css_class($this->custom_field_to_pod_field($custom_field)) + array( |
|
| 298 | 298 | 'pod_id' => $pod_id, |
| 299 | - 'id' => intval( substr( md5( $pod_id . '_' . $name ), 0, 8 ), 16 ), |
|
| 299 | + 'id' => intval(substr(md5($pod_id.'_'.$name), 0, 8), 16), |
|
| 300 | 300 | 'name' => $name, |
| 301 | - 'label' => $this->format_label( str_replace( 'http://schema.org/', '', $custom_field['predicate'] ) ), |
|
| 301 | + 'label' => $this->format_label(str_replace('http://schema.org/', '', $custom_field['predicate'])), |
|
| 302 | 302 | ); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - return array_values( $pod_fields ); |
|
| 305 | + return array_values($pod_fields); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | - protected function format_label( $name ) { |
|
| 309 | - return join( ' ', array_map( 'ucwords', preg_split( '/(?=[A-Z])/', $name ) ) ); |
|
| 308 | + protected function format_label($name) { |
|
| 309 | + return join(' ', array_map('ucwords', preg_split('/(?=[A-Z])/', $name))); |
|
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | } |