Completed
Pull Request — develop (#900)
by William
04:03
created
src/includes/class-wordlift-i18n.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -26,38 +26,38 @@
 block discarded – undo
26 26
  */
27 27
 class Wordlift_i18n {
28 28
 
29
-	/**
30
-	 * The domain specified for this plugin.
31
-	 *
32
-	 * @since    1.0.0
33
-	 * @access   private
34
-	 * @var      string    $domain    The domain identifier for this plugin.
35
-	 */
36
-	private $domain;
37
-
38
-	/**
39
-	 * Load the plugin text domain for translation.
40
-	 *
41
-	 * @since    1.0.0
42
-	 */
43
-	public function load_plugin_textdomain() {
44
-
45
-		load_plugin_textdomain(
46
-			$this->domain,
47
-			false,
48
-			dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
49
-		);
50
-
51
-	}
52
-
53
-	/**
54
-	 * Set the domain equal to that of the specified domain.
55
-	 *
56
-	 * @since    1.0.0
57
-	 * @param    string    $domain    The domain that represents the locale of this plugin.
58
-	 */
59
-	public function set_domain( $domain ) {
60
-		$this->domain = $domain;
61
-	}
29
+    /**
30
+     * The domain specified for this plugin.
31
+     *
32
+     * @since    1.0.0
33
+     * @access   private
34
+     * @var      string    $domain    The domain identifier for this plugin.
35
+     */
36
+    private $domain;
37
+
38
+    /**
39
+     * Load the plugin text domain for translation.
40
+     *
41
+     * @since    1.0.0
42
+     */
43
+    public function load_plugin_textdomain() {
44
+
45
+        load_plugin_textdomain(
46
+            $this->domain,
47
+            false,
48
+            dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
49
+        );
50
+
51
+    }
52
+
53
+    /**
54
+     * Set the domain equal to that of the specified domain.
55
+     *
56
+     * @since    1.0.0
57
+     * @param    string    $domain    The domain that represents the locale of this plugin.
58
+     */
59
+    public function set_domain( $domain ) {
60
+        $this->domain = $domain;
61
+    }
62 62
 
63 63
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-loader.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -23,107 +23,107 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/includes/class-wordlift-ui-service.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -7,80 +7,80 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_UI_Service {
9 9
 
10
-	/**
11
-	 * The button element HTML code.
12
-	 *
13
-	 * @since 3.2.0
14
-	 */
15
-	const BUTTON_HTML = '<a id="%s" class="button wl-button">%s</a>';
10
+    /**
11
+     * The button element HTML code.
12
+     *
13
+     * @since 3.2.0
14
+     */
15
+    const BUTTON_HTML = '<a id="%s" class="button wl-button">%s</a>';
16 16
 
17
-	/**
18
-	 * The template HTML code.
19
-	 *
20
-	 * @since 3.2.0
21
-	 */
22
-	const TEMPLATE_HTML = '<script id="%s" type="text/template">%s</script>';
17
+    /**
18
+     * The template HTML code.
19
+     *
20
+     * @since 3.2.0
21
+     */
22
+    const TEMPLATE_HTML = '<script id="%s" type="text/template">%s</script>';
23 23
 
24
-	/**
25
-	 * Get the button HTML.
26
-	 *
27
-	 * @since 3.2.0
28
-	 *
29
-	 * @param string $element_id The button element id.
30
-	 * @param string $label The button (translated) label.
31
-	 *
32
-	 * @return string The button HTML code.
33
-	 */
34
-	public function get_button_html( $element_id, $label ) {
24
+    /**
25
+     * Get the button HTML.
26
+     *
27
+     * @since 3.2.0
28
+     *
29
+     * @param string $element_id The button element id.
30
+     * @param string $label The button (translated) label.
31
+     *
32
+     * @return string The button HTML code.
33
+     */
34
+    public function get_button_html( $element_id, $label ) {
35 35
 
36
-		return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) );
37
-	}
36
+        return sprintf( self::BUTTON_HTML, $element_id, esc_html( $label ) );
37
+    }
38 38
 
39
-	/**
40
-	 * Echo the button HTML.
41
-	 *
42
-	 * @since 3.2.0
43
-	 *
44
-	 * @param string $element_id The button element id.
45
-	 * @param string $label The button (translated) label.
46
-	 *
47
-	 * @return string The button HTML code.
48
-	 */
49
-	public function print_button( $element_id, $label ) {
39
+    /**
40
+     * Echo the button HTML.
41
+     *
42
+     * @since 3.2.0
43
+     *
44
+     * @param string $element_id The button element id.
45
+     * @param string $label The button (translated) label.
46
+     *
47
+     * @return string The button HTML code.
48
+     */
49
+    public function print_button( $element_id, $label ) {
50 50
 
51
-		echo( $this->get_button_html( $element_id, $label ) );
51
+        echo( $this->get_button_html( $element_id, $label ) );
52 52
 
53
-	}
53
+    }
54 54
 
55
-	/**
56
-	 * Get the HTML code for a template tag.
57
-	 *
58
-	 * @since 3.2.0
59
-	 *
60
-	 * @param string $element_id The element id.
61
-	 * @param string $body The element content.
62
-	 *
63
-	 * @return string The HTML code.
64
-	 */
65
-	public function get_template_html( $element_id, $body ) {
55
+    /**
56
+     * Get the HTML code for a template tag.
57
+     *
58
+     * @since 3.2.0
59
+     *
60
+     * @param string $element_id The element id.
61
+     * @param string $body The element content.
62
+     *
63
+     * @return string The HTML code.
64
+     */
65
+    public function get_template_html( $element_id, $body ) {
66 66
 
67
-		return sprintf( self::TEMPLATE_HTML, $element_id, $body );
68
-	}
67
+        return sprintf( self::TEMPLATE_HTML, $element_id, $body );
68
+    }
69 69
 
70
-	/**
71
-	 * Echo the HTML code for a template tag.
72
-	 *
73
-	 * @since 3.2.0
74
-	 *
75
-	 * @param string $element_id The element id.
76
-	 * @param string $body The element content.
77
-	 *
78
-	 * @return string The HTML code.
79
-	 */
80
-	public function print_template( $element_id, $body ) {
70
+    /**
71
+     * Echo the HTML code for a template tag.
72
+     *
73
+     * @since 3.2.0
74
+     *
75
+     * @param string $element_id The element id.
76
+     * @param string $body The element content.
77
+     *
78
+     * @return string The HTML code.
79
+     */
80
+    public function print_template( $element_id, $body ) {
81 81
 
82
-		echo( $this->get_template_html( $element_id, $body ) );
82
+        echo( $this->get_template_html( $element_id, $body ) );
83 83
 
84
-	}
84
+    }
85 85
 
86 86
 }
