Completed
Push — develop ( 96dbbc...373a0b )
by David
02:47
created
src/admin/class-wordlift-admin.php 2 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -22,133 +22,133 @@
 block discarded – undo
22 22
  */
23 23
 class Wordlift_Admin {
24 24
 
25
-	/**
26
-	 * The ID of this plugin.
27
-	 *
28
-	 * @since    1.0.0
29
-	 * @access   private
30
-	 * @var      string $plugin_name The ID of this plugin.
31
-	 */
32
-	private $plugin_name;
33
-
34
-	/**
35
-	 * The version of this plugin.
36
-	 *
37
-	 * @since    1.0.0
38
-	 * @access   private
39
-	 * @var      string $version The current version of this plugin.
40
-	 */
41
-	private $version;
42
-
43
-	/**
44
-	 * Initialize the class and set its properties.
45
-	 *
46
-	 * @since    1.0.0
47
-	 *
48
-	 * @param   string                           $plugin_name           The name of this plugin.
49
-	 * @param   string                           $version               The version of this plugin.
50
-	 * @param    \Wordlift_Configuration_Service $configuration_service The configuration service.
51
-	 * @param    \Wordlift_Notice_Service        $notice_service        The notice service.
52
-	 */
53
-	public function __construct( $plugin_name, $version, $configuration_service, $notice_service ) {
54
-
55
-		$this->plugin_name = $plugin_name;
56
-		$this->version     = $version;
57
-
58
-		$dataset_uri = $configuration_service->get_dataset_uri();
59
-		$key         = $configuration_service->get_key();
60
-
61
-		if ( empty( $dataset_uri ) ) {
62
-			if ( empty( $key ) ) {
63
-				$error = __( 'WordLift\'s key is unset: WordLift requires a key.', 'wordlift' );
64
-			} else {
65
-				$error = __( 'WordLift\'s dataset URI is unset: please retry WordLift\'s configuration.', 'wordlift' );
66
-			}
67
-			$notice_service->add_error( $error );
68
-		}
69
-
70
-	}
71
-
72
-	/**
73
-	 * Register the stylesheets for the admin area.
74
-	 *
75
-	 * @since    1.0.0
76
-	 */
77
-	public function enqueue_styles() {
78
-
79
-		/**
80
-		 * This function is provided for demonstration purposes only.
81
-		 *
82
-		 * An instance of this class should be passed to the run() function
83
-		 * defined in Wordlift_Loader as all of the hooks are defined
84
-		 * in that particular class.
85
-		 *
86
-		 * The Wordlift_Loader will then create the relationship
87
-		 * between the defined hooks and the functions defined in this
88
-		 * class.
89
-		 */
90
-
91
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' );
92
-
93
-	}
94
-
95
-	/**
96
-	 * Register the JavaScript for the admin area.
97
-	 *
98
-	 * @since    1.0.0
99
-	 */
100
-	public function enqueue_scripts() {
101
-
102
-		/**
103
-		 * This function is provided for demonstration purposes only.
104
-		 *
105
-		 * An instance of this class should be passed to the run() function
106
-		 * defined in Wordlift_Loader as all of the hooks are defined
107
-		 * in that particular class.
108
-		 *
109
-		 * The Wordlift_Loader will then create the relationship
110
-		 * between the defined hooks and the functions defined in this
111
-		 * class.
112
-		 */
113
-
114
-		// Enqueue the admin scripts.
115
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array(
116
-			'jquery',
117
-			'underscore',
118
-			'backbone',
119
-		), $this->version, false );
120
-
121
-		// Set the basic params.
122
-		$params = array(
123
-			// @todo scripts in admin should use wp.post.
124
-			'ajax_url'   => admin_url( 'admin-ajax.php' ),
125
-			// @todo remove specific actions from settings.
126
-			'action'     => 'entity_by_title',
127
-			'datasetUri' => Wordlift_Configuration_Service::get_instance()->get_dataset_uri(),
128
-			'language'   => Wordlift_Configuration_Service::get_instance()->get_language_code(),
129
-			'l10n'       => array(
130
-				'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ),
131
-				'logo_selection_title'                               => __( 'WordLift Choose Logo', 'wordlift' ),
132
-				'logo_selection_button'                              => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
133
-			),
134
-		);
135
-
136
-		// Set post-related values if there's a current post.
137
-		if ( null !== $post = $entity_being_edited = get_post() ) {
138
-
139
-			$params['post_id']           = $entity_being_edited->ID;
140
-			$params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && Wordlift_Entity_Service::TYPE_NAME == $entity_being_edited->post_type && is_numeric( get_the_ID() );
141
-			// We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it
142
-			// from the results, since we don't want the current entity to be discovered by the analysis.
143
-			//
144
-			// See https://github.com/insideout10/wordlift-plugin/issues/345
145
-			$params['itemId'] = Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID );
146
-
147
-		}
148
-
149
-		// Finally output the params as `wlSettings` for JavaScript code.
150
-		wp_localize_script( $this->plugin_name, 'wlSettings', $params );
151
-
152
-	}
25
+    /**
26
+     * The ID of this plugin.
27
+     *
28
+     * @since    1.0.0
29
+     * @access   private
30
+     * @var      string $plugin_name The ID of this plugin.
31
+     */
32
+    private $plugin_name;
33
+
34
+    /**
35
+     * The version of this plugin.
36
+     *
37
+     * @since    1.0.0
38
+     * @access   private
39
+     * @var      string $version The current version of this plugin.
40
+     */
41
+    private $version;
42
+
43
+    /**
44
+     * Initialize the class and set its properties.
45
+     *
46
+     * @since    1.0.0
47
+     *
48
+     * @param   string                           $plugin_name           The name of this plugin.
49
+     * @param   string                           $version               The version of this plugin.
50
+     * @param    \Wordlift_Configuration_Service $configuration_service The configuration service.
51
+     * @param    \Wordlift_Notice_Service        $notice_service        The notice service.
52
+     */
53
+    public function __construct( $plugin_name, $version, $configuration_service, $notice_service ) {
54
+
55
+        $this->plugin_name = $plugin_name;
56
+        $this->version     = $version;
57
+
58
+        $dataset_uri = $configuration_service->get_dataset_uri();
59
+        $key         = $configuration_service->get_key();
60
+
61
+        if ( empty( $dataset_uri ) ) {
62
+            if ( empty( $key ) ) {
63
+                $error = __( 'WordLift\'s key is unset: WordLift requires a key.', 'wordlift' );
64
+            } else {
65
+                $error = __( 'WordLift\'s dataset URI is unset: please retry WordLift\'s configuration.', 'wordlift' );
66
+            }
67
+            $notice_service->add_error( $error );
68
+        }
69
+
70
+    }
71
+
72
+    /**
73
+     * Register the stylesheets for the admin area.
74
+     *
75
+     * @since    1.0.0
76
+     */
77
+    public function enqueue_styles() {
78
+
79
+        /**
80
+         * This function is provided for demonstration purposes only.
81
+         *
82
+         * An instance of this class should be passed to the run() function
83
+         * defined in Wordlift_Loader as all of the hooks are defined
84
+         * in that particular class.
85
+         *
86
+         * The Wordlift_Loader will then create the relationship
87
+         * between the defined hooks and the functions defined in this
88
+         * class.
89
+         */
90
+
91
+        wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' );
92
+
93
+    }
94
+
95
+    /**
96
+     * Register the JavaScript for the admin area.
97
+     *
98
+     * @since    1.0.0
99
+     */
100
+    public function enqueue_scripts() {
101
+
102
+        /**
103
+         * This function is provided for demonstration purposes only.
104
+         *
105
+         * An instance of this class should be passed to the run() function
106
+         * defined in Wordlift_Loader as all of the hooks are defined
107
+         * in that particular class.
108
+         *
109
+         * The Wordlift_Loader will then create the relationship
110
+         * between the defined hooks and the functions defined in this
111
+         * class.
112
+         */
113
+
114
+        // Enqueue the admin scripts.
115
+        wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array(
116
+            'jquery',
117
+            'underscore',
118
+            'backbone',
119
+        ), $this->version, false );
120
+
121
+        // Set the basic params.
122
+        $params = array(
123
+            // @todo scripts in admin should use wp.post.
124
+            'ajax_url'   => admin_url( 'admin-ajax.php' ),
125
+            // @todo remove specific actions from settings.
126
+            'action'     => 'entity_by_title',
127
+            'datasetUri' => Wordlift_Configuration_Service::get_instance()->get_dataset_uri(),
128
+            'language'   => Wordlift_Configuration_Service::get_instance()->get_language_code(),
129
+            'l10n'       => array(
130
+                'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ),
131
+                'logo_selection_title'                               => __( 'WordLift Choose Logo', 'wordlift' ),
132
+                'logo_selection_button'                              => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
133
+            ),
134
+        );
135
+
136
+        // Set post-related values if there's a current post.
137
+        if ( null !== $post = $entity_being_edited = get_post() ) {
138
+
139
+            $params['post_id']           = $entity_being_edited->ID;
140
+            $params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && Wordlift_Entity_Service::TYPE_NAME == $entity_being_edited->post_type && is_numeric( get_the_ID() );
141
+            // We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it
142
+            // from the results, since we don't want the current entity to be discovered by the analysis.
143
+            //
144
+            // See https://github.com/insideout10/wordlift-plugin/issues/345
145
+            $params['itemId'] = Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID );
146
+
147
+        }
148
+
149
+        // Finally output the params as `wlSettings` for JavaScript code.
150
+        wp_localize_script( $this->plugin_name, 'wlSettings', $params );
151
+
152
+    }
153 153
 
