@@ -23,107 +23,107 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Wordlift_Loader { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * The array of actions registered with WordPress. |
|
| 28 | - * |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - * @access protected |
|
| 31 | - * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
| 32 | - */ |
|
| 33 | - protected $actions; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The array of filters registered with WordPress. |
|
| 37 | - * |
|
| 38 | - * @since 1.0.0 |
|
| 39 | - * @access protected |
|
| 40 | - * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
| 41 | - */ |
|
| 42 | - protected $filters; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Initialize the collections used to maintain the actions and filters. |
|
| 46 | - * |
|
| 47 | - * @since 1.0.0 |
|
| 48 | - */ |
|
| 49 | - public function __construct() { |
|
| 50 | - |
|
| 51 | - $this->actions = array(); |
|
| 52 | - $this->filters = array(); |
|
| 53 | - |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Add a new action to the collection to be registered with WordPress. |
|
| 58 | - * |
|
| 59 | - * @since 1.0.0 |
|
| 60 | - * @param string $hook The name of the WordPress action that is being registered. |
|
| 61 | - * @param object $component A reference to the instance of the object on which the action is defined. |
|
| 62 | - * @param string $callback The name of the function definition on the $component. |
|
| 63 | - * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 64 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
| 65 | - */ |
|
| 66 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Add a new filter to the collection to be registered with WordPress. |
|
| 72 | - * |
|
| 73 | - * @since 1.0.0 |
|
| 74 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
| 75 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 76 | - * @param string $callback The name of the function definition on the $component. |
|
| 77 | - * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 78 | - * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
|
| 79 | - */ |
|
| 80 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * A utility function that is used to register the actions and hooks into a single |
|
| 86 | - * collection. |
|
| 87 | - * |
|
| 88 | - * @since 1.0.0 |
|
| 89 | - * @access private |
|
| 90 | - * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
| 91 | - * @param string $hook The name of the WordPress filter that is being registered. |
|
| 92 | - * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 93 | - * @param string $callback The name of the function definition on the $component. |
|
| 94 | - * @param int $priority The priority at which the function should be fired. |
|
| 95 | - * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
| 96 | - * @return array The collection of actions and filters registered with WordPress. |
|
| 97 | - */ |
|
| 98 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 99 | - |
|
| 100 | - $hooks[] = array( |
|
| 101 | - 'hook' => $hook, |
|
| 102 | - 'component' => $component, |
|
| 103 | - 'callback' => $callback, |
|
| 104 | - 'priority' => $priority, |
|
| 105 | - 'accepted_args' => $accepted_args |
|
| 106 | - ); |
|
| 107 | - |
|
| 108 | - return $hooks; |
|
| 109 | - |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Register the filters and actions with WordPress. |
|
| 114 | - * |
|
| 115 | - * @since 1.0.0 |
|
| 116 | - */ |
|
| 117 | - public function run() { |
|
| 118 | - |
|
| 119 | - foreach ( $this->filters as $hook ) { |
|
| 120 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - foreach ( $this->actions as $hook ) { |
|
| 124 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 125 | - } |
|
| 126 | - |
|
| 127 | - } |
|
| 26 | + /** |
|
| 27 | + * The array of actions registered with WordPress. |
|
| 28 | + * |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + * @access protected |
|
| 31 | + * @var array $actions The actions registered with WordPress to fire when the plugin loads. |
|
| 32 | + */ |
|
| 33 | + protected $actions; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The array of filters registered with WordPress. |
|
| 37 | + * |
|
| 38 | + * @since 1.0.0 |
|
| 39 | + * @access protected |
|
| 40 | + * @var array $filters The filters registered with WordPress to fire when the plugin loads. |
|
| 41 | + */ |
|
| 42 | + protected $filters; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Initialize the collections used to maintain the actions and filters. |
|
| 46 | + * |
|
| 47 | + * @since 1.0.0 |
|
| 48 | + */ |
|
| 49 | + public function __construct() { |
|
| 50 | + |
|
| 51 | + $this->actions = array(); |
|
| 52 | + $this->filters = array(); |
|
| 53 | + |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Add a new action to the collection to be registered with WordPress. |
|
| 58 | + * |
|
| 59 | + * @since 1.0.0 |
|
| 60 | + * @param string $hook The name of the WordPress action that is being registered. |
|
| 61 | + * @param object $component A reference to the instance of the object on which the action is defined. |
|
| 62 | + * @param string $callback The name of the function definition on the $component. |
|
| 63 | + * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 64 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
|
| 65 | + */ |
|
| 66 | + public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Add a new filter to the collection to be registered with WordPress. |
|
| 72 | + * |
|
| 73 | + * @since 1.0.0 |
|
| 74 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
| 75 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 76 | + * @param string $callback The name of the function definition on the $component. |
|
| 77 | + * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
|
| 78 | + * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
|
| 79 | + */ |
|
| 80 | + public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * A utility function that is used to register the actions and hooks into a single |
|
| 86 | + * collection. |
|
| 87 | + * |
|
| 88 | + * @since 1.0.0 |
|
| 89 | + * @access private |
|
| 90 | + * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). |
|
| 91 | + * @param string $hook The name of the WordPress filter that is being registered. |
|
| 92 | + * @param object $component A reference to the instance of the object on which the filter is defined. |
|
| 93 | + * @param string $callback The name of the function definition on the $component. |
|
| 94 | + * @param int $priority The priority at which the function should be fired. |
|
| 95 | + * @param int $accepted_args The number of arguments that should be passed to the $callback. |
|
| 96 | + * @return array The collection of actions and filters registered with WordPress. |
|
| 97 | + */ |
|
| 98 | + private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 99 | + |
|
| 100 | + $hooks[] = array( |
|
| 101 | + 'hook' => $hook, |
|
| 102 | + 'component' => $component, |
|
| 103 | + 'callback' => $callback, |
|
| 104 | + 'priority' => $priority, |
|
| 105 | + 'accepted_args' => $accepted_args |
|
| 106 | + ); |
|
| 107 | + |
|
| 108 | + return $hooks; |
|
| 109 | + |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Register the filters and actions with WordPress. |
|
| 114 | + * |
|
| 115 | + * @since 1.0.0 |
|
| 116 | + */ |
|
| 117 | + public function run() { |
|
| 118 | + |
|
| 119 | + foreach ( $this->filters as $hook ) { |
|
| 120 | + add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + foreach ( $this->actions as $hook ) { |
|
| 124 | + add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 125 | + } |
|
| 126 | + |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | 129 | } |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 64 | 64 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. |
| 65 | 65 | */ |
| 66 | - public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 67 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 66 | + public function add_action($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 67 | + $this->actions = $this->add($this->actions, $hook, $component, $callback, $priority, $accepted_args); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. |
| 78 | 78 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 |
| 79 | 79 | */ |
| 80 | - public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { |
|
| 81 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); |
|
| 80 | + public function add_filter($hook, $component, $callback, $priority = 10, $accepted_args = 1) { |
|
| 81 | + $this->filters = $this->add($this->filters, $hook, $component, $callback, $priority, $accepted_args); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param int $accepted_args The number of arguments that should be passed to the $callback. |
| 96 | 96 | * @return array The collection of actions and filters registered with WordPress. |
| 97 | 97 | */ |
| 98 | - private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { |
|
| 98 | + private function add($hooks, $hook, $component, $callback, $priority, $accepted_args) { |
|
| 99 | 99 | |
| 100 | 100 | $hooks[] = array( |
| 101 | 101 | 'hook' => $hook, |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function run() { |
| 118 | 118 | |
| 119 | - foreach ( $this->filters as $hook ) { |
|
| 120 | - add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 119 | + foreach ($this->filters as $hook) { |
|
| 120 | + add_filter($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - foreach ( $this->actions as $hook ) { |
|
| 124 | - add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); |
|
| 123 | + foreach ($this->actions as $hook) { |
|
| 124 | + add_action($hook['hook'], array($hook['component'], $hook['callback']), $hook['priority'], $hook['accepted_args']); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | } |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Include constants |
| 4 | -require_once( 'wordlift_core_constants.php' ); |
|
| 4 | +require_once('wordlift_core_constants.php'); |
|
| 5 | 5 | |
| 6 | 6 | // Include methods that deal with post/entity relations |
| 7 | -require_once( 'wordlift_core_post_entity_relations.php' ); |
|
| 7 | +require_once('wordlift_core_post_entity_relations.php'); |
|
| 8 | 8 | |
| 9 | 9 | // Include wl_schema api |
| 10 | -require_once( 'wordlift_core_schema_api.php' ); |
|
| 10 | +require_once('wordlift_core_schema_api.php'); |
|
| 11 | 11 | |
| 12 | 12 | // Include the Entity API which allow to query for entity posts. |
| 13 | -require_once( 'wordlift_core_entity_api.php' ); |
|
| 13 | +require_once('wordlift_core_entity_api.php'); |
|
| 14 | 14 | |
| 15 | 15 | // Include methods for Wordlift plugin install |
| 16 | -require_once( 'wordlift_core_install.php' ); |
|
| 16 | +require_once('wordlift_core_install.php'); |
|
| 17 | 17 | |
| 18 | 18 | // Include utility global functions |
| 19 | -require_once( 'wordlift_core_functions.php' ); |
|
| 20 | 19 | \ No newline at end of file |
| 20 | +require_once('wordlift_core_functions.php'); |
|
| 21 | 21 | \ No newline at end of file |
@@ -5,9 +5,9 @@ |
||
| 5 | 5 | * Ensure output buffer is cleaned |
| 6 | 6 | */ |
| 7 | 7 | function wl_core_send_json( $response ) { |
| 8 | - if ( ob_get_contents() ) { |
|
| 9 | - ob_clean(); |
|
| 10 | - } |
|
| 8 | + if ( ob_get_contents() ) { |
|
| 9 | + ob_clean(); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - return wp_send_json( $response ); |
|
| 12 | + return wp_send_json( $response ); |
|
| 13 | 13 | } |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | * @see https://codex.wordpress.org/Function_Reference/wp_send_json |
| 5 | 5 | * Ensure output buffer is cleaned |
| 6 | 6 | */ |
| 7 | -function wl_core_send_json( $response ) { |
|
| 8 | - if ( ob_get_contents() ) { |
|
| 7 | +function wl_core_send_json($response) { |
|
| 8 | + if (ob_get_contents()) { |
|
| 9 | 9 | ob_clean(); |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - return wp_send_json( $response ); |
|
| 12 | + return wp_send_json($response); |
|
| 13 | 13 | } |
@@ -2,32 +2,32 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function wordlift_geo_widget_shortcode( $atts, $content = null ) { |
| 4 | 4 | |
| 5 | - // Extract attributes and set default values. |
|
| 6 | - $params = shortcode_atts( array( |
|
| 7 | - 'width' => '100%', |
|
| 8 | - 'height' => '300px', |
|
| 9 | - 'latitude' => 0.0, |
|
| 10 | - 'longitude' => 0.0, |
|
| 11 | - 'zoom' => 5 |
|
| 12 | - |
|
| 13 | - ), $atts ); |
|
| 14 | - |
|
| 15 | - // Add leaflet css and library. |
|
| 16 | - wp_enqueue_style( 'leaflet_css', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 17 | - wp_enqueue_script( 'leaflet_js', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js' ); |
|
| 18 | - |
|
| 19 | - ob_start(); // Collect the buffer. |
|
| 20 | - wordlift_geo_widget_html( |
|
| 21 | - $params['width'], |
|
| 22 | - $params['height'], |
|
| 23 | - $params['latitude'], |
|
| 24 | - $params['longitude'], |
|
| 25 | - $params['zoom'], |
|
| 26 | - $content |
|
| 27 | - ); |
|
| 28 | - |
|
| 29 | - // Return the accumulated buffer. |
|
| 30 | - return ob_get_clean(); |
|
| 5 | + // Extract attributes and set default values. |
|
| 6 | + $params = shortcode_atts( array( |
|
| 7 | + 'width' => '100%', |
|
| 8 | + 'height' => '300px', |
|
| 9 | + 'latitude' => 0.0, |
|
| 10 | + 'longitude' => 0.0, |
|
| 11 | + 'zoom' => 5 |
|
| 12 | + |
|
| 13 | + ), $atts ); |
|
| 14 | + |
|
| 15 | + // Add leaflet css and library. |
|
| 16 | + wp_enqueue_style( 'leaflet_css', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 17 | + wp_enqueue_script( 'leaflet_js', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js' ); |
|
| 18 | + |
|
| 19 | + ob_start(); // Collect the buffer. |
|
| 20 | + wordlift_geo_widget_html( |
|
| 21 | + $params['width'], |
|
| 22 | + $params['height'], |
|
| 23 | + $params['latitude'], |
|
| 24 | + $params['longitude'], |
|
| 25 | + $params['zoom'], |
|
| 26 | + $content |
|
| 27 | + ); |
|
| 28 | + |
|
| 29 | + // Return the accumulated buffer. |
|
| 30 | + return ob_get_clean(); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
@@ -35,24 +35,24 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | function wl_geo_widget_layer_shortcode( $atts ) { |
| 37 | 37 | |
| 38 | - // Extract attributes and set default values. |
|
| 39 | - $params = shortcode_atts( array( |
|
| 40 | - 'name' => '', |
|
| 41 | - 'label' => '' |
|
| 42 | - ), $atts ); |
|
| 38 | + // Extract attributes and set default values. |
|
| 39 | + $params = shortcode_atts( array( |
|
| 40 | + 'name' => '', |
|
| 41 | + 'label' => '' |
|
| 42 | + ), $atts ); |
|
| 43 | 43 | |
| 44 | - // Return if a SPARQL Query name hasn't been provided. |
|
| 45 | - if ( empty( $params['name'] ) ) { |
|
| 46 | - return; |
|
| 47 | - } |
|
| 44 | + // Return if a SPARQL Query name hasn't been provided. |
|
| 45 | + if ( empty( $params['name'] ) ) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - // Set the layer label. |
|
| 50 | - $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 49 | + // Set the layer label. |
|
| 50 | + $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 51 | 51 | |
| 52 | - // Define the AJAX Url. |
|
| 53 | - $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 52 | + // Define the AJAX Url. |
|
| 53 | + $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 54 | 54 | |
| 55 | - echo <<<EOF |
|
| 55 | + echo <<<EOF |
|
| 56 | 56 | |
| 57 | 57 | $.ajax( '$ajax_url', { |
| 58 | 58 | success: function( data ) { |
@@ -83,21 +83,21 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | function wl_geo_widget_marker_shortcode( $atts ) { |
| 85 | 85 | |
| 86 | - // Extract attributes and set default values. |
|
| 87 | - $params = shortcode_atts( array( |
|
| 88 | - 'latitude' => null, |
|
| 89 | - 'longitude' => null |
|
| 90 | - ), $atts ); |
|
| 86 | + // Extract attributes and set default values. |
|
| 87 | + $params = shortcode_atts( array( |
|
| 88 | + 'latitude' => null, |
|
| 89 | + 'longitude' => null |
|
| 90 | + ), $atts ); |
|
| 91 | 91 | |
| 92 | - // Return if either latitude or longitude haven't been provided. |
|
| 93 | - if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 94 | - return; |
|
| 95 | - } |
|
| 92 | + // Return if either latitude or longitude haven't been provided. |
|
| 93 | + if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - $latitude_j = json_encode( $params['latitude'] ); |
|
| 98 | - $longitude_j = json_encode( $params['longitude'] ); |
|
| 97 | + $latitude_j = json_encode( $params['latitude'] ); |
|
| 98 | + $longitude_j = json_encode( $params['longitude'] ); |
|
| 99 | 99 | |
| 100 | - echo <<<EOF |
|
| 100 | + echo <<<EOF |
|
| 101 | 101 | |
| 102 | 102 | L.marker([$latitude_j, $longitude_j]).addTo(map); |
| 103 | 103 | EOF; |
@@ -109,10 +109,10 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | function wordlift_geo_widget_html( $width, $height, $latitude, $longitude, $zoom, $content ) { |
| 111 | 111 | |
| 112 | - // Create a unique Id for this widget. |
|
| 113 | - $div_id = uniqid( 'wl-geo-' ); |
|
| 112 | + // Create a unique Id for this widget. |
|
| 113 | + $div_id = uniqid( 'wl-geo-' ); |
|
| 114 | 114 | |
| 115 | - echo <<<EOF |
|
| 115 | + echo <<<EOF |
|
| 116 | 116 | <div id="$div_id" style="width: $width; height: $height;"></div> |
| 117 | 117 | |
| 118 | 118 | <script type="text/javascript"> |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | |
| 138 | 138 | EOF; |
| 139 | 139 | |
| 140 | - // Run inner shortcodes. |
|
| 141 | - do_shortcode( $content ); |
|
| 140 | + // Run inner shortcodes. |
|
| 141 | + do_shortcode( $content ); |
|
| 142 | 142 | |
| 143 | - echo <<<EOF |
|
| 143 | + echo <<<EOF |
|
| 144 | 144 | |
| 145 | 145 | } ); |
| 146 | 146 | </script> |
@@ -1,20 +1,20 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function wordlift_geo_widget_shortcode( $atts, $content = null ) { |
|
| 3 | +function wordlift_geo_widget_shortcode($atts, $content = null) { |
|
| 4 | 4 | |
| 5 | 5 | // Extract attributes and set default values. |
| 6 | - $params = shortcode_atts( array( |
|
| 6 | + $params = shortcode_atts(array( |
|
| 7 | 7 | 'width' => '100%', |
| 8 | 8 | 'height' => '300px', |
| 9 | 9 | 'latitude' => 0.0, |
| 10 | 10 | 'longitude' => 0.0, |
| 11 | 11 | 'zoom' => 5 |
| 12 | 12 | |
| 13 | - ), $atts ); |
|
| 13 | + ), $atts); |
|
| 14 | 14 | |
| 15 | 15 | // Add leaflet css and library. |
| 16 | - wp_enqueue_style( 'leaflet_css', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.css' ); |
|
| 17 | - wp_enqueue_script( 'leaflet_js', dirname( dirname( plugin_dir_url( __FILE__ ) ) ) . '/bower_components/leaflet/dist/leaflet.js' ); |
|
| 16 | + wp_enqueue_style('leaflet_css', dirname(dirname(plugin_dir_url(__FILE__))).'/bower_components/leaflet/dist/leaflet.css'); |
|
| 17 | + wp_enqueue_script('leaflet_js', dirname(dirname(plugin_dir_url(__FILE__))).'/bower_components/leaflet/dist/leaflet.js'); |
|
| 18 | 18 | |
| 19 | 19 | ob_start(); // Collect the buffer. |
| 20 | 20 | wordlift_geo_widget_html( |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -add_shortcode( 'wl_geo', 'wordlift_geo_widget_shortcode' ); |
|
| 34 | +add_shortcode('wl_geo', 'wordlift_geo_widget_shortcode'); |
|
| 35 | 35 | |
| 36 | -function wl_geo_widget_layer_shortcode( $atts ) { |
|
| 36 | +function wl_geo_widget_layer_shortcode($atts) { |
|
| 37 | 37 | |
| 38 | 38 | // Extract attributes and set default values. |
| 39 | - $params = shortcode_atts( array( |
|
| 39 | + $params = shortcode_atts(array( |
|
| 40 | 40 | 'name' => '', |
| 41 | 41 | 'label' => '' |
| 42 | - ), $atts ); |
|
| 42 | + ), $atts); |
|
| 43 | 43 | |
| 44 | 44 | // Return if a SPARQL Query name hasn't been provided. |
| 45 | - if ( empty( $params['name'] ) ) { |
|
| 45 | + if (empty($params['name'])) { |
|
| 46 | 46 | return; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // Set the layer label. |
| 50 | - $label_j = json_encode( empty( $params['label'] ) ? $params['name'] : $params['label'] ); |
|
| 50 | + $label_j = json_encode(empty($params['label']) ? $params['name'] : $params['label']); |
|
| 51 | 51 | |
| 52 | 52 | // Define the AJAX Url. |
| 53 | - $ajax_url = admin_url( 'admin-ajax.php?action=wl_sparql&format=geojson&slug=' . urlencode( $params['name'] ) ); |
|
| 53 | + $ajax_url = admin_url('admin-ajax.php?action=wl_sparql&format=geojson&slug='.urlencode($params['name'])); |
|
| 54 | 54 | |
| 55 | 55 | echo <<<EOF |
| 56 | 56 | |
@@ -78,24 +78,24 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | -add_shortcode( 'wl_geo_layer', 'wl_geo_widget_layer_shortcode' ); |
|
| 81 | +add_shortcode('wl_geo_layer', 'wl_geo_widget_layer_shortcode'); |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | -function wl_geo_widget_marker_shortcode( $atts ) { |
|
| 84 | +function wl_geo_widget_marker_shortcode($atts) { |
|
| 85 | 85 | |
| 86 | 86 | // Extract attributes and set default values. |
| 87 | - $params = shortcode_atts( array( |
|
| 87 | + $params = shortcode_atts(array( |
|
| 88 | 88 | 'latitude' => null, |
| 89 | 89 | 'longitude' => null |
| 90 | - ), $atts ); |
|
| 90 | + ), $atts); |
|
| 91 | 91 | |
| 92 | 92 | // Return if either latitude or longitude haven't been provided. |
| 93 | - if ( empty( $params['latitude'] ) || empty( $params['longitude'] ) ) { |
|
| 93 | + if (empty($params['latitude']) || empty($params['longitude'])) { |
|
| 94 | 94 | return; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - $latitude_j = json_encode( $params['latitude'] ); |
|
| 98 | - $longitude_j = json_encode( $params['longitude'] ); |
|
| 97 | + $latitude_j = json_encode($params['latitude']); |
|
| 98 | + $longitude_j = json_encode($params['longitude']); |
|
| 99 | 99 | |
| 100 | 100 | echo <<<EOF |
| 101 | 101 | |
@@ -104,13 +104,13 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | -add_shortcode( 'wl_geo_marker', 'wl_geo_widget_marker_shortcode' ); |
|
| 107 | +add_shortcode('wl_geo_marker', 'wl_geo_widget_marker_shortcode'); |
|
| 108 | 108 | |
| 109 | 109 | |
| 110 | -function wordlift_geo_widget_html( $width, $height, $latitude, $longitude, $zoom, $content ) { |
|
| 110 | +function wordlift_geo_widget_html($width, $height, $latitude, $longitude, $zoom, $content) { |
|
| 111 | 111 | |
| 112 | 112 | // Create a unique Id for this widget. |
| 113 | - $div_id = uniqid( 'wl-geo-' ); |
|
| 113 | + $div_id = uniqid('wl-geo-'); |
|
| 114 | 114 | |
| 115 | 115 | echo <<<EOF |
| 116 | 116 | <div id="$div_id" style="width: $width; height: $height;"></div> |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | EOF; |
| 139 | 139 | |
| 140 | 140 | // Run inner shortcodes. |
| 141 | - do_shortcode( $content ); |
|
| 141 | + do_shortcode($content); |
|
| 142 | 142 | |
| 143 | 143 | echo <<<EOF |
| 144 | 144 | |
@@ -9,18 +9,18 @@ discard block |
||
| 9 | 9 | * @return array An array with information about the saved image (*path*: the local path to the image, *url*: the local |
| 10 | 10 | * url, *content_type*: the image content type) |
| 11 | 11 | */ |
| 12 | -function wl_save_image( $url ) { |
|
| 12 | +function wl_save_image($url) { |
|
| 13 | 13 | |
| 14 | - $parts = parse_url( $url ); |
|
| 14 | + $parts = parse_url($url); |
|
| 15 | 15 | $path = $parts['path']; |
| 16 | 16 | |
| 17 | 17 | // Get the bare filename (filename w/o the extension). |
| 18 | 18 | // Sanitize filename before saving the current image as attachment |
| 19 | 19 | // See https://codex.wordpress.org/Function_Reference/sanitize_file_name |
| 20 | - $basename = sanitize_file_name( pathinfo( $path, PATHINFO_FILENAME ) . '-' . uniqid( date( 'YmdH-' ) ) ); |
|
| 20 | + $basename = sanitize_file_name(pathinfo($path, PATHINFO_FILENAME).'-'.uniqid(date('YmdH-'))); |
|
| 21 | 21 | |
| 22 | 22 | // Chunk the bare name to get a subpath. |
| 23 | - $chunks = chunk_split( strtolower( $basename ), 3, DIRECTORY_SEPARATOR ); |
|
| 23 | + $chunks = chunk_split(strtolower($basename), 3, DIRECTORY_SEPARATOR); |
|
| 24 | 24 | |
| 25 | 25 | // Get the base dir. |
| 26 | 26 | $wp_upload_dir = wp_upload_dir(); |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | $base_url = $wp_upload_dir['baseurl']; |
| 29 | 29 | |
| 30 | 30 | // Get the full path to the local filename. |
| 31 | - $image_path = '/' . $chunks; |
|
| 32 | - $image_full_path = $base_dir . $image_path; |
|
| 33 | - $image_full_url = $base_url . $image_path; |
|
| 31 | + $image_path = '/'.$chunks; |
|
| 32 | + $image_full_path = $base_dir.$image_path; |
|
| 33 | + $image_full_url = $base_url.$image_path; |
|
| 34 | 34 | |
| 35 | 35 | // Create the folders. |
| 36 | - if ( ! ( file_exists( $image_full_path ) && is_dir( $image_full_path ) ) ) { |
|
| 37 | - if ( false === mkdir( $image_full_path, 0777, true ) ) { |
|
| 38 | - wl_write_log( "wl_save_image : failed creating dir [ image full path :: $image_full_path ]\n" ); |
|
| 36 | + if ( ! (file_exists($image_full_path) && is_dir($image_full_path))) { |
|
| 37 | + if (false === mkdir($image_full_path, 0777, true)) { |
|
| 38 | + wl_write_log("wl_save_image : failed creating dir [ image full path :: $image_full_path ]\n"); |
|
| 39 | 39 | } |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | 42 | // Request the remote file. |
| 43 | - $response = wp_remote_get( $url ); |
|
| 44 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 43 | + $response = wp_remote_get($url); |
|
| 44 | + $content_type = wp_remote_retrieve_header($response, 'content-type'); |
|
| 45 | 45 | |
| 46 | - switch ( $content_type ) { |
|
| 46 | + switch ($content_type) { |
|
| 47 | 47 | case 'image/jpeg': |
| 48 | 48 | case 'image/jpg': |
| 49 | 49 | $extension = ".jpg"; |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | // Complete the local filename. |
| 65 | - $image_full_path .= $basename . $extension; |
|
| 66 | - $image_full_url .= $basename . $extension; |
|
| 65 | + $image_full_path .= $basename.$extension; |
|
| 66 | + $image_full_url .= $basename.$extension; |
|
| 67 | 67 | |
| 68 | 68 | // Store the data locally. |
| 69 | - file_put_contents( $image_full_path, wp_remote_retrieve_body( $response ) ); |
|
| 69 | + file_put_contents($image_full_path, wp_remote_retrieve_body($response)); |
|
| 70 | 70 | |
| 71 | 71 | // wl_write_log( "wl_save_image [ url :: $url ][ content type :: $content_type ][ image full path :: $image_full_path ][ image full url :: $image_full_url ]\n" ); |
| 72 | 72 | |
@@ -10,69 +10,69 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | function wl_save_image( $url ) { |
| 12 | 12 | |
| 13 | - $parts = parse_url( $url ); |
|
| 14 | - $path = $parts['path']; |
|
| 13 | + $parts = parse_url( $url ); |
|
| 14 | + $path = $parts['path']; |
|
| 15 | 15 | |
| 16 | - // Get the bare filename (filename w/o the extension). |
|
| 17 | - // Sanitize filename before saving the current image as attachment |
|
| 18 | - // See https://codex.wordpress.org/Function_Reference/sanitize_file_name |
|
| 19 | - $basename = sanitize_file_name( pathinfo( $path, PATHINFO_FILENAME ) . '-' . uniqid( date( 'YmdH-' ) ) ); |
|
| 16 | + // Get the bare filename (filename w/o the extension). |
|
| 17 | + // Sanitize filename before saving the current image as attachment |
|
| 18 | + // See https://codex.wordpress.org/Function_Reference/sanitize_file_name |
|
| 19 | + $basename = sanitize_file_name( pathinfo( $path, PATHINFO_FILENAME ) . '-' . uniqid( date( 'YmdH-' ) ) ); |
|
| 20 | 20 | |
| 21 | - // Chunk the bare name to get a subpath. |
|
| 22 | - $chunks = chunk_split( strtolower( $basename ), 3, DIRECTORY_SEPARATOR ); |
|
| 21 | + // Chunk the bare name to get a subpath. |
|
| 22 | + $chunks = chunk_split( strtolower( $basename ), 3, DIRECTORY_SEPARATOR ); |
|
| 23 | 23 | |
| 24 | - // Get the base dir. |
|
| 25 | - $wp_upload_dir = wp_upload_dir(); |
|
| 26 | - $base_dir = $wp_upload_dir['basedir']; |
|
| 27 | - $base_url = $wp_upload_dir['baseurl']; |
|
| 24 | + // Get the base dir. |
|
| 25 | + $wp_upload_dir = wp_upload_dir(); |
|
| 26 | + $base_dir = $wp_upload_dir['basedir']; |
|
| 27 | + $base_url = $wp_upload_dir['baseurl']; |
|
| 28 | 28 | |
| 29 | - // Get the full path to the local filename. |
|
| 30 | - $image_path = '/' . $chunks; |
|
| 31 | - $image_full_path = $base_dir . $image_path; |
|
| 32 | - $image_full_url = $base_url . $image_path; |
|
| 29 | + // Get the full path to the local filename. |
|
| 30 | + $image_path = '/' . $chunks; |
|
| 31 | + $image_full_path = $base_dir . $image_path; |
|
| 32 | + $image_full_url = $base_url . $image_path; |
|
| 33 | 33 | |
| 34 | - // Create the folders. |
|
| 35 | - if ( ! ( file_exists( $image_full_path ) && is_dir( $image_full_path ) ) ) { |
|
| 36 | - if ( false === mkdir( $image_full_path, 0777, true ) ) { |
|
| 37 | - wl_write_log( "wl_save_image : failed creating dir [ image full path :: $image_full_path ]\n" ); |
|
| 38 | - } |
|
| 39 | - }; |
|
| 34 | + // Create the folders. |
|
| 35 | + if ( ! ( file_exists( $image_full_path ) && is_dir( $image_full_path ) ) ) { |
|
| 36 | + if ( false === mkdir( $image_full_path, 0777, true ) ) { |
|
| 37 | + wl_write_log( "wl_save_image : failed creating dir [ image full path :: $image_full_path ]\n" ); |
|
| 38 | + } |
|
| 39 | + }; |
|
| 40 | 40 | |
| 41 | - // Request the remote file. |
|
| 42 | - $response = wp_remote_get( $url ); |
|
| 43 | - $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 41 | + // Request the remote file. |
|
| 42 | + $response = wp_remote_get( $url ); |
|
| 43 | + $content_type = wp_remote_retrieve_header( $response, 'content-type' ); |
|
| 44 | 44 | |
| 45 | - switch ( $content_type ) { |
|
| 46 | - case 'image/jpeg': |
|
| 47 | - case 'image/jpg': |
|
| 48 | - $extension = ".jpg"; |
|
| 49 | - break; |
|
| 50 | - case 'image/svg+xml': |
|
| 51 | - $extension = ".svg"; |
|
| 52 | - break; |
|
| 53 | - case 'image/gif': |
|
| 54 | - $extension = ".gif"; |
|
| 55 | - break; |
|
| 56 | - case 'image/png': |
|
| 57 | - $extension = ".png"; |
|
| 58 | - break; |
|
| 59 | - default: |
|
| 60 | - $extension = ''; |
|
| 61 | - } |
|
| 45 | + switch ( $content_type ) { |
|
| 46 | + case 'image/jpeg': |
|
| 47 | + case 'image/jpg': |
|
| 48 | + $extension = ".jpg"; |
|
| 49 | + break; |
|
| 50 | + case 'image/svg+xml': |
|
| 51 | + $extension = ".svg"; |
|
| 52 | + break; |
|
| 53 | + case 'image/gif': |
|
| 54 | + $extension = ".gif"; |
|
| 55 | + break; |
|
| 56 | + case 'image/png': |
|
| 57 | + $extension = ".png"; |
|
| 58 | + break; |
|
| 59 | + default: |
|
| 60 | + $extension = ''; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // Complete the local filename. |
|
| 64 | - $image_full_path .= $basename . $extension; |
|
| 65 | - $image_full_url .= $basename . $extension; |
|
| 63 | + // Complete the local filename. |
|
| 64 | + $image_full_path .= $basename . $extension; |
|
| 65 | + $image_full_url .= $basename . $extension; |
|
| 66 | 66 | |
| 67 | - // Store the data locally. |
|
| 68 | - file_put_contents( $image_full_path, wp_remote_retrieve_body( $response ) ); |
|
| 67 | + // Store the data locally. |
|
| 68 | + file_put_contents( $image_full_path, wp_remote_retrieve_body( $response ) ); |
|
| 69 | 69 | |
| 70 | - // wl_write_log( "wl_save_image [ url :: $url ][ content type :: $content_type ][ image full path :: $image_full_path ][ image full url :: $image_full_url ]\n" ); |
|
| 70 | + // wl_write_log( "wl_save_image [ url :: $url ][ content type :: $content_type ][ image full path :: $image_full_path ][ image full url :: $image_full_url ]\n" ); |
|
| 71 | 71 | |
| 72 | - // Return the path. |
|
| 73 | - return array( |
|
| 74 | - 'path' => $image_full_path, |
|
| 75 | - 'url' => $image_full_url, |
|
| 76 | - 'content_type' => $content_type, |
|
| 77 | - ); |
|
| 72 | + // Return the path. |
|
| 73 | + return array( |
|
| 74 | + 'path' => $image_full_path, |
|
| 75 | + 'url' => $image_full_url, |
|
| 76 | + 'content_type' => $content_type, |
|
| 77 | + ); |
|
| 78 | 78 | } |
@@ -3,8 +3,8 @@ discard block |
||
| 3 | 3 | * This file contains the Prefixes List table. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -if( ! class_exists( 'WP_List_Table' ) ) { |
|
| 7 | - require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); |
|
| 6 | +if ( ! class_exists('WP_List_Table')) { |
|
| 7 | + require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | var $_column_headers; |
| 19 | 19 | |
| 20 | - function get_columns(){ |
|
| 20 | + function get_columns() { |
|
| 21 | 21 | $columns = array( |
| 22 | 22 | // 'cb' => '<input type="checkbox" />', |
| 23 | 23 | 'prefix' => 'Prefix', |
@@ -30,31 +30,31 @@ discard block |
||
| 30 | 30 | $columns = $this->get_columns(); |
| 31 | 31 | $hidden = array(); |
| 32 | 32 | $sortable = $this->get_sortable_columns(); |
| 33 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 33 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 34 | 34 | |
| 35 | 35 | $prefixes = wl_prefixes_list(); |
| 36 | - usort( $prefixes, array( &$this, 'usort_reorder' ) ); |
|
| 36 | + usort($prefixes, array(&$this, 'usort_reorder')); |
|
| 37 | 37 | $this->items = $prefixes; |
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - function column_default( $item, $column_name ) { |
|
| 42 | - switch( $column_name ) { |
|
| 41 | + function column_default($item, $column_name) { |
|
| 42 | + switch ($column_name) { |
|
| 43 | 43 | case 'prefix': |
| 44 | 44 | case 'namespace': |
| 45 | - return $item[ $column_name ]; |
|
| 45 | + return $item[$column_name]; |
|
| 46 | 46 | default: |
| 47 | - return print_r( $item, true ) ; //Show the whole array for troubleshooting purposes |
|
| 47 | + return print_r($item, true); //Show the whole array for troubleshooting purposes |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - function column_prefix( $item ) { |
|
| 51 | + function column_prefix($item) { |
|
| 52 | 52 | $actions = array( |
| 53 | 53 | // 'edit' => sprintf( '<a href="?page=%s&action=%s&prefix=%s">Edit</a>', $_REQUEST['page'], 'edit', $item['prefix'] ), |
| 54 | - 'delete' => sprintf( '<a href="?page=%s&action=%s&prefix=%s">Delete</a>', $_REQUEST['page'], 'delete', $item['prefix'] ) |
|
| 54 | + 'delete' => sprintf('<a href="?page=%s&action=%s&prefix=%s">Delete</a>', $_REQUEST['page'], 'delete', $item['prefix']) |
|
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - return sprintf( '%1$s %2$s', $item['prefix'], $this->row_actions($actions) ); |
|
| 57 | + return sprintf('%1$s %2$s', $item['prefix'], $this->row_actions($actions)); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
@@ -67,21 +67,21 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | function get_sortable_columns() { |
| 69 | 69 | $sortable_columns = array( |
| 70 | - 'prefix' => array('prefix',false), |
|
| 71 | - 'namespace' => array('namespace',false) |
|
| 70 | + 'prefix' => array('prefix', false), |
|
| 71 | + 'namespace' => array('namespace', false) |
|
| 72 | 72 | ); |
| 73 | 73 | return $sortable_columns; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - function usort_reorder( $a, $b ) { |
|
| 76 | + function usort_reorder($a, $b) { |
|
| 77 | 77 | // If no sort, default to title |
| 78 | - $orderby = ( ! empty( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'prefix'; |
|
| 78 | + $orderby = ( ! empty($_GET['orderby'])) ? $_GET['orderby'] : 'prefix'; |
|
| 79 | 79 | // If no order, default to asc |
| 80 | - $order = ( ! empty($_GET['order'] ) ) ? $_GET['order'] : 'asc'; |
|
| 80 | + $order = ( ! empty($_GET['order'])) ? $_GET['order'] : 'asc'; |
|
| 81 | 81 | // Determine sort order |
| 82 | - $result = strcmp( $a[$orderby], $b[$orderby] ); |
|
| 82 | + $result = strcmp($a[$orderby], $b[$orderby]); |
|
| 83 | 83 | // Send final sort direction to usort |
| 84 | - return ( $order === 'asc' ) ? $result : -$result; |
|
| 84 | + return ($order === 'asc') ? $result : -$result; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | function get_bulk_actions() { |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | function wordlift_ajax_redirect() { |
| 11 | 11 | |
| 12 | - $url = $_GET['url']; |
|
| 13 | - $link = get_permalink( get_page_by_path( 'timeline-event' ) ); |
|
| 14 | - header( 'Location: ' . $link . '?url=' . urlencode( $url ) ); |
|
| 15 | - wp_die(); |
|
| 12 | + $url = $_GET['url']; |
|
| 13 | + $link = get_permalink( get_page_by_path( 'timeline-event' ) ); |
|
| 14 | + header( 'Location: ' . $link . '?url=' . urlencode( $url ) ); |
|
| 15 | + wp_die(); |
|
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
@@ -10,11 +10,11 @@ |
||
| 10 | 10 | function wordlift_ajax_redirect() { |
| 11 | 11 | |
| 12 | 12 | $url = $_GET['url']; |
| 13 | - $link = get_permalink( get_page_by_path( 'timeline-event' ) ); |
|
| 14 | - header( 'Location: ' . $link . '?url=' . urlencode( $url ) ); |
|
| 13 | + $link = get_permalink(get_page_by_path('timeline-event')); |
|
| 14 | + header('Location: '.$link.'?url='.urlencode($url)); |
|
| 15 | 15 | wp_die(); |
| 16 | 16 | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -add_action( 'wp_ajax_wl_redirect', 'wordlift_ajax_redirect' ); |
|
| 20 | -add_action( 'wp_ajax_nopriv_wl_redirect', 'wordlift_ajax_redirect' ); |
|
| 21 | 19 | \ No newline at end of file |
| 20 | +add_action('wp_ajax_wl_redirect', 'wordlift_ajax_redirect'); |
|
| 21 | +add_action('wp_ajax_nopriv_wl_redirect', 'wordlift_ajax_redirect'); |
|
| 22 | 22 | \ No newline at end of file |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @param array $atts An array of shortcode attributes. |
| 10 | 10 | * @return string A dom element with requested property value(s). |
| 11 | 11 | */ |
| 12 | -function wl_shortcode_field( $atts ) { |
|
| 12 | +function wl_shortcode_field($atts) { |
|
| 13 | 13 | |
| 14 | 14 | // Extract attributes and set default values. |
| 15 | - $field_atts = shortcode_atts( array( |
|
| 15 | + $field_atts = shortcode_atts(array( |
|
| 16 | 16 | 'id' => null, |
| 17 | 17 | 'name' => null |
| 18 | - ), $atts ); |
|
| 18 | + ), $atts); |
|
| 19 | 19 | |
| 20 | 20 | // Get id of the post |
| 21 | 21 | $entity_id = $field_atts['id']; |
| 22 | - if( is_null( $field_atts['id'] ) || !is_numeric( $field_atts['id'] ) ) { |
|
| 22 | + if (is_null($field_atts['id']) || ! is_numeric($field_atts['id'])) { |
|
| 23 | 23 | $entity_id = get_the_ID(); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $property_name = $field_atts['name']; |
| 27 | - if( !is_null( $property_name ) ) { |
|
| 28 | - $values = wl_schema_get_value( $entity_id, $property_name ); |
|
| 27 | + if ( ! is_null($property_name)) { |
|
| 28 | + $values = wl_schema_get_value($entity_id, $property_name); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Return |
| 32 | - if( is_array( $values ) ) { |
|
| 33 | - return implode( ', ', $values ); |
|
| 32 | + if (is_array($values)) { |
|
| 33 | + return implode(', ', $values); |
|
| 34 | 34 | } else { |
| 35 | 35 | return null; |
| 36 | 36 | } |
@@ -40,5 +40,5 @@ discard block |
||
| 40 | 40 | add_shortcode('wl_field', 'wl_shortcode_field'); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | -add_action( 'init', 'wl_register_shortcode_field'); |
|
| 43 | +add_action('init', 'wl_register_shortcode_field'); |
|
| 44 | 44 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // If uninstall not called from WordPress, then exit. |
| 29 | 29 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 30 | - exit; |
|
| 30 | + exit; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Get a reference to WP and the Wordlift plugin |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | // Do a db search for posts of type entity |
| 42 | 42 | $args = array( |
| 43 | - 'posts_per_page' => - 1, |
|
| 44 | - 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 46 | - 'fields' => 'ids' |
|
| 43 | + 'posts_per_page' => - 1, |
|
| 44 | + 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
|
| 45 | + 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 46 | + 'fields' => 'ids' |
|
| 47 | 47 | ); |
| 48 | 48 | $entities_array = get_posts( $args ); |
| 49 | 49 | |
@@ -52,8 +52,8 @@ discard block |
||
| 52 | 52 | wl_write_log( 'Deleting entities and their meta... ' ); |
| 53 | 53 | wl_write_log( $entities_array ); |
| 54 | 54 | foreach ( $entities_array as $entity_id ) { |
| 55 | - // Delete the whole entity and its metas. |
|
| 56 | - wp_delete_post( $entity_id, true ); |
|
| 55 | + // Delete the whole entity and its metas. |
|
| 56 | + wp_delete_post( $entity_id, true ); |
|
| 57 | 57 | } |
| 58 | 58 | wl_write_log( 'Done.' ); |
| 59 | 59 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | // We loop over terms in this rude way because in the uninstall script |
| 75 | 75 | // is not possible to call WP custom taxonomy functions. |
| 76 | 76 | foreach ( range( 0, 100 ) as $index ) { |
| 77 | - delete_option( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | - wp_delete_term( $index, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 77 | + delete_option( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | + wp_delete_term( $index, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 79 | 79 | } |
| 80 | 80 | delete_option( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
| 81 | 81 | wl_write_log( 'Done.' ); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | // If uninstall not called from WordPress, then exit. |
| 29 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
| 29 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
| 30 | 30 | exit; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -39,53 +39,53 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | 41 | // Do a db search for posts of type entity |
| 42 | -$args = array( |
|
| 43 | - 'posts_per_page' => - 1, |
|
| 42 | +$args = array( |
|
| 43 | + 'posts_per_page' => -1, |
|
| 44 | 44 | 'post_type' => Wordlift_Entity_Service::TYPE_NAME, |
| 45 | - 'post_status' => array( 'publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash' ), |
|
| 45 | + 'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash'), |
|
| 46 | 46 | 'fields' => 'ids' |
| 47 | 47 | ); |
| 48 | -$entities_array = get_posts( $args ); |
|
| 48 | +$entities_array = get_posts($args); |
|
| 49 | 49 | |
| 50 | 50 | // Loop over entities and delete them. |
| 51 | 51 | // TODO: thumbnails? |
| 52 | -wl_write_log( 'Deleting entities and their meta... ' ); |
|
| 53 | -wl_write_log( $entities_array ); |
|
| 54 | -foreach ( $entities_array as $entity_id ) { |
|
| 52 | +wl_write_log('Deleting entities and their meta... '); |
|
| 53 | +wl_write_log($entities_array); |
|
| 54 | +foreach ($entities_array as $entity_id) { |
|
| 55 | 55 | // Delete the whole entity and its metas. |
| 56 | - wp_delete_post( $entity_id, true ); |
|
| 56 | + wp_delete_post($entity_id, true); |
|
| 57 | 57 | } |
| 58 | -wl_write_log( 'Done.' ); |
|
| 58 | +wl_write_log('Done.'); |
|
| 59 | 59 | |
| 60 | 60 | /* |
| 61 | 61 | * Delete post-entity relationships |
| 62 | 62 | */ |
| 63 | -wl_write_log( 'Deleting post-entity relationships... ' ); |
|
| 64 | -$sql = 'DROP TABLE IF EXISTS ' . wl_core_get_relation_instances_table_name() . ';'; |
|
| 65 | -$wpdb->query( $sql ); |
|
| 66 | -delete_option( 'wl_db_version' ); |
|
| 67 | -wl_write_log( 'Done.' ); |
|
| 63 | +wl_write_log('Deleting post-entity relationships... '); |
|
| 64 | +$sql = 'DROP TABLE IF EXISTS '.wl_core_get_relation_instances_table_name().';'; |
|
| 65 | +$wpdb->query($sql); |
|
| 66 | +delete_option('wl_db_version'); |
|
| 67 | +wl_write_log('Done.'); |
|
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | 70 | * Delete taxonomy |
| 71 | 71 | */ |
| 72 | -wl_write_log( 'Cleaning entities taxonomy... ' ); |
|
| 72 | +wl_write_log('Cleaning entities taxonomy... '); |
|
| 73 | 73 | // Delte custom taxonomy terms. |
| 74 | 74 | // We loop over terms in this rude way because in the uninstall script |
| 75 | 75 | // is not possible to call WP custom taxonomy functions. |
| 76 | -foreach ( range( 0, 100 ) as $index ) { |
|
| 77 | - delete_option( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME . '_' . $index ); |
|
| 78 | - wp_delete_term( $index, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME ); |
|
| 76 | +foreach (range(0, 100) as $index) { |
|
| 77 | + delete_option(Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME.'_'.$index); |
|
| 78 | + wp_delete_term($index, Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME); |
|
| 79 | 79 | } |
| 80 | -delete_option( Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME . '_children' ); // it's a hierarchical taxonomy |
|
| 81 | -wl_write_log( 'Done.' ); |
|
| 80 | +delete_option(Wordlift_Entity_Types_Taxonomy_Service::TAXONOMY_NAME.'_children'); // it's a hierarchical taxonomy |
|
| 81 | +wl_write_log('Done.'); |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Delete options |
| 85 | 85 | */ |
| 86 | -wl_write_log( 'Cleaning WordLift options... ' ); |
|
| 86 | +wl_write_log('Cleaning WordLift options... '); |
|
| 87 | 87 | // delete_option( WL_OPTIONS_NAME ); |
| 88 | -delete_option( 'wl_option_prefixes' ); |
|
| 89 | -delete_option( 'wl_general_settings' ); |
|
| 90 | -delete_option( 'wl_advanced_settings' ); |
|
| 91 | -wl_write_log( 'Done. WordLift successfully uninstalled.' ); |
|
| 88 | +delete_option('wl_option_prefixes'); |
|
| 89 | +delete_option('wl_general_settings'); |
|
| 90 | +delete_option('wl_advanced_settings'); |
|
| 91 | +wl_write_log('Done. WordLift successfully uninstalled.'); |
|