Please login to merge, or discard this patch.
src/admin/WL_Metabox/WL_Metabox_Field_coordinates.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -3,51 +3,51 @@  discard block
 block discarded – undo
3 3
 
4 4
 class WL_Metabox_Field_coordinates extends WL_Metabox_Field {
5 5
 
6
-	public function __construct( $args ) {
6
+    public function __construct( $args ) {
7 7
 
8
-		// Just set up the necessary info without calling the parent constructor.
9
-		// TODO: write a parent class for grouped properties
8
+        // Just set up the necessary info without calling the parent constructor.
9
+        // TODO: write a parent class for grouped properties
10 10
 
11
-		// we use 'coordinates' to namespace the Field in $_POST data.
12
-		// In  the DB the correct meta names will be used.
13
-		$this->meta_name = 'coordinates';
14
-	}
11
+        // we use 'coordinates' to namespace the Field in $_POST data.
12
+        // In  the DB the correct meta names will be used.
13
+        $this->meta_name = 'coordinates';
14
+    }
15 15
 
16
-	public function get_data() {
17
-		$entity_id  = get_the_ID();
18
-		$this->data = wl_get_coordinates( $entity_id );
19
-	}
16
+    public function get_data() {
17
+        $entity_id  = get_the_ID();
18
+        $this->data = wl_get_coordinates( $entity_id );
19
+    }
20 20
 
21
-	public function html() {
21
+    public function html() {
22 22
 
23
-		// Open main <div> for the Field
24
-		$html = $this->html_wrapper_open();
23
+        // Open main <div> for the Field
24
+        $html = $this->html_wrapper_open();
25 25
 
26
-		// Label
27
-		$html .= '<h3>coordinates</h3>';
26
+        // Label
27
+        $html .= '<h3>coordinates</h3>';
28 28
 
29
-		// print nonce
30
-		$html .= $this->html_nonce();
29
+        // print nonce
30
+        $html .= $this->html_nonce();
31 31
 
32
-		// Get coordinates
33
-		$data        = $this->data;
34
-		// TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we
35
-		// want to use the current user location for the marker.
36
-		$coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' );
37
-		$map_init    = '[0,0]' === $coordinates
38
-			? 'locate( {setView: true, maxZoom: 16} )'
39
-			: sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] );
32
+        // Get coordinates
33
+        $data        = $this->data;
34
+        // TODO: We temporary use here 0,0 as default coordinates for the marker, but if no coordinates are given we
35
+        // want to use the current user location for the marker.
36
+        $coordinates = ( ! empty( $data['latitude'] ) && ! empty( $data['longitude'] ) ? sprintf( '[%f,%f]', $data['latitude'], $data['longitude'] ) : '[0,0]' );
37
+        $map_init    = '[0,0]' === $coordinates
38
+            ? 'locate( {setView: true, maxZoom: 16} )'
39
+            : sprintf( "setView( [%f,%f], 9 )", $data['latitude'], $data['longitude'] );
40 40
 
41
-		// Print input fields
42
-		$html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>';
43
-		$html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />';
41
+        // Print input fields
42
+        $html .= '<label for="wl_place_lat">' . __( 'Latitude', 'wordlift' ) . '</label>';
43
+        $html .= '<input type="text" id="wl_place_lat" name="wl_metaboxes[coordinates][]" value="' . $data['latitude'] . '" style="width:100%" />';
44 44
 
45
-		$html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>';
46
-		$html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />';
45
+        $html .= '<label for="wl_place_lon">' . __( 'Longitude', 'wordlift' ) . '</label>';
46
+        $html .= '<input type="text" id="wl_place_lon" name="wl_metaboxes[coordinates][]" value="' . $data['longitude'] . '" style="width:100%" />';
47 47
 
48
-		// Show Leaflet map to pick coordinates
49
-		$element_id = uniqid( 'wl-gep-map-' );
50
-		$html .= <<<EOF
48
+        // Show Leaflet map to pick coordinates
49
+        $element_id = uniqid( 'wl-gep-map-' );
50
+        $html .= <<<EOF
51 51
 
52 52
 <div id="$element_id"></div>
53 53
 
@@ -79,44 +79,44 @@  discard block
 block discarded – undo
79 79
 EOF;
80 80
 
81 81
 
82
-		$html .= $this->html_wrapper_close();
82
+        $html .= $this->html_wrapper_close();
83 83
 
84
-		return $html;
85
-	}
84
+        return $html;
85
+    }
86 86
 
87
-	public function save_data( $coords ) {
87
+    public function save_data( $coords ) {
88 88
 
89
-		$this->sanitize_data( $coords );
89
+        $this->sanitize_data( $coords );
90 90
 
91
-		$entity_id = get_the_ID();
91
+        $entity_id = get_the_ID();
92 92
 
93
-		// Take away old values
94
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE );
95
-		delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE );
93
+        // Take away old values
94
+        delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE );
95
+        delete_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE );
96 96
 
97
-		$latitude  = $this->data[0];
98
-		$longitude = $this->data[1];
97
+        $latitude  = $this->data[0];
98
+        $longitude = $this->data[1];
99 99
 