154 154
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param    \Wordlift_Configuration_Service $configuration_service The configuration service.
51 51
 	 * @param    \Wordlift_Notice_Service        $notice_service        The notice service.
52 52
 	 */
53
-	public function __construct( $plugin_name, $version, $configuration_service, $notice_service ) {
53
+	public function __construct($plugin_name, $version, $configuration_service, $notice_service) {
54 54
 
55 55
 		$this->plugin_name = $plugin_name;
56 56
 		$this->version     = $version;
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 		$dataset_uri = $configuration_service->get_dataset_uri();
59 59
 		$key         = $configuration_service->get_key();
60 60
 
61
-		if ( empty( $dataset_uri ) ) {
62
-			if ( empty( $key ) ) {
63
-				$error = __( 'WordLift\'s key is unset: WordLift requires a key.', 'wordlift' );
61
+		if (empty($dataset_uri)) {
62
+			if (empty($key)) {
63
+				$error = __('WordLift\'s key is unset: WordLift requires a key.', 'wordlift');
64 64
 			} else {
65
-				$error = __( 'WordLift\'s dataset URI is unset: please retry WordLift\'s configuration.', 'wordlift' );
65
+				$error = __('WordLift\'s dataset URI is unset: please retry WordLift\'s configuration.', 'wordlift');
66 66
 			}
67
-			$notice_service->add_error( $error );
67
+			$notice_service->add_error($error);
68 68
 		}
69 69
 
70 70
 	}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * class.
89 89
 		 */
90 90
 
91
-		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wordlift-admin.css', array(), $this->version, 'all' );
91
+		wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__).'css/wordlift-admin.css', array(), $this->version, 'all');
92 92
 
93 93
 	}
