| @@ -53,37 +53,28 @@ | ||
| 53 | 53 | parent::__construct( $plugin ); |
| 54 | 54 | $this->_addAction( 'load-post.php', 'enqueueMediaScripts' ); |
| 55 | 55 | $this->_addAction( 'load-post-new.php', 'enqueueMediaScripts' ); |
| 56 | 56 | $this->_addAction( 'admin_footer', 'renderTempaltes' ); |
| 57 | - $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 8 ); | |
| 57 | + $this->_addAction( 'admin_enqueue_scripts', 'enqueueLibraryScripts', null, 9 ); | |
| 58 | 58 | $this->_addAction( 'admin_menu', 'registerAdminMenu' ); |
| 59 | 59 | $this->_addFilter( 'media_view_strings', 'setupMediaViewStrings' ); |
| 60 | 60 | $this->_addFilter( 'plugin_action_links', 'getPluginActionLinks', 10, 2 ); |
| 61 | - $this->_addFilter( 'visualizer_logger_data', 'getLoggerData' ); | |
| 62 | - $this->_addFilter( 'visualizer_get_chart_counts', 'getChartCountsByTypeAndMeta' ); | |
| 63 | - $this->_addFilter( 'visualizer_feedback_review_trigger', 'feedbackReviewTrigger' ); | |
| 61 | + $this->_addFilter( 'plugin_row_meta', 'getPluginMetaLinks', 10, 2 ); | |
| 62 | + $this->_addAjaxAction( Visualizer_Plugin::ACTION_TRACK, 'visualizer_enable_track' ); | |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | 65 | /** |
| 67 | - * Whether to show the feedback review or not. | |
| 68 | - * | |
| 69 | - * @access public | |
| 66 | + * Enable track ajax action. | |
| 70 | 67 | */ |
| 71 | - public function feedbackReviewTrigger( $dumb ) { | |
| 72 | - $query = new WP_Query( | |
| 73 | - array( | |
| 74 | - 'posts_per_page' => 50, | |
| 75 | - 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, | |
| 76 | - 'fields' => 'ids', | |
| 77 | - 'update_post_meta_cache' => false, | |
| 78 | - 'update_post_term_cache' => false, | |
| 79 | - ) | |
| 80 | - ); | |
| 81 | - | |
| 82 | - if ( $query->have_posts() && $query->post_count > 0 ) { | |
| 83 | - return true; | |
| 68 | + public function visualizer_enable_track() { | |
| 69 | + check_admin_referer( Visualizer_Plugin::ACTION_TRACK, 'nonce' ); | |
| 70 | + $status = $_GET['status']; | |
| 71 | + if ( $status == 'yes' ) { | |
| 72 | + update_option( 'visualizer_logger_flag', 'yes' ); | |
| 73 | + } else { | |
| 74 | + update_option( 'visualizer_logger_flag', 'no' ); | |
| 84 | 75 | } |
| 85 | - return false; | |
| 76 | + wp_send_json_success( array( 'status' => $status ) ); | |
| 86 | 77 | } |
| 87 | 78 | |
| 88 | 79 | /** |
| 89 | 80 | * Enqueues media scripts and styles. |
| @@ -268,22 +259,18 @@ | ||
| 268 | 259 | if ( $suffix == $this->_libraryPage ) { |
| 269 | 260 | wp_enqueue_style( 'visualizer-library', VISUALIZER_ABSURL . 'css/library.css', array(), Visualizer_Plugin::VERSION ); |
| 270 | 261 | $this->_addFilter( 'media_upload_tabs', 'setupVisualizerTab' ); |
| 271 | 262 | wp_enqueue_media(); |
| 272 | - wp_enqueue_script( | |
| 273 | - 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array( | |
| 274 | - 'jquery', | |
| 275 | - 'media-views', | |
| 276 | - ), Visualizer_Plugin::VERSION, true | |
| 277 | - ); | |
| 263 | + wp_enqueue_script( 'visualizer-library', VISUALIZER_ABSURL . 'js/library.js', array( | |
| 264 | + 'jquery', | |
| 265 | + 'media-views', | |
| 266 | + ), Visualizer_Plugin::VERSION, true ); | |
| 278 | 267 | wp_enqueue_script( 'google-jsapi-new', '//www.gstatic.com/charts/loader.js', array(), null, true ); |
| 279 | 268 | wp_enqueue_script( 'google-jsapi-old', '//www.google.com/jsapi', array( 'google-jsapi-new' ), null, true ); |
| 280 | - wp_enqueue_script( | |
| 281 | - 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( | |
| 282 | - 'google-jsapi-old', | |
| 283 | - 'visualizer-library', | |
| 284 | - ), Visualizer_Plugin::VERSION, true | |
| 285 | - ); | |
| 269 | + wp_enqueue_script( 'visualizer-render', VISUALIZER_ABSURL . 'js/render.js', array( | |
| 270 | + 'google-jsapi-old', | |
| 271 | + 'visualizer-library', | |
| 272 | + ), Visualizer_Plugin::VERSION, true ); | |
| 286 | 273 | } |
| 287 | 274 | } |
| 288 | 275 | |
| 289 | 276 | /** |
| @@ -324,16 +311,14 @@ | ||
| 324 | 311 | * @access public |
| 325 | 312 | */ |
| 326 | 313 | public function renderLibraryPage() { |
| 327 | 314 | // get current page |
| 328 | - $page = filter_input( | |
| 329 | - INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array( | |
| 330 | - 'options' => array( | |
| 331 | - 'min_range' => 1, | |
| 332 | - 'default' => 1, | |
| 333 | - ), | |
| 334 | - ) | |
| 335 | - ); | |
| 315 | + $page = filter_input( INPUT_GET, 'vpage', FILTER_VALIDATE_INT, array( | |
| 316 | + 'options' => array( | |
| 317 | + 'min_range' => 1, | |
| 318 | + 'default' => 1, | |
| 319 | + ), | |
| 320 | + ) ); | |
| 336 | 321 | // the initial query arguments to fetch charts |
| 337 | 322 | $query_args = array( |
| 338 | 323 | 'post_type' => Visualizer_Plugin::CPT_VISUALIZER, |
| 339 | 324 | 'posts_per_page' => 6, |
| @@ -386,42 +371,39 @@ | ||
| 386 | 371 | ); |
| 387 | 372 | } |
| 388 | 373 | // enqueue charts array |
| 389 | 374 | $ajaxurl = admin_url( 'admin-ajax.php' ); |
| 390 | - wp_localize_script( | |
| 391 | - 'visualizer-library', 'visualizer', array( | |
| 392 | - 'charts' => $charts, | |
| 393 | - 'urls' => array( | |
| 394 | - 'base' => add_query_arg( 'vpage', false ), | |
| 395 | - 'create' => add_query_arg( | |
| 396 | - array( | |
| 397 | - 'action' => Visualizer_Plugin::ACTION_CREATE_CHART, | |
| 398 | - 'library' => 'yes', | |
| 399 | - ), $ajaxurl | |
| 400 | - ), | |
| 401 | - 'edit' => add_query_arg( | |
| 402 | - array( | |
| 403 | - 'action' => Visualizer_Plugin::ACTION_EDIT_CHART, | |
| 404 | - 'library' => 'yes', | |
| 405 | - ), $ajaxurl | |
| 406 | - ), | |
| 407 | - ), | |
| 408 | - ) | |
| 409 | - ); | |
| 375 | + wp_localize_script( 'visualizer-library', 'visualizer', array( | |
| 376 | + 'charts' => $charts, | |
| 377 | + 'urls' => array( | |
| 378 | + 'base' => add_query_arg( 'vpage', false ), | |
| 379 | + 'create' => add_query_arg( array( | |
| 380 | + 'action' => Visualizer_Plugin::ACTION_CREATE_CHART, | |
| 381 | + 'library' => 'yes', | |
| 382 | + ), $ajaxurl ), | |
| 383 | + 'edit' => add_query_arg( array( | |
| 384 | + 'action' => Visualizer_Plugin::ACTION_EDIT_CHART, | |
| 385 | + 'library' => 'yes', | |
| 386 | + ), $ajaxurl ), | |
| 387 | + 'logger' => add_query_arg( array( | |
| 388 | + 'action' => Visualizer_Plugin::ACTION_TRACK, | |
| 389 | + 'library' => 'yes', | |
| 390 | + 'nonce' => wp_create_nonce( Visualizer_Plugin::ACTION_TRACK ), | |
| 391 | + ), $ajaxurl ), | |
| 392 | + ), | |
| 393 | + ) ); | |
| 410 | 394 | // render library page |
| 411 | 395 | $render = new Visualizer_Render_Library(); |
| 412 | 396 | $render->charts = $charts; |
| 413 | 397 | $render->type = $filter; |
| 414 | 398 | $render->types = self::_getChartTypesLocalized(); |
| 415 | - $render->pagination = paginate_links( | |
| 416 | - array( | |
| 417 | - 'base' => add_query_arg( 'vpage', '%#%' ), | |
| 418 | - 'format' => '', | |
| 419 | - 'current' => $page, | |
| 420 | - 'total' => $query->max_num_pages, | |
| 421 | - 'type' => 'array', | |
| 422 | - ) | |
| 423 | - ); | |
| 399 | + $render->pagination = paginate_links( array( | |
| 400 | + 'base' => add_query_arg( 'vpage', '%#%' ), | |
| 401 | + 'format' => '', | |
| 402 | + 'current' => $page, | |
| 403 | + 'total' => $query->max_num_pages, | |
| 404 | + 'type' => 'array', | |
| 405 | + ) ); | |
| 424 | 406 | $render->render(); |
| 425 | 407 | } |
| 426 | 408 | |
| 427 | 409 | /** |