100
-		// insert new coordinate values
101
-		if ( ! empty( $latitude ) && ! empty( $longitude ) ) {
102
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true );
103
-			add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true );
104
-		}
100
+        // insert new coordinate values
101
+        if ( ! empty( $latitude ) && ! empty( $longitude ) ) {
102
+            add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LATITUDE, $latitude, true );
103
+            add_post_meta( $entity_id, Wordlift_Schema_Service::FIELD_GEO_LONGITUDE, $longitude, true );
104
+        }
105 105
 
106
-	}
106
+    }
107 107
 
108
-	/**
109
-	 * Only accept float numbers
110
-	 */
111
-	public function sanitize_data_filter( $value ) {
108
+    /**
109
+     * Only accept float numbers
110
+     */
111
+    public function sanitize_data_filter( $value ) {
112 112
 
113
-		// DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
114
-		// "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
115
-		if ( ! is_numeric( $value ) ) {
116
-			return '';
117
-		}
113
+        // DO NOT set latitude/longitude to 0/0 as default values. It's a specific place on the globe:
114
+        // "The zero/zero point of this system is located in the Gulf of Guinea about 625 km (390 mi) south of Tema, Ghana."
115
+        if ( ! is_numeric( $value ) ) {
116
+            return '';
117
+        }
118 118
 
119
-		return $value;
120
-	}
119
+        return $value;
120
+    }
121 121
 }
122 122
 
Please login to merge, or discard this patch.
src/admin/class-wordlift-primashop-adapter.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,33 +7,33 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_PrimaShop_Adapter {
9 9
 
10
-	/**
11
-	 * Create a Wordlift_PrimaShop_Adapter instance.
12
-	 *
13
-	 * @since 3.2.3
14
-	 */
15
-	public function __construct() {
10
+    /**
11
+     * Create a Wordlift_PrimaShop_Adapter instance.
12
+     *
13
+     * @since 3.2.3
14
+     */
15
+    public function __construct() {
16 16
 
17
-		// Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings
18
-		// in the entity edit page.
19
-		add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' );
17
+        // Tell WP (and PrimaShop) that we support the *prima-layout-settings*. This will display the Content Settings
18
+        // in the entity edit page.
19
+        add_post_type_support( Wordlift_Entity_Service::TYPE_NAME, 'prima-layout-settings' );
20 20
 
21
-	}
21
+    }
22 22
 
23
-	/**
24
-	 * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em>
25
-	 * would have returned.
26
-	 *
27
-	 * @since 3.2.3
28
-	 *
29
-	 * @param array $meta The meta array.
30
-	 * @param string $ype The post type.
31
-	 *
32
-	 * @return array A meta array.
33
-	 */
34
-	function prima_metabox_entity_header_args( $meta, $ype ) {
23
+    /**
24
+     * Intercept the <em>prima_metabox_entity_header_args</em> filter and return what a call to the related <em>post</em>
25
+     * would have returned.
26
+     *
27
+     * @since 3.2.3
28
+     *
29
+     * @param array $meta The meta array.
30
+     * @param string $ype The post type.
31
+     *
32
+     * @return array A meta array.
33
+     */
34
+    function prima_metabox_entity_header_args( $meta, $ype ) {
35 35
 
36
-		return apply_filters( "prima_metabox_post_header_args", $meta, 'post' );
37
-	}
36
+        return apply_filters( "prima_metabox_post_header_args", $meta, 'post' );
37
+    }
38 38
 
39 39
 }
