Skip to content

Commit ff50027

Browse files
authored
Merge pull request #107 from Codeinwp/development
Release 1.7.0
2 parents 1cf41d6 + 534092a commit ff50027

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2929
-1381
lines changed

.distignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.git
2+
.distignore
3+
.gitignore
4+
.travis.yml
5+
.jshintrc
6+
Gruntfile.js
7+
grunt
8+
phpcs.xml
9+
node_modules
10+
logs
11+
package.json
12+
npm-debug.log

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
node_modules
3+
logs
4+

.jshintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"boss": true,
3+
"curly": true,
4+
"eqeqeq": true,
5+
"eqnull": true,
6+
"expr": true,
7+
"immed": true,
8+
"noarg": true,
9+
"nonbsp": true,
10+
"onevar": true,
11+
"trailing": true,
12+
"undef": true,
13+
"sub":true,
14+
"unused": false,
15+
"browser": true,
16+
"globals": {
17+
"_": false,
18+
"Backbone": false,
19+
"jQuery": false,
20+
"JSON": false,
21+
"wp": false
22+
}
23+
}

.travis.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
language: php
2+
3+
## PHP versions to test against
4+
php:
5+
- "7.0"
6+
- "5.6"
7+
- "5.5"
8+
- "5.4"
9+
- "5.3"
10+
- "5.2"
11+
sudo: false
12+
env:
13+
- WP_VERSION=master WP_MULTISITE=0
14+
install:
15+
- . $HOME/.nvm/nvm.sh
16+
- nvm install stable
17+
- nvm use stable
18+
- npm install
19+
- npm install grunt-cli -g
20+
before_script:
21+
## Install the wordpress latest version
22+
- export WP_DEVELOP_DIR=/tmp/wordpress/
23+
- mkdir -p $WP_DEVELOP_DIR
24+
- git clone --depth=1 --branch="$WP_VERSION" git://develop.git.wordpress.org/ $WP_DEVELOP_DIR
25+
- plugin_slug=$(basename $(pwd))
26+
- plugin_dir=$WP_DEVELOP_DIR/src/wp-content/plugins/$plugin_slug
27+
- cd ..
28+
- mv $plugin_slug $plugin_dir
29+
- cd $WP_DEVELOP_DIR
30+
- cp wp-tests-config-sample.php wp-tests-config.php
31+
- sed -i "s/youremptytestdbnamehere/wordpress_test/" wp-tests-config.php
32+
- sed -i "s/yourusernamehere/root/" wp-tests-config.php
33+
- sed -i "s/yourpasswordhere//" wp-tests-config.php
34+
- mysql -e 'CREATE DATABASE wordpress_test;' -uroot
35+
36+
## install PHPCS and Wordpress standards
37+
- pear install pear/PHP_CodeSniffer
38+
- mkdir wordpress-coding-standards && curl -L https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/archive/master.tar.gz | tar xz --strip-components=1 -C wordpress-coding-standards
39+
- phpenv rehash
40+
- phpcs --config-set installed_paths $WP_DEVELOP_DIR/wordpress-coding-standards
41+
- phpenv rehash
42+
- cd $plugin_dir
43+
44+
script:
45+
grunt travis

Gruntfile.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* jshint node:true */
2+
/* global require */
3+
4+
module.exports = function (grunt) {
5+
'use strict';
6+
7+
var loader = require( 'load-project-config' ),
8+
config = require( 'grunt-plugin-fleet' );
9+
loader( grunt, config ).init();
10+
};