94 94
 
@@ -112,42 +112,42 @@  discard block
 block discarded – undo
112 112
 		 */
113 113
 
114 114
 		// Enqueue the admin scripts.
115
-		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wordlift-admin.bundle.js', array(
115
+		wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__).'js/wordlift-admin.bundle.js', array(
116 116
 			'jquery',
117 117
 			'underscore',
118 118
 			'backbone',
119
-		), $this->version, false );
119
+		), $this->version, false);
120 120
 
121 121
 		// Set the basic params.
122 122
 		$params = array(
123 123
 			// @todo scripts in admin should use wp.post.
124
-			'ajax_url'   => admin_url( 'admin-ajax.php' ),
124
+			'ajax_url'   => admin_url('admin-ajax.php'),
125 125
 			// @todo remove specific actions from settings.
126 126
 			'action'     => 'entity_by_title',
127 127
 			'datasetUri' => Wordlift_Configuration_Service::get_instance()->get_dataset_uri(),
128 128
 			'language'   => Wordlift_Configuration_Service::get_instance()->get_language_code(),
129 129
 			'l10n'       => array(
130
-				'You already published an entity with the same name' => __( 'You already published an entity with the same name: ', 'wordlift' ),
131
-				'logo_selection_title'                               => __( 'WordLift Choose Logo', 'wordlift' ),
132
-				'logo_selection_button'                              => array( 'text' => __( 'Choose Logo', 'wordlift' ) ),
130
+				'You already published an entity with the same name' => __('You already published an entity with the same name: ', 'wordlift'),
131
+				'logo_selection_title'                               => __('WordLift Choose Logo', 'wordlift'),
132
+				'logo_selection_button'                              => array('text' => __('Choose Logo', 'wordlift')),
133 133
 			),
134 134
 		);
135 135
 
136 136
 		// Set post-related values if there's a current post.
137
-		if ( null !== $post = $entity_being_edited = get_post() ) {
137
+		if (null !== $post = $entity_being_edited = get_post()) {
138 138
 
139 139
 			$params['post_id']           = $entity_being_edited->ID;
140
-			$params['entityBeingEdited'] = isset( $entity_being_edited->post_type ) && Wordlift_Entity_Service::TYPE_NAME == $entity_being_edited->post_type && is_numeric( get_the_ID() );
140
+			$params['entityBeingEdited'] = isset($entity_being_edited->post_type) && Wordlift_Entity_Service::TYPE_NAME == $entity_being_edited->post_type && is_numeric(get_the_ID());
141 141
 			// We add the `itemId` here to give a chance to the analysis to use it in order to tell WLS to exclude it
142 142
 			// from the results, since we don't want the current entity to be discovered by the analysis.
143 143
 			//
144 144
 			// See https://github.com/insideout10/wordlift-plugin/issues/345
145
-			$params['itemId'] = Wordlift_Entity_Service::get_instance()->get_uri( $entity_being_edited->ID );
145
+			$params['itemId'] = Wordlift_Entity_Service::get_instance()->get_uri($entity_being_edited->ID);
146 146
 
147 147
 		}
148 148
 
149 149
 		// Finally output the params as `wlSettings` for JavaScript code.
150
-		wp_localize_script( $this->plugin_name, 'wlSettings', $params );
150
+		wp_localize_script($this->plugin_name, 'wlSettings', $params);
151 151
 
152 152
 	}
153 153
 
Please login to merge, or discard this patch.