Please login to merge, or discard this patch.
src/admin/class-wordlift-notice-service.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -7,180 +7,180 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Notice_Service {
9 9
 
10
-	/**
11
-	 * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible
12
-	 * on the WordPress UI (via a small X button on the right side of the notice).
13
-	 *
14
-	 * @since 3.2.0
15
-	 */
16
-	const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>';
17
-
18
-	/**
19
-	 * The standard WordPress <em>update</em> style class.
20
-	 *
21
-	 * @since 3.2.0
22
-	 */
23
-	const UPDATE = 'update';
24
-
25
-	/**
26
-	 * The standard WordPress <em>update-nag</em> style class.
27
-	 *
28
-	 * @since 3.2.0
29
-	 */
30
-	const UPDATE_NAG = 'update-nag';
31
-
32
-	/**
33
-	 * The standard WordPress <em>error</em> style class.
34
-	 *
35
-	 * @since 3.2.0
36
-	 */
37
-	const ERROR = 'error';
38
-
39
-	/**
40
-	 * A custom WordLift css style class used for WordLift suggestions.
41
-	 *
42
-	 * @since 3.3.0
43
-	 */
44
-	const SUGGESTION = 'wl-suggestion';
45
-
46
-	/**
47
-	 * The array of notices.
48
-	 *
49
-	 * @since 3.2.0
50
-	 * @access private
51
-	 * @var array $notices The array of notices.
52
-	 */
53
-	private $notices = array();
54
-
55
-	/**
56
-	 * A singleton instance of the Notice service.
57
-	 *
58
-	 * @since 3.2.0
59
-	 * @access private
60
-	 * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service.
61
-	 */
62
-	private static $instance;
63
-
64
-	/**
65
-	 * Create an instance of the Notice service.
66
-	 *
67
-	 * @since 3.2.0
68
-	 */
69
-	public function __construct() {
70
-
71
-		// Hook to be called when to display notices.
72
-		add_action( 'admin_notices', array( $this, 'admin_notices' ) );
73
-
74
-		self::$instance = $this;
75
-
76
-	}
77
-
78
-	/**
79
-	 * Get the singleton instance of the Notice service.
80
-	 *
81
-	 * @since 3.2.0
82
-	 * @return \Wordlift_Notice_Service The singleton instance of the Notice service.
83
-	 */
84
-	public static function get_instance() {
85
-
86
-		return self::$instance;
87
-	}
88
-
89
-	/**
90
-	 * Add a notice.
91
-	 *
92
-	 * @since 3.2.0
93
-	 *
94
-	 * @param string $class The css class.
95
-	 * @param string $message The message.
96
-	 */
97
-	public function add( $class, $message ) {
98
-
99
-		$this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) );
100
-
101
-	}
102
-
103
-	/**
104
-	 * Add an update notice (message with a white background and a green left border).
105
-	 *
106
-	 * @since 3.2.0
107
-	 *
108
-	 * @param string $message The message to display.
109
-	 */
110
-	public function add_update( $message ) {
111
-
112
-		$this->add( self::UPDATE, $message );
113
-
114
-	}
115
-
116
-	/**
117
-	 * Add an update nag notice (message with a white background and a yellow left border).
118
-	 *
119
-	 * @since 3.2.0
120
-	 *
121
-	 * @param string $message The message to display.
122
-	 */
123
-	public function add_update_nag( $message ) {
124
-
125
-		$this->add( self::UPDATE_NAG, $message );
126
-
127
-	}
128
-
129
-	/**
130
-	 * Add an error notice (message with a white background and a red left border).
131
-	 *
132
-	 * @since 3.2.0
133
-	 *
134
-	 * @param string $message The message to display.
135
-	 */
136
-	public function add_error( $message ) {
137
-
138
-		$this->add( self::ERROR, $message );
139
-
140
-	}
141
-
142
-	/**
143
-	 * Add a suggestion notice (message with a white background and a WordLift brand colored left border).
144
-	 *
145
-	 * @since 3.3.0
146
-	 *
147
-	 * @param string $message The message to display.
148
-	 */
149
-	public function add_suggestion( $message ) {
150
-
151
-		$this->add( self::SUGGESTION, $message );
152
-
153
-	}
154
-
155
-	/**
156
-	 * Print out the notices when the admin_notices action is called.
157
-	 *
158
-	 * @since 3.2.0
159
-	 */
160
-	public function admin_notices() {
161
-
162
-		foreach ( $this->notices as $notice ) {
163
-			echo( $notice );
164
-		}
165
-
166
-	}
167
-
168
-	/**
169
-	 * Transform message depending on message type. Return a string
170
-	 *
171
-	 * @since 3.3.0
172
-	 *
173
-	 * @param string $message The message.
174
-	 */
175
-	private function transform( $message ) {
176
-
177
-		switch (  gettype( $message ) ) {
178
-			case 'array':
179
-				return implode( $message, '<br />' );
180
-			default:
181
-       			return $message;
182
-		}
183
-
184
-	}
10
+    /**
11
+     * The template used to display notices. The <em>notice dismissible</em> style classes make this notice dismissible
12
+     * on the WordPress UI (via a small X button on the right side of the notice).
13
+     *
14
+     * @since 3.2.0
15
+     */
16
+    const TEMPLATE = '<div class="wl-notice notice is-dismissible %s"><p>%s</p></div>';
17
+
18
+    /**
19
+     * The standard WordPress <em>update</em> style class.
20
+     *
21
+     * @since 3.2.0
22
+     */
23
+    const UPDATE = 'update';
24
+
25
+    /**
26
+     * The standard WordPress <em>update-nag</em> style class.
27
+     *
28
+     * @since 3.2.0
29
+     */
30
+    const UPDATE_NAG = 'update-nag';
31
+
32
+    /**
33
+     * The standard WordPress <em>error</em> style class.
34
+     *
35
+     * @since 3.2.0
36
+     */
37
+    const ERROR = 'error';
38
+
39
+    /**
40
+     * A custom WordLift css style class used for WordLift suggestions.
41
+     *
42
+     * @since 3.3.0
43
+     */
44
+    const SUGGESTION = 'wl-suggestion';
45
+
46
+    /**
47
+     * The array of notices.
48
+     *
49
+     * @since 3.2.0
50
+     * @access private
51
+     * @var array $notices The array of notices.
52
+     */
53
+    private $notices = array();
54
+
55
+    /**
56
+     * A singleton instance of the Notice service.
57
+     *
58
+     * @since 3.2.0
59
+     * @access private
60
+     * @var \Wordlift_Notice_Service $instance A singleton instance of the Notice service.
61
+     */
62
+    private static $instance;
63
+
64
+    /**
65
+     * Create an instance of the Notice service.
66
+     *
67
+     * @since 3.2.0
68
+     */
69
+    public function __construct() {
70
+
71
+        // Hook to be called when to display notices.
72
+        add_action( 'admin_notices', array( $this, 'admin_notices' ) );
73
+
74
+        self::$instance = $this;
75
+
76
+    }
77
+
78
+    /**
79
+     * Get the singleton instance of the Notice service.
80
+     *
81
+     * @since 3.2.0
82
+     * @return \Wordlift_Notice_Service The singleton instance of the Notice service.
83
+     */
84
+    public static function get_instance() {
85
+
86
+        return self::$instance;
87
+    }
88
+
89
+    /**
90
+     * Add a notice.
91
+     *
92
+     * @since 3.2.0
93
+     *
94
+     * @param string $class The css class.
95
+     * @param string $message The message.
96
+     */
97
+    public function add( $class, $message ) {
98
+
99
+        $this->notices[] = sprintf( self::TEMPLATE, $class, $this->transform( $message ) );
100
+
101
+    }
102
+
103
+    /**
104
+     * Add an update notice (message with a white background and a green left border).
105
+     *
106
+     * @since 3.2.0
107
+     *
108
+     * @param string $message The message to display.
109
+     */
110
+    public function add_update( $message ) {
111
+
112
+        $this->add( self::UPDATE, $message );
113
+
114
+    }
115
+
116
+    /**
117
+     * Add an update nag notice (message with a white background and a yellow left border).
118
+     *
119
+     * @since 3.2.0
120
+     *
121
+     * @param string $message The message to display.
122
+     */
123
+    public function add_update_nag( $message ) {
124
+
125
+        $this->add( self::UPDATE_NAG, $message );
126
+
127
+    }
128
+
129
+    /**
130
+     * Add an error notice (message with a white background and a red left border).
131
+     *
132
+     * @since 3.2.0
133
+     *
134
+     * @param string $message The message to display.
135
+     */
136
+    public function add_error( $message ) {
137
+
138
+        $this->add( self::ERROR, $message );
139
+
140
+    }
141
+
142
+    /**
143
+     * Add a suggestion notice (message with a white background and a WordLift brand colored left border).
144
+     *
145
+     * @since 3.3.0
146
+     *
147
+     * @param string $message The message to display.
148
+     */
149
+    public function add_suggestion( $message ) {
150
+
151
+        $this->add( self::SUGGESTION, $message );
152
+
153
+    }
154
+
155
+    /**
156
+     * Print out the notices when the admin_notices action is called.
157
+     *
158
+     * @since 3.2.0
159
+     */
160
+    public function admin_notices() {
161
+
162
+        foreach ( $this->notices as $notice ) {
163
+            echo( $notice );
164
+        }
165
+
166
+    }
167
+
168
+    /**
169
+     * Transform message depending on message type. Return a string
170
+     *
171
+     * @since 3.3.0
172
+     *
173
+     * @param string $message The message.
174
+     */
175
+    private function transform( $message ) {
176
+
177
+        switch (  gettype( $message ) ) {
178
+            case 'array':
179
+                return implode( $message, '<br />' );
180
+            default:
181
+                   return $message;
182
+        }
183
+
184
+    }
185 185
 