classes/Visualizer/Module.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// +----------------------------------------------------------------------+
2020
// | Author: Eugene Manuilov <[email protected]> |
2121
// +----------------------------------------------------------------------+
22-
2322
/**
2423
* Base class for all modules. Implements routine methods required by all modules.
2524
*
@@ -75,11 +74,12 @@ public function __construct( Visualizer_Plugin $plugin ) {
7574
* @access protected
7675
* @param string $tag The name of the action to which the $method is hooked.
7776
* @param string $method The name of the method to be called.
78-
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
79-
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
77+
* @param bool $methodClass The root of the method.
78+
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
79+
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
8080
* @return Visualizer_Module
8181
*/
82-
protected function _addAction( $tag, $method, $methodClass=NULL, $priority = 10, $accepted_args = 1 ) {
82+
protected function _addAction( $tag, $method, $methodClass = null, $priority = 10, $accepted_args = 1 ) {
8383
add_action( $tag, array( $methodClass ? $methodClass : $this, $method ), $priority, $accepted_args );
8484
return $this;
8585
}
@@ -90,13 +90,14 @@ protected function _addAction( $tag, $method, $methodClass=NULL, $priority = 10,
9090
* @since 1.0.0
9191
*
9292
* @access public
93-
* @param string $tag The name of the AJAX action to which the $method is hooked.
94-
* @param string $method Optional. The name of the method to be called. If the name of the method is not provided, tag name will be used as method name.
93+
* @param string $tag The name of the AJAX action to which the $method is hooked.
94+
* @param string $method Optional. The name of the method to be called. If the name of the method is not provided, tag name will be used as method name.
95+
* @param bool $methodClass The root of the method.
9596
* @param boolean $private Optional. Determines if we should register hook for logged in users.
9697
* @param boolean $public Optional. Determines if we should register hook for not logged in users.
9798
* @return Visualizer_Module
9899
*/
99-
protected function _addAjaxAction( $tag, $method = '', $methodClass=NULL, $private = true, $public = false ) {
100+
protected function _addAjaxAction( $tag, $method = '', $methodClass = null, $private = true, $public = false ) {
100101
if ( $private ) {
101102
$this->_addAction( 'wp_ajax_' . $tag, $method, $methodClass );
102103
}
@@ -116,9 +117,9 @@ protected function _addAjaxAction( $tag, $method = '', $methodClass=NULL, $priva
116117
*
117118
* @access protected
118119
* @param string $tag The name of the filter to hook the $method to.
119-
* @param type $method The name of the method to be called when the filter is applied.
120-
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
121-
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
120+
* @param type $method The name of the method to be called when the filter is applied.
121+
* @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
122+
* @param int $accepted_args optional. The number of arguments the function accept (default 1).
122123
* @return Visualizer_Module
123124
*/
124125
protected function _addFilter( $tag, $method, $priority = 10, $accepted_args = 1 ) {
@@ -142,4 +143,4 @@ protected function _addShortcode( $tag, $method ) {
142143
return $this;
143144
}
144145

145-
}
146+
}

classes/Visualizer/Module/Admin.php

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
// +----------------------------------------------------------------------+
2020
// | Author: Eugene Manuilov <[email protected]> |
2121
// +----------------------------------------------------------------------+
22-
2322
/**
2423
* The module for all admin stuff.
2524
*
@@ -75,21 +74,21 @@ public function __construct( Visualizer_Plugin $plugin ) {
7574
*/
7675
public static function _getChartTypesLocalized() {
7776
$types = array(
78-
'all' => esc_html__( 'All', Visualizer_Plugin::NAME ),
79-
'pie' => esc_html__( 'Pie', Visualizer_Plugin::NAME ),
80-
'line' => esc_html__( 'Line', Visualizer_Plugin::NAME ),
81-
'area' => esc_html__( 'Area', Visualizer_Plugin::NAME ),
82-
'geo' => esc_html__( 'Geo', Visualizer_Plugin::NAME ),
83-
'bar' => esc_html__( 'Bar', Visualizer_Plugin::NAME ),
84-
'column' => esc_html__( 'Column', Visualizer_Plugin::NAME ),
85-
'gauge' => esc_html__( 'Gauge', Visualizer_Plugin::NAME ),
86-
'scatter' => esc_html__( 'Scatter', Visualizer_Plugin::NAME ),
87-
'candlestick' => esc_html__( 'Candlestick', Visualizer_Plugin::NAME ),
77+
'all' => esc_html__( 'All', 'visualizer' ),
78+
'pie' => esc_html__( 'Pie', 'visualizer' ),
79+
'line' => esc_html__( 'Line', 'visualizer' ),
80+
'area' => esc_html__( 'Area', 'visualizer' ),
81+
'geo' => esc_html__( 'Geo', 'visualizer' ),
82+
'bar' => esc_html__( 'Bar', 'visualizer' ),
83+
'column' => esc_html__( 'Column', 'visualizer' ),
84+
'gauge' => esc_html__( 'Gauge', 'visualizer' ),
85+
'scatter' => esc_html__( 'Scatter', 'visualizer' ),
86+
'candlestick' => esc_html__( 'Candlestick', 'visualizer' ),
8887
);
8988

90-
$types = apply_filters("visualizer_pro_chart_types", $types);
89+
$types = apply_filters( 'visualizer_pro_chart_types', $types );
9190

92-
return $types;
91+
return $types;
9392
}
9493

9594
/**
@@ -134,11 +133,11 @@ public function setupMediaViewStrings( $strings ) {
134133
'delete_chart' => Visualizer_Plugin::ACTION_DELETE_CHART,
135134
),
136135
'controller' => array(
137-
'title' => esc_html__( 'Visualizations', Visualizer_Plugin::NAME ),
136+
'title' => esc_html__( 'Visualizations', 'visualizer' ),
138137
),
139138
'routers' => array(
140-
'library' => esc_html__( 'From Library', Visualizer_Plugin::NAME ),
141-
'create' => esc_html__( 'Create New', Visualizer_Plugin::NAME ),
139+
'library' => esc_html__( 'From Library', 'visualizer' ),
140+
'create' => esc_html__( 'Create New', 'visualizer' ),
142141
),
143142
'library' => array(
144143
'filters' => self::_getChartTypesLocalized(),
@@ -189,7 +188,7 @@ public function enqueueLibraryScripts( $suffix ) {
189188
wp_enqueue_media();
190189
wp_enqueue_script( 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array( 'jquery', 'media-views' ), Visualizer_Plugin::VERSION, true );
191190
wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true );
192-
wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array('google-jsapi-new'), null, true );
191+
wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true );
193192
wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( 'google-jsapi-old', 'visualizer-library' ), Visualizer_Plugin::VERSION, true );
194193
}
195194
}
@@ -216,7 +215,7 @@ public function setupVisualizerTab( $tabs ) {
216215
* @access public
217216
*/
218217
public function registerAdminMenu() {
219-
$title = esc_html__( 'Visualizer Library', Visualizer_Plugin::NAME );
218+
$title = esc_html__( 'Visualizer Library', 'visualizer' );
220219
$callback = array( $this, 'renderLibraryPage' );
221220
$this->_libraryPage = add_submenu_page( 'upload.php', $title, $title, 'edit_posts', Visualizer_Plugin::NAME, $callback );
222221
}
@@ -234,7 +233,7 @@ public function renderLibraryPage() {
234233
'options' => array(
235234
'min_range' => 1,
236235
'default' => 1,
237-
)
236+
),
238237
) );
239238

240239
// the initial query arguments to fetch charts
@@ -258,24 +257,23 @@ public function renderLibraryPage() {
258257
$filter = 'all';
259258
}
260259

261-
// Added by Ash/Upwork
262-
$filterByMeta = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
263-
if($filterByMeta){
264-
$query = array(
260+
// Added by Ash/Upwork
261+
$filterByMeta = filter_input( INPUT_GET, 'filter', FILTER_SANITIZE_STRING );
262+
if ( $filterByMeta ) {
263+
$query = array(
265264
'key' => Visualizer_Plugin::CF_SETTINGS,
266265
'value' => $filterByMeta,
267266
'compare' => 'LIKE',
268-
);
269-
$meta = isset($query_args['meta_query']) ? $query_args['meta_query'] : array();
270-
$meta[] = $query;
271-
$query_args['meta_query'] = $meta;
272-
}
273-
// Added by Ash/Upwork
274-
267+
);
268+
$meta = isset( $query_args['meta_query'] ) ? $query_args['meta_query'] : array();
269+
$meta[] = $query;
270+
$query_args['meta_query'] = $meta;
271+
}
272+
// Added by Ash/Upwork
275273
// fetch charts
276274
$charts = array();
277275
$query = new WP_Query( $query_args );
278-
while( $query->have_posts() ) {
276+
while ( $query->have_posts() ) {
279277
$chart = $query->next_post();
280278

281279
// fetch and update settings
@@ -287,7 +285,7 @@ public function renderLibraryPage() {
287285
$data = apply_filters( Visualizer_Plugin::FILTER_GET_CHART_DATA, unserialize( $chart->post_content ), $chart->ID, $type );
288286

289287
// add chart to the array
290-
$charts['visualizer-' . $chart->ID] = array(
288+
$charts[ 'visualizer-' . $chart->ID ] = array(
291289
'id' => $chart->ID,
292290
'type' => $type,
293291
'series' => $series,
@@ -303,7 +301,7 @@ public function renderLibraryPage() {
303301
'urls' => array(
304302
'base' => add_query_arg( 'vpage', false ),
305303
'create' => add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_CREATE_CHART, 'library' => 'yes' ), $ajaxurl ),
306-
'edit' => add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_EDIT_CHART, 'library' => 'yes' ), $ajaxurl ),
304+
'edit' => add_query_arg( array( 'action' => Visualizer_Plugin::ACTION_EDIT_CHART, 'library' => 'yes' ), $ajaxurl ),
307305
),
308306
) );
309307

@@ -330,7 +328,7 @@ public function renderLibraryPage() {
330328
* @since 1.0.0
331329
*
332330
* @access public
333-
* @param array $links The array of original action links.
331+
* @param array $links The array of original action links.
334332
* @param string $file The plugin basename.
335333
* @return array Updated array of action links.
336334
*/
@@ -341,7 +339,7 @@ public function getPluginActionLinks( $links, $file ) {
341339
sprintf(
342340
'<a href="%s">%s</a>',
343341
admin_url( 'upload.php?page=' . Visualizer_Plugin::NAME ),
344-
esc_html__( 'Library', Visualizer_Plugin::NAME )
342+
esc_html__( 'Library', 'visualizer' )
345343
)
346344
);
347345
}
@@ -355,7 +353,7 @@ public function getPluginActionLinks( $links, $file ) {
355353
* @since 1.0.0
356354
*
357355
* @access public
358-
* @param array $plugin_meta The array of a plugin meta links.
356+
* @param array $plugin_meta The array of a plugin meta links.
359357
* @param string $plugin_file The plugin's basename.
360358
* @return array Updated array of plugin meta links.
361359
*/
@@ -364,16 +362,16 @@ public function getPluginMetaLinks( $plugin_meta, $plugin_file ) {
364362
// knowledge base link
365363
$plugin_meta[] = sprintf(
366364
'<a href="https://github.com/codeinwp/visualizer/wiki" target="_blank">%s</a>',
367-
esc_html__( 'Knowledge Base', Visualizer_Plugin::NAME )
365+
esc_html__( 'Knowledge Base', 'visualizer' )
368366
);
369367
// flattr link
370368
$plugin_meta[] = sprintf(
371369
'<a style="color:red" href="https://themeisle.com/plugins/visualizer-charts-and-graphs-pro-addon/" target="_blank">%s</a>',
372-
esc_html__( 'Pro Addon', Visualizer_Plugin::NAME )
370+
esc_html__( 'Pro Addon', 'visualizer' )
373371
);
374372
}
375373

376374
return $plugin_meta;
377375
}
378376

379-
}
377+
}

0 commit comments

Comments
 (0)