PluginProbe
Reviews Plus / trunk
Reviews Plus vtrunk
1.4.2 trunk 1.0.7 1.1.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1
reviews-plus / reviews-plus.php

reviews-plus.php in Reviews Plus trunk, at reviews-plus.php

127 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: Reviews Plus - Google compatible WordPress Reviews for any content
5 * Description: Add rich reviews to posts, pages or any custom post type. Reviews summary compatible with SERP.
6 * Version: 1.4.2
7 * Author: impleCode
8 * Author URI: https://implecode.com
9 * Text Domain: reviews-plus
10 * Domain Path: /lang/
11 */
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 define( 'AL_REVIEWS_BASE_URL', plugins_url( '/', __FILE__ ) );
17 define( 'AL_REVIEWS_BASE_PATH', dirname( __FILE__ ) );
18 define( 'AL_REVIEWS_MAIN_FILE', __FILE__ );
19
20 add_action( 'after_setup_theme', 'start_ic_revs', 16 );
21
22 function start_ic_revs() {
23 load_plugin_textdomain( 'reviews-plus', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
24 require_once( AL_REVIEWS_BASE_PATH . '/functions/index.php' );
25 require_once( AL_REVIEWS_BASE_PATH . '/includes/index.php' );
26 require_once( AL_REVIEWS_BASE_PATH . '/sep/index.php' );
27 require_once( AL_REVIEWS_BASE_PATH . '/ext/index.php' );
28 }
29
30 add_action( 'init', 'ic_revs_register_styles', 20 );
31
32 /**
33 * Registers reviews stylesheet
34 *
35 */
36 function ic_revs_register_styles() {
37 wp_register_style( 'al_ic_revs_styles', AL_REVIEWS_BASE_URL . 'css/reviews-plus.min.css' . ic_filemtime( AL_REVIEWS_BASE_PATH . '/css/reviews-plus.min.css' ) );
38 wp_register_script( 'al_ic_revs_scripts', AL_REVIEWS_BASE_URL . 'js/reviews-plus.min.js' . ic_filemtime( AL_REVIEWS_BASE_PATH . '/js/reviews-plus.min.js' ), array( 'jquery' ) );
39 }
40
41 add_action( 'current_screen', 'ic_revs_admin_register_styles', 20 );
42
43 /**
44 * Registers reviews admin stylesheet
45 *
46 */
47 function ic_revs_admin_register_styles() {
48 wp_register_style( 'al_ic_revs_admin_styles', AL_REVIEWS_BASE_URL . 'css/reviews-plus-admin.min.css' . ic_filemtime( AL_REVIEWS_BASE_PATH . 'css/reviews-plus-admin.min.css' ), array(
49 'wp-color-picker',
50 'dashicons'
51 ) );
52 wp_register_script( 'al_ic_revs_scripts', AL_REVIEWS_BASE_URL . 'js/reviews-plus.min.js' . ic_filemtime( AL_REVIEWS_BASE_PATH . '/js/reviews-plus.min.js' ), array( 'jquery' ) );
53 $deps = array(
54 'jquery',
55 'admin-comments',
56 );
57 if ( is_ic_revs_admin_screen() || is_ic_review_edit_screen() ) {
58 $in_footer = true;
59 } else {
60 $deps[] = 'wp-color-picker';
61 $in_footer = false;
62 }
63 $screen = get_current_screen();
64 if ( ! empty( $screen->is_block_editor ) ) {
65 $deps[] = 'wp-edit-post';
66 wp_register_script( 'al_ic_revs_admin_editor', AL_REVIEWS_BASE_URL . 'js/reviews-plus-editor.min.js' . ic_filemtime( plugin_dir_path( __FILE__ ) . '/js/reviews-plus-editor.min.js' ), array(
67 'wp-data',
68 'wp-edit-post'
69 ) );
70 }
71 wp_register_script( 'al_ic_revs_admin_scripts', AL_REVIEWS_BASE_URL . 'js/reviews-plus-admin.min.js' . ic_filemtime( plugin_dir_path( __FILE__ ) . '/js/reviews-plus-admin.min.js' ), $deps, false, $in_footer );
72
73 }
74
75 add_action( 'wp_enqueue_scripts', 'ic_revs_enqueue_styles', 20 );
76
77 /**
78 * Enqueues catalog stylesheet
79 *
80 */
81 function ic_revs_enqueue_styles() {
82 wp_enqueue_style( 'dashicons' );
83 wp_enqueue_style( 'al_ic_revs_styles' );
84 wp_enqueue_script( 'al_ic_revs_scripts' );
85 wp_localize_script( 'al_ic_revs_scripts', 'ic_revs', array(
86 'no_rating' => implecode_warning( __( 'The rating cannot be empty.', 'reviews-plus' ), 0 ),
87 'no_empty' => implecode_warning( __( 'A valid value is required.', 'reviews-plus' ), 0 ),
88 'check_errors' => implecode_warning( __( 'Please fill all the required data.', 'reviews-plus' ), 0 )
89 ) );
90 }
91
92 add_action( 'admin_enqueue_scripts', 'ic_revs_admin_enqueue_styles', 20 );
93
94 /**
95 * Enqueues catalog admin stylesheet
96 *
97 */
98 function ic_revs_admin_enqueue_styles() {
99 wp_enqueue_style( 'al_ic_revs_admin_styles' );
100 wp_localize_script( 'al_ic_revs_admin_scripts', 'reviews_object', array(
101 'showcomm' => __( 'Show more reviews' ),
102 'endcomm' => __( 'No more reviews found.' ),
103 'nonce' => wp_create_nonce( 'ic-ajax-nonce' )
104 ) );
105 wp_enqueue_script( 'al_ic_revs_admin_scripts' );
106 wp_enqueue_script( 'al_ic_revs_scripts' );
107 global $current_screen;
108 $post_types = get_ic_review_active_post_types();
109 if ( function_exists( 'product_post_type_array' ) ) {
110 $post_types = array_merge( product_post_type_array(), $post_types );
111 }
112 if ( is_array( $post_types ) && ! empty( $current_screen->post_type ) && ! in_array( $current_screen->post_type, $post_types ) ) {
113 return;
114 }
115 wp_enqueue_script( 'al_ic_revs_admin_editor' );
116 }
117
118 add_action( 'admin_enqueue_scripts', 'ic_enqueue_review_scripts' );
119
120 function ic_enqueue_review_scripts() {
121
122 if ( is_ic_revs_admin_screen() ) {
123 wp_enqueue_script( 'admin-comments' );
124 enqueue_comment_hotkeys_js();
125 }
126 }
127