186 186
 }
Please login to merge, or discard this patch.
src/public/class-wordlift-shortcode.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -8,50 +8,50 @@
 block discarded – undo
8 8
  */
9 9
 abstract class Wordlift_Shortcode {
10 10
 
11
-	/**
12
-	 * The shortcode, set by extending classes.
13
-	 */
14
-	const SHORTCODE = NULL;
15
-
16
-	/**
17
-	 * Create a shortcode instance by registering the shortcode with the render
18
-	 * function.
19
-	 *
20
-	 * @since 3.5.4
21
-	 */
22
-	public function __construct() {
23
-
24
-		add_shortcode( static::SHORTCODE, array( $this, 'render' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Render the shortcode.
30
-	 *
31
-	 * @since 3.5.4
32
-	 *
33
-	 * @param array $atts An array of shortcode attributes as set by the editor.
34
-	 *
35
-	 * @return string The output html code.
36
-	 */
37
-	public abstract function render( $atts );
38
-
39
-	/**
40
-	 * Enqueue scripts. Called by the shortcode implementations in their render
41
-	 * method.
42
-	 *
43
-	 * @since 3.5.4
44
-	 */
45
-	protected function enqueue_scripts() {
46
-
47
-		wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
48
-		wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) );
49
-		wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array(
50
-			'jquery',
51
-			'angularjs',
52
-			'angularjs-touch'
53
-		) );
54
-
55
-	}
11
+    /**
12
+     * The shortcode, set by extending classes.
13
+     */
14
+    const SHORTCODE = NULL;
15
+
16
+    /**
17
+     * Create a shortcode instance by registering the shortcode with the render
18
+     * function.
19
+     *
20
+     * @since 3.5.4
21
+     */
22
+    public function __construct() {
23
+
24
+        add_shortcode( static::SHORTCODE, array( $this, 'render' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Render the shortcode.
30
+     *
31
+     * @since 3.5.4
32
+     *
33
+     * @param array $atts An array of shortcode attributes as set by the editor.
34
+     *
35
+     * @return string The output html code.
36
+     */
37
+    public abstract function render( $atts );
38
+
39
+    /**
40
+     * Enqueue scripts. Called by the shortcode implementations in their render
41
+     * method.
42
+     *
43
+     * @since 3.5.4
44
+     */
45
+    protected function enqueue_scripts() {
46
+
47
+        wp_enqueue_script( 'angularjs', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular.min.js' );
48
+        wp_enqueue_script( 'angularjs-touch', 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.11/angular-touch.min.js', array( 'angularjs' ) );
49
+        wp_enqueue_script( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/js/wordlift-ui' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '.min' : '' ) . '.js', array(
50
+            'jquery',
51
+            'angularjs',
52
+            'angularjs-touch'
53
+        ) );
54
+
55
+    }
56 56
 
57 57
 }
Please login to merge, or discard this patch.
src/public/class-wordlift-timeline-shortcode.php 1 patch
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -7,198 +7,198 @@
 block discarded – undo
7 7
  */
8 8
 class Wordlift_Timeline_Shortcode extends Wordlift_Shortcode {
9 9
 
10
-	const SHORTCODE = 'wl_timeline';
11
-
12
-	/**
13
-	 * The list of locales supported by TimelineJS (correspond to the list of
14
-	 * files in the locale subfolder).
15
-	 *
16
-	 * @since 3.7.0
17
-	 * @var array An array of two-letters language codes.
18
-	 */
19
-	private static $supported_locales = array(
20
-		'ur',
21
-		'uk',
22
-		'tr',
23
-		'tl',
24
-		'th',
25
-		'te',
26
-		'ta',
27
-		'sv',
28
-		'sr',
29
-		'sl',
30
-		'sk',
31
-		'si',
32
-		'ru',
33
-		'ro',
34
-		'rm',
35
-		'pt',
36
-		'pl',
37
-		'no',
38
-		'nl',
39
-		'ne',
40
-		'ms',
41
-		'lv',
42
-		'lt',
43
-		'lb',
44
-		'ko',
45
-		'ka',
46
-		'ja',
47
-		'iw',
48
-		'it',
49
-		'is',
50
-		'id',
51
-		'hy',
52
-		'hu',
53
-		'hr',
54
-		'hi',
55
-		'he',
56
-		'gl',
57
-		'ga',
58
-		'fy',
59
-		'fr',
60
-		'fo',
61
-		'fi',
62
-		'fa',
63
-		'eu',
64
-		'et',
65
-		'es',
66
-		'eo',
67
-		'en',
68
-		'el',
69
-		'de',
70
-		'da',
71
-		'cz',
72
-		'ca',
73
-		'bg',
74
-		'be',
75
-		'ar',
76
-		'af'
77
-	);
78
-
79
-	/**
80
-	 * The Log service.
81
-	 *
82
-	 * @since 3.1.0
83
-	 * @access private
84
-	 * @var \Wordlift_Log_Service $log_service The Log service.
85
-	 */
86
-	private $log_service;
87
-
88
-	/**
89
-	 * Create a Wordlift_Timeline_Shortcode instance.
90
-	 *
91
-	 * @since 3.1.0
92
-	 */
93
-	public function __construct() {
94
-		parent::__construct();
95
-
96
-		$this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' );
97
-
98
-	}
99
-
100
-	/**
101
-	 * Renders the Timeline.
102
-	 *
103
-	 * @since 3.1.0
104
-	 *
105
-	 * @param array $atts An array of shortcode attributes.
106
-	 *
107
-	 * @return string The rendered HTML.
108
-	 */
109
-	public function render( $atts ) {
110
-
111
-		//extract attributes and set default values
112
-		$settings = shortcode_atts( array(
113
-			'debug'                            => defined( 'WP_DEBUG' ) && WP_DEBUG,
114
-			'height'                           => NULL,
115
-			'width'                            => NULL,
116
-			'is_embed'                         => FALSE,
117
-			'hash_bookmark'                    => FALSE,
118
-			'default_bg_color'                 => 'white',
119
-			'scale_factor'                     => 2,
120
-			'initial_zoom'                     => NULL,
121
-			'zoom_sequence'                    => '[0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]',
122
-			'timenav_position'                 => 'bottom',
123
-			'optimal_tick_width'               => 100,
124
-			'base_class'                       => 'tl-timeline',
125
-			'timenav_height'                   => 150,
126
-			'timenav_height_percentage'        => NULL,
127
-			'timenav_mobile_height_percentage' => 40,
128
-			'timenav_height_min'               => 150,
129
-			'marker_height_min'                => 30,
130
-			'marker_width_min'                 => 100,
131
-			'marker_padding'                   => 5,
132
-			'start_at_slide'                   => 0,
133
-			'start_at_end'                     => FALSE,
134
-			'menubar_height'                   => 0,
135
-			'use_bc'                           => FALSE,
136
-			'duration'                         => 1000,
137
-			'ease'                             => 'TL.Ease.easeInOutQuint',
138
-			'slide_default_fade'               => '0%',
139
-			'language'                         => $this->get_locale(),
140
-			'ga_property_id'                   => NULL,
141
-			'track_events'                     => "['back_to_start','nav_next','nav_previous','zoom_in','zoom_out']",
142
-			'global'                           => FALSE,
143
-			// The following settings are unrelated to TimelineJS script.
144
-			'display_images_as'                => 'media',
145
-			'excerpt_length'                   => 55,
146
-		), $atts );
147
-
148
-		// Load the TimelineJS stylesheets and scripts.
149
-		wp_enqueue_style( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/css/timeline.css' );
150
-		wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/js/timeline' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '-min' : '' ) . '.js' );
151
-
152
-		// Enqueue the scripts for the timeline.
153
-		$this->enqueue_scripts();
154
-
155
-		// Provide the script with options.
156
-		wp_localize_script( 'timelinejs', 'wl_timeline_params', array(
157
-			'ajax_url'          => admin_url( 'admin-ajax.php' ),
158
-			// TODO: this parameter is already provided by WP
159
-			'action'            => 'wl_timeline',
160
-			// These settings apply to our wl_timeline AJAX endpoint.
161
-			'display_images_as' => $settings['display_images_as'],
162
-			'excerpt_length'    => $settings['excerpt_length'],
163
-			// These settings apply to the timeline javascript client.
164
-			'settings'          => array_filter( $settings, function ( $value ) {
165
-				// Do not set NULL values.
166
-				return ( NULL !== $value );
167
-			} )
168
-		) );
169
-
170
-		// Get the current post id or set null if global is set to true.
171
-		$post_id = ( $settings['global'] ? NULL : get_the_ID() );
172
-
173
-		// Escaping atts.
174
-		$style        = sprintf( 'style="%s%s"', isset( $settings['width'] ) ? "width:{$settings['width']};" : '', isset( $settings['height'] ) ? "height:{$settings['height']};" : '' );
175
-		$data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' );
176
-
177
-		// Generate a unique ID for this timeline.
178
-		$element_id = uniqid( 'wl-timeline-' );
179
-
180
-		if ( WP_DEBUG ) {
181
-			$this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" );
182
-		}
183
-
184
-		// Building template.
185
-		return sprintf( '<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id );
186
-	}
187
-
188
-	/**
189
-	 * Return the locale for the TimelineJS according to WP's configured locale and
190
-	 * support TimelineJS locales. If WP's locale is not supported, english is used.
191
-	 *
192
-	 * @since 3.7.0
193
-	 * @return string The locale (2 letters code).
194
-	 */
195
-	private function get_locale() {
196
-
197
-		// Get the first 2 letters.
198
-		$locale = substr( get_locale(), 0, 2 );
199
-
200
-		// Check that the specified locale is supported otherwise use English.
201
-		return in_array( $locale, self::$supported_locales ) ? $locale : 'en';
202
-	}
10
+    const SHORTCODE = 'wl_timeline';
11
+
12
+    /**
13
+     * The list of locales supported by TimelineJS (correspond to the list of
14
+     * files in the locale subfolder).
15
+     *
16
+     * @since 3.7.0
17
+     * @var array An array of two-letters language codes.
18
+     */
19
+    private static $supported_locales = array(
20
+        'ur',
21
+        'uk',
22
+        'tr',
23
+        'tl',
24
+        'th',
25
+        'te',
26
+        'ta',
27
+        'sv',
28
+        'sr',
29
+        'sl',
30
+        'sk',
31
+        'si',
32
+        'ru',
33
+        'ro',
34
+        'rm',
35
+        'pt',
36
+        'pl',
37
+        'no',
38
+        'nl',
39
+        'ne',
40
+        'ms',
41
+        'lv',
42
+        'lt',
43
+        'lb',
44
+        'ko',
45
+        'ka',
46
+        'ja',
47
+        'iw',
48
+        'it',
49
+        'is',
50
+        'id',
51
+        'hy',
52
+        'hu',
53
+        'hr',
54
+        'hi',
55
+        'he',
56
+        'gl',
57
+        'ga',
58
+        'fy',
59
+        'fr',
60
+        'fo',
61
+        'fi',
62
+        'fa',
63
+        'eu',
64
+        'et',
65
+        'es',
66
+        'eo',
67
+        'en',
68
+        'el',
69
+        'de',
70
+        'da',
71
+        'cz',
72
+        'ca',
73
+        'bg',
74
+        'be',
75
+        'ar',
76
+        'af'
77
+    );
78
+
79
+    /**
80
+     * The Log service.
81
+     *
82
+     * @since 3.1.0
83
+     * @access private
84
+     * @var \Wordlift_Log_Service $log_service The Log service.
85
+     */
86
+    private $log_service;
87
+
88
+    /**
89
+     * Create a Wordlift_Timeline_Shortcode instance.
90
+     *
91
+     * @since 3.1.0
92
+     */
93
+    public function __construct() {
94
+        parent::__construct();
95
+
96
+        $this->log_service = Wordlift_Log_Service::get_logger( 'Wordlift_Timeline_Shortcode' );
97
+
98
+    }
99
+
100
+    /**
101
+     * Renders the Timeline.
102
+     *
103
+     * @since 3.1.0
104
+     *
105
+     * @param array $atts An array of shortcode attributes.
106
+     *
107
+     * @return string The rendered HTML.
108
+     */
109
+    public function render( $atts ) {
110
+
111
+        //extract attributes and set default values
112
+        $settings = shortcode_atts( array(
113
+            'debug'                            => defined( 'WP_DEBUG' ) && WP_DEBUG,
114
+            'height'                           => NULL,
115
+            'width'                            => NULL,
116
+            'is_embed'                         => FALSE,
117
+            'hash_bookmark'                    => FALSE,
118
+            'default_bg_color'                 => 'white',
119
+            'scale_factor'                     => 2,
120
+            'initial_zoom'                     => NULL,
121
+            'zoom_sequence'                    => '[0.5, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]',
122
+            'timenav_position'                 => 'bottom',
123
+            'optimal_tick_width'               => 100,
124
+            'base_class'                       => 'tl-timeline',
125
+            'timenav_height'                   => 150,
126
+            'timenav_height_percentage'        => NULL,
127
+            'timenav_mobile_height_percentage' => 40,
128
+            'timenav_height_min'               => 150,
129
+            'marker_height_min'                => 30,
130
+            'marker_width_min'                 => 100,
131
+            'marker_padding'                   => 5,
132
+            'start_at_slide'                   => 0,
133
+            'start_at_end'                     => FALSE,
134
+            'menubar_height'                   => 0,
135
+            'use_bc'                           => FALSE,
136
+            'duration'                         => 1000,
137
+            'ease'                             => 'TL.Ease.easeInOutQuint',
138
+            'slide_default_fade'               => '0%',
139
+            'language'                         => $this->get_locale(),
140
+            'ga_property_id'                   => NULL,
141
+            'track_events'                     => "['back_to_start','nav_next','nav_previous','zoom_in','zoom_out']",
142
+            'global'                           => FALSE,
143
+            // The following settings are unrelated to TimelineJS script.
144
+            'display_images_as'                => 'media',
145
+            'excerpt_length'                   => 55,
146
+        ), $atts );
147
+
148
+        // Load the TimelineJS stylesheets and scripts.
149
+        wp_enqueue_style( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/css/timeline.css' );
150
+        wp_enqueue_script( 'timelinejs', dirname( plugin_dir_url( __FILE__ ) ) . '/timelinejs/js/timeline' . ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ? '-min' : '' ) . '.js' );
151
+
152
+        // Enqueue the scripts for the timeline.
153
+        $this->enqueue_scripts();
154
+
155
+        // Provide the script with options.
156
+        wp_localize_script( 'timelinejs', 'wl_timeline_params', array(
157
+            'ajax_url'          => admin_url( 'admin-ajax.php' ),
158
+            // TODO: this parameter is already provided by WP
159
+            'action'            => 'wl_timeline',
160
+            // These settings apply to our wl_timeline AJAX endpoint.
161
+            'display_images_as' => $settings['display_images_as'],
162
+            'excerpt_length'    => $settings['excerpt_length'],
163
+            // These settings apply to the timeline javascript client.
164
+            'settings'          => array_filter( $settings, function ( $value ) {
165
+                // Do not set NULL values.
166
+                return ( NULL !== $value );
167
+            } )
168
+        ) );
169
+
170
+        // Get the current post id or set null if global is set to true.
171
+        $post_id = ( $settings['global'] ? NULL : get_the_ID() );
172
+
173
+        // Escaping atts.
174
+        $style        = sprintf( 'style="%s%s"', isset( $settings['width'] ) ? "width:{$settings['width']};" : '', isset( $settings['height'] ) ? "height:{$settings['height']};" : '' );
175
+        $data_post_id = ( isset( $post_id ) ? "data-post-id='$post_id'" : '' );
176
+
177
+        // Generate a unique ID for this timeline.
178
+        $element_id = uniqid( 'wl-timeline-' );
179
+
180
+        if ( WP_DEBUG ) {
181
+            $this->log_service->trace( "Creating a timeline widget [ element id :: $element_id ][ post id :: $post_id ]" );
182
+        }
183
+
184
+        // Building template.
185
+        return sprintf( '<div class="wl-timeline-container" %s><div class="wl-timeline" id="%s" %s></div></div>', $style, $element_id, $data_post_id );
186
+    }
187
+
188
+    /**
189
+     * Return the locale for the TimelineJS according to WP's configured locale and
190
+     * support TimelineJS locales. If WP's locale is not supported, english is used.
191
+     *
192
+     * @since 3.7.0
193
+     * @return string The locale (2 letters code).
194
+     */
195
+    private function get_locale() {
196
+
197
+        // Get the first 2 letters.
198
+        $locale = substr( get_locale(), 0, 2 );
199
+
200
+        // Check that the specified locale is supported otherwise use English.
201
+        return in_array( $locale, self::$supported_locales ) ? $locale : 'en';
202
+    }
203 203
 
204 204
 }
Please login to merge, or discard this patch.
src/includes/properties/class-wordlift-property-getter.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -9,72 +9,72 @@
 block discarded – undo
9 9
  */
10 10
 class Wordlift_Property_Getter {
11 11
 
12
-	/**
13
-	 * An array of {@link Wordlift_Simple_Property_Service}s which can access a
14
-	 * property.
15
-	 *
16
-	 * @since 3.8.0
17
-	 * @access private
18
-	 * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s.
19
-	 */
20
-	private $services = array();
12
+    /**
13
+     * An array of {@link Wordlift_Simple_Property_Service}s which can access a
14
+     * property.
15
+     *
16
+     * @since 3.8.0
17
+     * @access private
18
+     * @var Wordlift_Simple_Property_Service[] $services An array of {@link Wordlift_Simple_Property_Service}s.
19
+     */
20
+    private $services = array();
21 21
 
22
-	/**
23
-	 * The default {@link Wordlift_Simple_Property_Service} which is used to access
24
-	 * a property when no specific {@link Wordlift_Simple_Property_Service} is found
25
-	 * in the {@see $services} array.
26
-	 * @var Wordlift_Simple_Property_Service
27
-	 */
28
-	private $default;
22
+    /**
23
+     * The default {@link Wordlift_Simple_Property_Service} which is used to access
24
+     * a property when no specific {@link Wordlift_Simple_Property_Service} is found
25
+     * in the {@see $services} array.
26
+     * @var Wordlift_Simple_Property_Service
27
+     */
28
+    private $default;
29 29
 
30
-	/**
31
-	 * Create a property service with the provided {@link Wordlift_Simple_Property_Service}
32
-	 * as default.
33
-	 *
34
-	 * @since 3.8.0
35
-	 *
36
-	 * @param $default
37
-	 */
38
-	public function __construct( $default ) {
30
+    /**
31
+     * Create a property service with the provided {@link Wordlift_Simple_Property_Service}
32
+     * as default.
33
+     *
34
+     * @since 3.8.0
35
+     *
36
+     * @param $default
37
+     */
38
+    public function __construct( $default ) {
39 39
 
40
-		$this->default = $default;
40
+        $this->default = $default;
41 41
 
42
-	}
42
+    }
43 43
 
44
-	/**
45
-	 * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys.
46
-	 *
47
-	 * @since 3.8.0
48
-	 *
49
-	 * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance.
50
-	 * @param array $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle.
51
-	 */
52
-	public function register( $property_service, $meta_keys ) {
44
+    /**
45
+     * Register a {@link Wordlift_Simple_Property_Service} for the specified meta keys.
46
+     *
47
+     * @since 3.8.0
48
+     *
49
+     * @param \Wordlift_Simple_Property_Service $property_service A {@link Wordlift_Simple_Property_Service} instance.
50
+     * @param array $meta_keys An array of meta keys that the provided {@link Wordlift_Simple_Property_Service} will handle.
51
+     */
52
+    public function register( $property_service, $meta_keys ) {
53 53
 
54
-		// Register the specified property service for each meta key.
55
-		foreach ( $meta_keys as $meta_key ) {
56
-			$this->services[ $meta_key ] = $property_service;
57
-		}
54
+        // Register the specified property service for each meta key.
55
+        foreach ( $meta_keys as $meta_key ) {
56
+            $this->services[ $meta_key ] = $property_service;
57
+        }
58 58
 
59
-	}
59
+    }
60 60
 
61
-	/**
62
-	 * Get the value for the specified entity post id and WP's meta key.
63
-	 *
64
-	 * @since 3.8.0
65
-	 *
66
-	 * @param int $post_id The post id.
67
-	 * @param string $meta_key The meta key.
68
-	 *
69
-	 * @return mixed|null The property value or null.
70
-	 */
71
-	public function get( $post_id, $meta_key ) {
61
+    /**
62
+     * Get the value for the specified entity post id and WP's meta key.
63
+     *
64
+     * @since 3.8.0
65
+     *
66
+     * @param int $post_id The post id.
67
+     * @param string $meta_key The meta key.
68
+     *
69
+     * @return mixed|null The property value or null.
70
+     */
71
+    public function get( $post_id, $meta_key ) {
72 72
 
73
-		return isset( $this->services[ $meta_key ] )
74
-			// Use a specific property service.
75
-			? $this->services[ $meta_key ]->get( $post_id, $meta_key )
76
-			// Use the default property service.
77
-			: $this->default->get( $post_id, $meta_key );
78
-	}
73
+        return isset( $this->services[ $meta_key ] )
74
+            // Use a specific property service.
75
+            ? $this->services[ $meta_key ]->get( $post_id, $meta_key )
76
+            // Use the default property service.
77
+            : $this->default->get( $post_id, $meta_key );
78
+    }
79 79
 
80 80
 }
Please login to merge, or discard this patch.