@@ -21,112 +21,112 @@ |
||
21 | 21 | |
22 | 22 | class Actions implements HooksContract |
23 | 23 | { |
24 | - protected $about; |
|
25 | - protected $admin; |
|
26 | - protected $app; |
|
27 | - protected $blocks; |
|
28 | - protected $console; |
|
29 | - protected $editor; |
|
30 | - protected $listtable; |
|
31 | - protected $menu; |
|
32 | - protected $main; |
|
33 | - protected $notices; |
|
34 | - protected $public; |
|
35 | - protected $review; |
|
36 | - protected $router; |
|
37 | - protected $settings; |
|
38 | - protected $taxonomy; |
|
39 | - protected $translator; |
|
40 | - protected $trustalyze; |
|
41 | - protected $welcome; |
|
24 | + protected $about; |
|
25 | + protected $admin; |
|
26 | + protected $app; |
|
27 | + protected $blocks; |
|
28 | + protected $console; |
|
29 | + protected $editor; |
|
30 | + protected $listtable; |
|
31 | + protected $menu; |
|
32 | + protected $main; |
|
33 | + protected $notices; |
|
34 | + protected $public; |
|
35 | + protected $review; |
|
36 | + protected $router; |
|
37 | + protected $settings; |
|
38 | + protected $taxonomy; |
|
39 | + protected $translator; |
|
40 | + protected $trustalyze; |
|
41 | + protected $welcome; |
|
42 | 42 | |
43 | - public function __construct(Application $app ) { |
|
44 | - $this->app = $app; |
|
45 | - $this->admin = $app->make(AdminController::class); |
|
46 | - $this->blocks = $app->make(BlocksController::class); |
|
47 | - $this->console = $app->make(Console::class); |
|
48 | - $this->editor = $app->make(EditorController::class); |
|
49 | - $this->listtable = $app->make(ListTableController::class); |
|
50 | - $this->main = $app->make(MainController::class); |
|
51 | - $this->menu = $app->make(MenuController::class); |
|
52 | - $this->notices = $app->make(NoticeController::class); |
|
53 | - $this->public = $app->make(PublicController::class); |
|
54 | - $this->review = $app->make(ReviewController::class); |
|
55 | - $this->router = $app->make(Router::class); |
|
56 | - $this->settings = $app->make(SettingsController::class); |
|
57 | - $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | - $this->translator = $app->make(TranslationController::class); |
|
59 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | - $this->welcome = $app->make(WelcomeController::class); |
|
61 | - } |
|
43 | + public function __construct(Application $app ) { |
|
44 | + $this->app = $app; |
|
45 | + $this->admin = $app->make(AdminController::class); |
|
46 | + $this->blocks = $app->make(BlocksController::class); |
|
47 | + $this->console = $app->make(Console::class); |
|
48 | + $this->editor = $app->make(EditorController::class); |
|
49 | + $this->listtable = $app->make(ListTableController::class); |
|
50 | + $this->main = $app->make(MainController::class); |
|
51 | + $this->menu = $app->make(MenuController::class); |
|
52 | + $this->notices = $app->make(NoticeController::class); |
|
53 | + $this->public = $app->make(PublicController::class); |
|
54 | + $this->review = $app->make(ReviewController::class); |
|
55 | + $this->router = $app->make(Router::class); |
|
56 | + $this->settings = $app->make(SettingsController::class); |
|
57 | + $this->taxonomy = $app->make(TaxonomyController::class); |
|
58 | + $this->translator = $app->make(TranslationController::class); |
|
59 | + $this->trustalyze = $app->make(TrustalyzeController::class); |
|
60 | + $this->welcome = $app->make(WelcomeController::class); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @return void |
|
65 | - */ |
|
66 | - public function run() |
|
67 | - { |
|
68 | - add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | - add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | - add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | - add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | - add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | - add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | - add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | - add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | - add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | - add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | - add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | - add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | - add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | - add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | - add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | - add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | - add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | - add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | - add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | - add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | - add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | - add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | - add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | - add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | - add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | - add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | - add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | - add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | - add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | - add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | - add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | - add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | - add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | - add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | - add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | - add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | - add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | - add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | - add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | - add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | - add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | - add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | - add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | - add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | - add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | - add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | - add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | - add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | - add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | - add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | - add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | - add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | - add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | - add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | - add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | - add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | - add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | - add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | - add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | - add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | - add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | - add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | - add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
131 | - } |
|
63 | + /** |
|
64 | + * @return void |
|
65 | + */ |
|
66 | + public function run() |
|
67 | + { |
|
68 | + add_action('admin_enqueue_scripts', [$this->admin, 'enqueueAssets']); |
|
69 | + add_action('admin_init', [$this->admin, 'registerTinymcePopups']); |
|
70 | + add_action('media_buttons', [$this->admin, 'renderTinymceButton'], 11); |
|
71 | + add_action('admin_init', [$this->admin, 'runMigrations']); |
|
72 | + add_action('plugins_loaded', [$this->app, 'getDefaults'], 11); |
|
73 | + add_action('plugins_loaded', [$this->app, 'registerAddons']); |
|
74 | + add_action('plugins_loaded', [$this->app, 'registerLanguages']); |
|
75 | + add_action('plugins_loaded', [$this->app, 'registerReviewTypes']); |
|
76 | + add_action('admin_init', [$this->app, 'setDefaults']); |
|
77 | + add_action('init', [$this->blocks, 'registerAssets'], 9); |
|
78 | + add_action('init', [$this->blocks, 'registerBlocks']); |
|
79 | + add_action('admin_footer', [$this->console, 'logOnce']); |
|
80 | + add_action('wp_footer', [$this->console, 'logOnce']); |
|
81 | + add_action('add_meta_boxes_'.Application::POST_TYPE, [$this->editor, 'registerMetaBoxes']); |
|
82 | + add_action('admin_print_scripts', [$this->editor, 'removeAutosave'], 999); |
|
83 | + add_action('admin_menu', [$this->editor, 'removeMetaBoxes']); |
|
84 | + add_action('current_screen', [$this->editor, 'removePostTypeSupport']); |
|
85 | + add_action('post_submitbox_misc_actions', [$this->editor, 'renderPinnedInPublishMetaBox']); |
|
86 | + add_action('admin_head', [$this->editor, 'renderReviewFields']); |
|
87 | + add_action('admin_action_revert', [$this->editor, 'revertReview']); |
|
88 | + add_action('save_post_'.Application::POST_TYPE, [$this->editor, 'saveMetaboxes'], 10, 3); |
|
89 | + add_action('admin_action_approve', [$this->listtable, 'approve']); |
|
90 | + add_action('bulk_edit_custom_box', [$this->listtable, 'renderBulkEditFields'], 10, 2); |
|
91 | + add_action('restrict_manage_posts', [$this->listtable, 'renderColumnFilters']); |
|
92 | + add_action('manage_'.Application::POST_TYPE.'_posts_custom_column', [$this->listtable, 'renderColumnValues'], 10, 2); |
|
93 | + add_action('save_post_'.Application::POST_TYPE, [$this->listtable, 'saveBulkEditFields']); |
|
94 | + add_action('pre_get_posts', [$this->listtable, 'setQueryForColumn']); |
|
95 | + add_action('admin_action_unapprove', [$this->listtable, 'unapprove']); |
|
96 | + add_action('init', [$this->main, 'registerPostType'], 8); |
|
97 | + add_action('init', [$this->main, 'registerShortcodes']); |
|
98 | + add_action('init', [$this->main, 'registerTaxonomy']); |
|
99 | + add_action('widgets_init', [$this->main, 'registerWidgets']); |
|
100 | + add_action('admin_menu', [$this->menu, 'registerMenuCount']); |
|
101 | + add_action('admin_menu', [$this->menu, 'registerSubMenus']); |
|
102 | + add_action('admin_init', [$this->menu, 'setCustomPermissions'], 999); |
|
103 | + add_action('admin_notices', [$this->notices, 'filterAdminNotices']); |
|
104 | + add_action('wp_enqueue_scripts', [$this->public, 'enqueueAssets'], 999); |
|
105 | + add_filter('site-reviews/builder', [$this->public, 'modifyBuilder']); |
|
106 | + add_action('wp_footer', [$this->public, 'renderSchema']); |
|
107 | + add_action('set_object_terms', [$this->review, 'onAfterChangeCategory'], 10, 6); |
|
108 | + add_action('transition_post_status', [$this->review, 'onAfterChangeStatus'], 10, 3); |
|
109 | + add_action('site-reviews/review/created', [$this->review, 'onAfterCreate']); |
|
110 | + add_action('before_delete_post', [$this->review, 'onBeforeDelete']); |
|
111 | + add_action('update_postmeta', [$this->review, 'onBeforeUpdate'], 10, 4); |
|
112 | + add_action('admin_init', [$this->router, 'routeAdminPostRequest']); |
|
113 | + add_action('wp_ajax_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
114 | + add_action('wp_ajax_nopriv_'.Application::PREFIX.'action', [$this->router, 'routeAjaxRequest']); |
|
115 | + add_action('init', [$this->router, 'routePublicPostRequest']); |
|
116 | + add_action('admin_init', [$this->settings, 'registerSettings']); |
|
117 | + add_action(Application::TAXONOMY.'_term_edit_form_top', [$this->taxonomy, 'disableParents']); |
|
118 | + add_action(Application::TAXONOMY.'_term_new_form_tag', [$this->taxonomy, 'disableParents']); |
|
119 | + add_action(Application::TAXONOMY.'_add_form_fields', [$this->taxonomy, 'enableParents']); |
|
120 | + add_action(Application::TAXONOMY.'_edit_form', [$this->taxonomy, 'enableParents']); |
|
121 | + add_action('restrict_manage_posts', [$this->taxonomy, 'renderTaxonomyFilter'], 9); |
|
122 | + add_action('set_object_terms', [$this->taxonomy, 'restrictTermSelection'], 9, 6); |
|
123 | + add_action('plugins_loaded', [$this->translator, 'addTranslationFilters']); |
|
124 | + add_action('admin_enqueue_scripts', [$this->translator, 'translatePostStatusLabels']); |
|
125 | + add_action('site-reviews/review/created', [$this->trustalyze, 'onCreated']); |
|
126 | + add_action('site-reviews/review/reverted', [$this->trustalyze, 'onReverted']); |
|
127 | + add_action('site-reviews/review/saved', [$this->trustalyze, 'onSaved']); |
|
128 | + add_action('updated_postmeta', [$this->trustalyze, 'onUpdatedMeta'], 10, 3); |
|
129 | + add_action('activated_plugin', [$this->welcome, 'redirectOnActivation'], 10, 2); |
|
130 | + add_action('admin_menu', [$this->welcome, 'registerPage']); |
|
131 | + } |
|
132 | 132 | } |
@@ -15,64 +15,64 @@ |
||
15 | 15 | |
16 | 16 | class Filters implements HooksContract |
17 | 17 | { |
18 | - protected $admin; |
|
19 | - protected $app; |
|
20 | - protected $basename; |
|
21 | - protected $blocks; |
|
22 | - protected $editor; |
|
23 | - protected $listtable; |
|
24 | - protected $public; |
|
25 | - protected $translator; |
|
26 | - protected $trustalyze; |
|
27 | - protected $welcome; |
|
18 | + protected $admin; |
|
19 | + protected $app; |
|
20 | + protected $basename; |
|
21 | + protected $blocks; |
|
22 | + protected $editor; |
|
23 | + protected $listtable; |
|
24 | + protected $public; |
|
25 | + protected $translator; |
|
26 | + protected $trustalyze; |
|
27 | + protected $welcome; |
|
28 | 28 | |
29 | - public function __construct(Application $app) |
|
30 | - { |
|
31 | - $this->app = $app; |
|
32 | - $this->admin = $app->make(AdminController::class); |
|
33 | - $this->basename = plugin_basename($app->file); |
|
34 | - $this->blocks = $app->make(BlocksController::class); |
|
35 | - $this->editor = $app->make(EditorController::class); |
|
36 | - $this->listtable = $app->make(ListTableController::class); |
|
37 | - $this->public = $app->make(PublicController::class); |
|
38 | - $this->translator = $app->make(TranslationController::class); |
|
39 | - $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | - $this->welcome = $app->make(WelcomeController::class); |
|
41 | - } |
|
29 | + public function __construct(Application $app) |
|
30 | + { |
|
31 | + $this->app = $app; |
|
32 | + $this->admin = $app->make(AdminController::class); |
|
33 | + $this->basename = plugin_basename($app->file); |
|
34 | + $this->blocks = $app->make(BlocksController::class); |
|
35 | + $this->editor = $app->make(EditorController::class); |
|
36 | + $this->listtable = $app->make(ListTableController::class); |
|
37 | + $this->public = $app->make(PublicController::class); |
|
38 | + $this->translator = $app->make(TranslationController::class); |
|
39 | + $this->trustalyze = $app->make(TrustalyzeController::class); |
|
40 | + $this->welcome = $app->make(WelcomeController::class); |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function run() |
|
47 | - { |
|
48 | - add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | - add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | - add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | - add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | - add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | - add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | - add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | - add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | - add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | - add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | - add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | - add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | - add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | - add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | - add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | - add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | - add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | - add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | - add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | - add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | - add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
69 | - add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
70 | - add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
71 | - add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
72 | - add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
73 | - add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
74 | - add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
75 | - add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
76 | - add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
77 | - } |
|
43 | + /** |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function run() |
|
47 | + { |
|
48 | + add_filter('map_meta_cap', [$this->admin, 'filterCreateCapability'], 10, 2); |
|
49 | + add_filter('mce_external_plugins', [$this->admin, 'filterTinymcePlugins'], 15); |
|
50 | + add_filter('plugin_action_links_'.$this->basename, [$this->admin, 'filterActionLinks']); |
|
51 | + add_filter('dashboard_glance_items', [$this->admin, 'filterDashboardGlanceItems']); |
|
52 | + add_filter('block_categories', [$this->blocks, 'filterBlockCategories']); |
|
53 | + add_filter('classic_editor_enabled_editors_for_post_type', [$this->blocks, 'filterEnabledEditors'], 10, 2); |
|
54 | + add_filter('use_block_editor_for_post_type', [$this->blocks, 'filterUseBlockEditor'], 10, 2); |
|
55 | + add_filter('wp_editor_settings', [$this->editor, 'filterEditorSettings']); |
|
56 | + add_filter('the_editor', [$this->editor, 'filterEditorTextarea']); |
|
57 | + add_filter('is_protected_meta', [$this->editor, 'filterIsProtectedMeta'], 10, 3); |
|
58 | + add_filter('post_updated_messages', [$this->editor, 'filterUpdateMessages']); |
|
59 | + add_filter('manage_'.Application::POST_TYPE.'_posts_columns', [$this->listtable, 'filterColumnsForPostType']); |
|
60 | + add_filter('post_date_column_status', [$this->listtable, 'filterDateColumnStatus'], 10, 2); |
|
61 | + add_filter('default_hidden_columns', [$this->listtable, 'filterDefaultHiddenColumns'], 10, 2); |
|
62 | + add_filter('post_row_actions', [$this->listtable, 'filterRowActions'], 10, 2); |
|
63 | + add_filter('manage_edit-'.Application::POST_TYPE.'_sortable_columns', [$this->listtable, 'filterSortableColumns']); |
|
64 | + add_filter('script_loader_tag', [$this->public, 'filterEnqueuedScripts'], 10, 2); |
|
65 | + add_filter('site-reviews/config/forms/submission-form', [$this->public, 'filterFieldOrder'], 11); |
|
66 | + add_filter('site-reviews/render/view', [$this->public, 'filterRenderView']); |
|
67 | + add_filter('bulk_post_updated_messages', [$this->translator, 'filterBulkUpdateMessages'], 10, 2); |
|
68 | + add_filter('display_post_states', [$this->translator, 'filterPostStates'], 10, 2); |
|
69 | + add_filter('site-reviews/gettext/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
70 | + add_filter('site-reviews/gettext_with_context/default', [$this->translator, 'filterPostStatusLabels'], 10, 2); |
|
71 | + add_filter('site-reviews/ngettext/default', [$this->translator, 'filterPostStatusText'], 10, 4); |
|
72 | + add_filter('site-reviews/settings/callback', [$this->trustalyze, 'filterSettingsCallback']); |
|
73 | + add_filter('site-reviews/interpolate/partials/form/table-row-multiple', [$this->trustalyze, 'filterSettingsTableRow'], 10, 3); |
|
74 | + add_filter('plugin_action_links_'.$this->basename, [$this->welcome, 'filterActionLinks'], 9); |
|
75 | + add_filter('admin_title', [$this->welcome, 'filterAdminTitle']); |
|
76 | + add_filter('admin_footer_text', [$this->welcome, 'filterFooterText']); |
|
77 | + } |
|
78 | 78 | } |
@@ -10,184 +10,184 @@ |
||
10 | 10 | |
11 | 11 | class Columns |
12 | 12 | { |
13 | - /** |
|
14 | - * @param int $postId |
|
15 | - * @return void|string |
|
16 | - */ |
|
17 | - public function buildColumnAssignedTo($postId) |
|
18 | - { |
|
19 | - $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | - if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
21 | - return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
22 | - 'href' => (string) get_the_permalink($assignedPost->ID), |
|
23 | - ]); |
|
24 | - } |
|
25 | - } |
|
13 | + /** |
|
14 | + * @param int $postId |
|
15 | + * @return void|string |
|
16 | + */ |
|
17 | + public function buildColumnAssignedTo($postId) |
|
18 | + { |
|
19 | + $assignedPost = glsr(Database::class)->getAssignedToPost($postId); |
|
20 | + if ($assignedPost instanceof WP_Post && 'publish' == $assignedPost->post_status) { |
|
21 | + return glsr(Builder::class)->a(get_the_title($assignedPost->ID), [ |
|
22 | + 'href' => (string) get_the_permalink($assignedPost->ID), |
|
23 | + ]); |
|
24 | + } |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @param int $postId |
|
29 | - * @return void|string |
|
30 | - */ |
|
31 | - public function buildColumnEmail($postId) |
|
32 | - { |
|
33 | - if ($email = glsr(Database::class)->get($postId, 'email')) { |
|
34 | - return $email; |
|
35 | - } |
|
36 | - } |
|
27 | + /** |
|
28 | + * @param int $postId |
|
29 | + * @return void|string |
|
30 | + */ |
|
31 | + public function buildColumnEmail($postId) |
|
32 | + { |
|
33 | + if ($email = glsr(Database::class)->get($postId, 'email')) { |
|
34 | + return $email; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param int $postId |
|
40 | - * @return void|string |
|
41 | - */ |
|
42 | - public function buildColumnIpAddress($postId) |
|
43 | - { |
|
44 | - if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) { |
|
45 | - return $ipAddress; |
|
46 | - } |
|
47 | - } |
|
38 | + /** |
|
39 | + * @param int $postId |
|
40 | + * @return void|string |
|
41 | + */ |
|
42 | + public function buildColumnIpAddress($postId) |
|
43 | + { |
|
44 | + if ($ipAddress = glsr(Database::class)->get($postId, 'ip_address')) { |
|
45 | + return $ipAddress; |
|
46 | + } |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param int $postId |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function buildColumnPinned($postId) |
|
54 | - { |
|
55 | - $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
56 | - ? 'pinned ' |
|
57 | - : ''; |
|
58 | - if (glsr()->can('edit_others_posts')) { |
|
59 | - $pinned.= 'pin-review '; |
|
60 | - } |
|
61 | - return glsr(Builder::class)->i([ |
|
62 | - 'class' => $pinned.'dashicons dashicons-sticky', |
|
63 | - 'data-id' => $postId, |
|
64 | - ]); |
|
65 | - } |
|
49 | + /** |
|
50 | + * @param int $postId |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function buildColumnPinned($postId) |
|
54 | + { |
|
55 | + $pinned = glsr(Database::class)->get($postId, 'pinned') |
|
56 | + ? 'pinned ' |
|
57 | + : ''; |
|
58 | + if (glsr()->can('edit_others_posts')) { |
|
59 | + $pinned.= 'pin-review '; |
|
60 | + } |
|
61 | + return glsr(Builder::class)->i([ |
|
62 | + 'class' => $pinned.'dashicons dashicons-sticky', |
|
63 | + 'data-id' => $postId, |
|
64 | + ]); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @param int $postId |
|
69 | - * @return string |
|
70 | - */ |
|
71 | - public function buildColumnResponse($postId) |
|
72 | - { |
|
73 | - return glsr(Database::class)->get($postId, 'response') |
|
74 | - ? __('Yes', 'site-reviews') |
|
75 | - : __('No', 'site-reviews'); |
|
76 | - } |
|
67 | + /** |
|
68 | + * @param int $postId |
|
69 | + * @return string |
|
70 | + */ |
|
71 | + public function buildColumnResponse($postId) |
|
72 | + { |
|
73 | + return glsr(Database::class)->get($postId, 'response') |
|
74 | + ? __('Yes', 'site-reviews') |
|
75 | + : __('No', 'site-reviews'); |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * @param int $postId |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function buildColumnReviewer($postId) |
|
83 | - { |
|
84 | - $author = strval(glsr(Database::class)->get($postId, 'author')); |
|
85 | - $userId = Helper::castToInt(get_post($postId)->post_author); |
|
86 | - return !empty($userId) |
|
87 | - ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)]) |
|
88 | - : $author; |
|
89 | - } |
|
78 | + /** |
|
79 | + * @param int $postId |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function buildColumnReviewer($postId) |
|
83 | + { |
|
84 | + $author = strval(glsr(Database::class)->get($postId, 'author')); |
|
85 | + $userId = Helper::castToInt(get_post($postId)->post_author); |
|
86 | + return !empty($userId) |
|
87 | + ? glsr(Builder::class)->a($author, ['href' => get_author_posts_url($userId)]) |
|
88 | + : $author; |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * @param int $postId |
|
93 | - * @param int|null $rating |
|
94 | - * @return string |
|
95 | - */ |
|
96 | - public function buildColumnRating($postId) |
|
97 | - { |
|
98 | - return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
99 | - } |
|
91 | + /** |
|
92 | + * @param int $postId |
|
93 | + * @param int|null $rating |
|
94 | + * @return string |
|
95 | + */ |
|
96 | + public function buildColumnRating($postId) |
|
97 | + { |
|
98 | + return glsr_star_rating(intval(glsr(Database::class)->get($postId, 'rating'))); |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * @param int $postId |
|
103 | - * @return string |
|
104 | - */ |
|
105 | - public function buildColumnReviewType($postId) |
|
106 | - { |
|
107 | - $type = glsr(Database::class)->get($postId, 'review_type'); |
|
108 | - return array_key_exists($type, glsr()->reviewTypes) |
|
109 | - ? glsr()->reviewTypes[$type] |
|
110 | - : __('Unsupported Type', 'site-reviews'); |
|
111 | - } |
|
101 | + /** |
|
102 | + * @param int $postId |
|
103 | + * @return string |
|
104 | + */ |
|
105 | + public function buildColumnReviewType($postId) |
|
106 | + { |
|
107 | + $type = glsr(Database::class)->get($postId, 'review_type'); |
|
108 | + return array_key_exists($type, glsr()->reviewTypes) |
|
109 | + ? glsr()->reviewTypes[$type] |
|
110 | + : __('Unsupported Type', 'site-reviews'); |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
114 | - * @param string $postType |
|
115 | - * @return void |
|
116 | - */ |
|
117 | - public function renderFilters($postType) |
|
118 | - { |
|
119 | - if (Application::POST_TYPE !== $postType) { |
|
120 | - return; |
|
121 | - } |
|
122 | - if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
123 | - $status = 'publish'; |
|
124 | - } |
|
125 | - $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
126 | - $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
127 | - $this->renderFilterRatings($ratings); |
|
128 | - $this->renderFilterTypes($types); |
|
129 | - } |
|
113 | + /** |
|
114 | + * @param string $postType |
|
115 | + * @return void |
|
116 | + */ |
|
117 | + public function renderFilters($postType) |
|
118 | + { |
|
119 | + if (Application::POST_TYPE !== $postType) { |
|
120 | + return; |
|
121 | + } |
|
122 | + if (!($status = filter_input(INPUT_GET, 'post_status'))) { |
|
123 | + $status = 'publish'; |
|
124 | + } |
|
125 | + $ratings = glsr(Database::class)->getReviewsMeta('rating', $status); |
|
126 | + $types = glsr(Database::class)->getReviewsMeta('review_type', $status); |
|
127 | + $this->renderFilterRatings($ratings); |
|
128 | + $this->renderFilterTypes($types); |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @param string $column |
|
133 | - * @param int $postId |
|
134 | - * @return void |
|
135 | - */ |
|
136 | - public function renderValues($column, $postId) |
|
137 | - { |
|
138 | - $method = Helper::buildMethodName($column, 'buildColumn'); |
|
139 | - $value = method_exists($this, $method) |
|
140 | - ? call_user_func([$this, $method], $postId) |
|
141 | - : ''; |
|
142 | - $value = apply_filters('site-reviews/columns/'.$column, $value, $postId); |
|
143 | - if (0 !== $value && empty($value)) { |
|
144 | - $value = '—'; |
|
145 | - } |
|
146 | - echo $value; |
|
147 | - } |
|
131 | + /** |
|
132 | + * @param string $column |
|
133 | + * @param int $postId |
|
134 | + * @return void |
|
135 | + */ |
|
136 | + public function renderValues($column, $postId) |
|
137 | + { |
|
138 | + $method = Helper::buildMethodName($column, 'buildColumn'); |
|
139 | + $value = method_exists($this, $method) |
|
140 | + ? call_user_func([$this, $method], $postId) |
|
141 | + : ''; |
|
142 | + $value = apply_filters('site-reviews/columns/'.$column, $value, $postId); |
|
143 | + if (0 !== $value && empty($value)) { |
|
144 | + $value = '—'; |
|
145 | + } |
|
146 | + echo $value; |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param array $ratings |
|
151 | - * @return void |
|
152 | - */ |
|
153 | - protected function renderFilterRatings($ratings) |
|
154 | - { |
|
155 | - if (empty($ratings)) { |
|
156 | - return; |
|
157 | - } |
|
158 | - $ratings = array_flip(array_reverse($ratings)); |
|
159 | - array_walk($ratings, function (&$value, $key) { |
|
160 | - $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
161 | - $value = sprintf($label, $key); |
|
162 | - }); |
|
163 | - echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
164 | - 'class' => 'screen-reader-text', |
|
165 | - 'for' => 'rating', |
|
166 | - ]); |
|
167 | - echo glsr(Builder::class)->select([ |
|
168 | - 'name' => 'rating', |
|
169 | - 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
170 | - 'value' => filter_input(INPUT_GET, 'rating'), |
|
171 | - ]); |
|
172 | - } |
|
149 | + /** |
|
150 | + * @param array $ratings |
|
151 | + * @return void |
|
152 | + */ |
|
153 | + protected function renderFilterRatings($ratings) |
|
154 | + { |
|
155 | + if (empty($ratings)) { |
|
156 | + return; |
|
157 | + } |
|
158 | + $ratings = array_flip(array_reverse($ratings)); |
|
159 | + array_walk($ratings, function (&$value, $key) { |
|
160 | + $label = _n('%s star', '%s stars', $key, 'site-reviews'); |
|
161 | + $value = sprintf($label, $key); |
|
162 | + }); |
|
163 | + echo glsr(Builder::class)->label(__('Filter by rating', 'site-reviews'), [ |
|
164 | + 'class' => 'screen-reader-text', |
|
165 | + 'for' => 'rating', |
|
166 | + ]); |
|
167 | + echo glsr(Builder::class)->select([ |
|
168 | + 'name' => 'rating', |
|
169 | + 'options' => ['' => __('All ratings', 'site-reviews')] + $ratings, |
|
170 | + 'value' => filter_input(INPUT_GET, 'rating'), |
|
171 | + ]); |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * @param array $types |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - protected function renderFilterTypes($types) |
|
179 | - { |
|
180 | - if (count(glsr()->reviewTypes) < 2) { |
|
181 | - return; |
|
182 | - } |
|
183 | - echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
184 | - 'class' => 'screen-reader-text', |
|
185 | - 'for' => 'review_type', |
|
186 | - ]); |
|
187 | - echo glsr(Builder::class)->select([ |
|
188 | - 'name' => 'review_type', |
|
189 | - 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
190 | - 'value' => filter_input(INPUT_GET, 'review_type'), |
|
191 | - ]); |
|
192 | - } |
|
174 | + /** |
|
175 | + * @param array $types |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + protected function renderFilterTypes($types) |
|
179 | + { |
|
180 | + if (count(glsr()->reviewTypes) < 2) { |
|
181 | + return; |
|
182 | + } |
|
183 | + echo glsr(Builder::class)->label(__('Filter by type', 'site-reviews'), [ |
|
184 | + 'class' => 'screen-reader-text', |
|
185 | + 'for' => 'review_type', |
|
186 | + ]); |
|
187 | + echo glsr(Builder::class)->select([ |
|
188 | + 'name' => 'review_type', |
|
189 | + 'options' => ['' => __('All types', 'site-reviews')] + glsr()->reviewTypes, |
|
190 | + 'value' => filter_input(INPUT_GET, 'review_type'), |
|
191 | + ]); |
|
192 | + } |
|
193 | 193 | } |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | * @return mixed |
10 | 10 | */ |
11 | 11 | add_filter('plugins_loaded', function () { |
12 | - $hooks = array( |
|
13 | - 'glsr_calculate_ratings' => 1, |
|
14 | - 'glsr_create_review' => 2, |
|
15 | - 'glsr_debug' => 10, |
|
16 | - 'glsr_get' => 4, |
|
17 | - 'glsr_get_option' => 4, |
|
18 | - 'glsr_get_options' => 1, |
|
19 | - 'glsr_get_rating' => 2, |
|
20 | - 'glsr_get_review' => 2, |
|
21 | - 'glsr_get_reviews' => 2, |
|
22 | - 'glsr_log' => 3, |
|
23 | - 'glsr_star_rating' => 2, |
|
24 | - ); |
|
25 | - foreach ($hooks as $function => $acceptedArgs) { |
|
26 | - add_filter($function, function () use ($function) { |
|
27 | - $args = func_get_args(); |
|
28 | - array_shift($args); // remove the fallback value |
|
29 | - return call_user_func_array($function, $args); |
|
30 | - }, 10, $acceptedArgs); |
|
31 | - } |
|
12 | + $hooks = array( |
|
13 | + 'glsr_calculate_ratings' => 1, |
|
14 | + 'glsr_create_review' => 2, |
|
15 | + 'glsr_debug' => 10, |
|
16 | + 'glsr_get' => 4, |
|
17 | + 'glsr_get_option' => 4, |
|
18 | + 'glsr_get_options' => 1, |
|
19 | + 'glsr_get_rating' => 2, |
|
20 | + 'glsr_get_review' => 2, |
|
21 | + 'glsr_get_reviews' => 2, |
|
22 | + 'glsr_log' => 3, |
|
23 | + 'glsr_star_rating' => 2, |
|
24 | + ); |
|
25 | + foreach ($hooks as $function => $acceptedArgs) { |
|
26 | + add_filter($function, function () use ($function) { |
|
27 | + $args = func_get_args(); |
|
28 | + array_shift($args); // remove the fallback value |
|
29 | + return call_user_func_array($function, $args); |
|
30 | + }, 10, $acceptedArgs); |
|
31 | + } |
|
32 | 32 | }); |
33 | 33 | |
34 | 34 | /** |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function glsr($alias = null) |
38 | 38 | { |
39 | - $app = \GeminiLabs\SiteReviews\Application::load(); |
|
40 | - return !is_null($alias) |
|
41 | - ? $app->make($alias) |
|
42 | - : $app; |
|
39 | + $app = \GeminiLabs\SiteReviews\Application::load(); |
|
40 | + return !is_null($alias) |
|
41 | + ? $app->make($alias) |
|
42 | + : $app; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,15 +49,15 @@ discard block |
||
49 | 49 | */ |
50 | 50 | function glsr_array_column(array $array, $column) |
51 | 51 | { |
52 | - $result = array(); |
|
53 | - foreach ($array as $subarray) { |
|
54 | - $subarray = (array) $subarray; |
|
55 | - if (!isset($subarray[$column])) { |
|
56 | - continue; |
|
57 | - } |
|
58 | - $result[] = $subarray[$column]; |
|
59 | - } |
|
60 | - return $result; |
|
52 | + $result = array(); |
|
53 | + foreach ($array as $subarray) { |
|
54 | + $subarray = (array) $subarray; |
|
55 | + if (!isset($subarray[$column])) { |
|
56 | + continue; |
|
57 | + } |
|
58 | + $result[] = $subarray[$column]; |
|
59 | + } |
|
60 | + return $result; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | */ |
66 | 66 | function glsr_calculate_ratings() |
67 | 67 | { |
68 | - glsr('Database\CountsManager')->updateAll(); |
|
69 | - glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
68 | + glsr('Database\CountsManager')->updateAll(); |
|
69 | + glsr_log()->notice(__('Recalculated rating counts.', 'site-reviews')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | */ |
75 | 75 | function glsr_create_review($reviewValues = array()) |
76 | 76 | { |
77 | - $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
78 | - \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
79 | - ); |
|
80 | - return glsr('Database\ReviewManager')->create($review); |
|
77 | + $review = new \GeminiLabs\SiteReviews\Commands\CreateReview( |
|
78 | + \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($reviewValues) |
|
79 | + ); |
|
80 | + return glsr('Database\ReviewManager')->create($review); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function glsr_current_screen() |
87 | 87 | { |
88 | - if (function_exists('get_current_screen')) { |
|
89 | - $screen = get_current_screen(); |
|
90 | - } |
|
91 | - return empty($screen) |
|
92 | - ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
93 | - : $screen; |
|
88 | + if (function_exists('get_current_screen')) { |
|
89 | + $screen = get_current_screen(); |
|
90 | + } |
|
91 | + return empty($screen) |
|
92 | + ? (object) array_fill_keys(['base', 'id', 'post_type'], null) |
|
93 | + : $screen; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | */ |
100 | 100 | function glsr_debug(...$vars) |
101 | 101 | { |
102 | - if (1 == count($vars)) { |
|
103 | - $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
104 | - printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
105 | - } else { |
|
106 | - echo '<div class="glsr-debug-group">'; |
|
107 | - foreach ($vars as $var) { |
|
108 | - glsr_debug($var); |
|
109 | - } |
|
110 | - echo '</div>'; |
|
111 | - } |
|
102 | + if (1 == count($vars)) { |
|
103 | + $value = htmlspecialchars(print_r($vars[0], true), ENT_QUOTES, 'UTF-8'); |
|
104 | + printf('<div class="glsr-debug"><pre>%s</pre></div>', $value); |
|
105 | + } else { |
|
106 | + echo '<div class="glsr-debug-group">'; |
|
107 | + foreach ($vars as $var) { |
|
108 | + glsr_debug($var); |
|
109 | + } |
|
110 | + echo '</div>'; |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function glsr_get($array, $path = '', $fallback = '') |
121 | 121 | { |
122 | - return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
122 | + return \GeminiLabs\SiteReviews\Helpers\Arr::get($array, $path, $fallback); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | */ |
131 | 131 | function glsr_get_option($path = '', $fallback = '', $cast = '') |
132 | 132 | { |
133 | - return is_string($path) |
|
134 | - ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
135 | - : $fallback; |
|
133 | + return is_string($path) |
|
134 | + ? glsr('Database\OptionManager')->get(\GeminiLabs\SiteReviews\Helpers\Str::prefix('settings.', $path), $fallback, $cast) |
|
135 | + : $fallback; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function glsr_get_options() |
142 | 142 | { |
143 | - return glsr('Database\OptionManager')->get('settings'); |
|
143 | + return glsr('Database\OptionManager')->get('settings'); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function glsr_get_rating($args = array()) |
150 | 150 | { |
151 | - $args = \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args); |
|
152 | - $counts = glsr('Database\ReviewManager')->getRatingCounts($args); |
|
153 | - return (object) array( |
|
154 | - 'average' => glsr('Modules\Rating')->getAverage($counts), |
|
155 | - 'maximum' => glsr()->constant('MAX_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
156 | - 'minimum' => glsr()->constant('MIN_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
157 | - 'ratings' => $counts, |
|
158 | - 'reviews' => array_sum($counts), |
|
159 | - ); |
|
151 | + $args = \GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args); |
|
152 | + $counts = glsr('Database\ReviewManager')->getRatingCounts($args); |
|
153 | + return (object) array( |
|
154 | + 'average' => glsr('Modules\Rating')->getAverage($counts), |
|
155 | + 'maximum' => glsr()->constant('MAX_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
156 | + 'minimum' => glsr()->constant('MIN_RATING', \GeminiLabs\SiteReviews\Modules\Rating::class), |
|
157 | + 'ratings' => $counts, |
|
158 | + 'reviews' => array_sum($counts), |
|
159 | + ); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | */ |
166 | 166 | function glsr_get_review($post) |
167 | 167 | { |
168 | - if (is_numeric($post)) { |
|
169 | - $post = get_post($post); |
|
170 | - } |
|
171 | - if (!($post instanceof WP_Post)) { |
|
172 | - $post = new WP_Post((object) []); |
|
173 | - } |
|
174 | - return glsr('Database\ReviewManager')->single($post); |
|
168 | + if (is_numeric($post)) { |
|
169 | + $post = get_post($post); |
|
170 | + } |
|
171 | + if (!($post instanceof WP_Post)) { |
|
172 | + $post = new WP_Post((object) []); |
|
173 | + } |
|
174 | + return glsr('Database\ReviewManager')->single($post); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | function glsr_get_reviews($args = array()) |
181 | 181 | { |
182 | - return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
182 | + return glsr('Database\ReviewManager')->get(\GeminiLabs\SiteReviews\Helpers\Arr::consolidateArray($args)); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function glsr_log() |
189 | 189 | { |
190 | - $args = func_get_args(); |
|
191 | - $console = glsr('Modules\Console'); |
|
192 | - if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
193 | - return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
194 | - } |
|
195 | - return $console; |
|
190 | + $args = func_get_args(); |
|
191 | + $console = glsr('Modules\Console'); |
|
192 | + if ($value = \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '0')) { |
|
193 | + return $console->debug($value, \GeminiLabs\SiteReviews\Helpers\Arr::get($args, '1', [])); |
|
194 | + } |
|
195 | + return $console; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -200,5 +200,5 @@ discard block |
||
200 | 200 | */ |
201 | 201 | function glsr_star_rating($rating) |
202 | 202 | { |
203 | - return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
203 | + return glsr('Modules\Html\Partial')->build('star-rating', ['rating' => $rating]); |
|
204 | 204 | } |
@@ -8,47 +8,47 @@ discard block |
||
8 | 8 | |
9 | 9 | class SqlQueries |
10 | 10 | { |
11 | - protected $db; |
|
12 | - protected $postType; |
|
11 | + protected $db; |
|
12 | + protected $postType; |
|
13 | 13 | |
14 | - public function __construct() |
|
15 | - { |
|
16 | - global $wpdb; |
|
17 | - $this->db = $wpdb; |
|
18 | - $this->postType = Application::POST_TYPE; |
|
19 | - } |
|
14 | + public function __construct() |
|
15 | + { |
|
16 | + global $wpdb; |
|
17 | + $this->db = $wpdb; |
|
18 | + $this->postType = Application::POST_TYPE; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @return bool |
|
23 | - */ |
|
24 | - public function deletePostCountMetaKeys() |
|
25 | - { |
|
26 | - return $this->db->query(" |
|
21 | + /** |
|
22 | + * @return bool |
|
23 | + */ |
|
24 | + public function deletePostCountMetaKeys() |
|
25 | + { |
|
26 | + return $this->db->query(" |
|
27 | 27 | DELETE |
28 | 28 | FROM {$this->db->postmeta} |
29 | 29 | WHERE meta_key LIKE '_glsr_%' |
30 | 30 | "); |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function deleteTermCountMetaKeys() |
|
37 | - { |
|
38 | - return $this->db->query(" |
|
33 | + /** |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function deleteTermCountMetaKeys() |
|
37 | + { |
|
38 | + return $this->db->query(" |
|
39 | 39 | DELETE |
40 | 40 | FROM {$this->db->termmeta} |
41 | 41 | WHERE meta_key LIKE '_glsr_%' |
42 | 42 | "); |
43 | - } |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param string $metaReviewId |
|
47 | - * @return int |
|
48 | - */ |
|
49 | - public function getPostIdFromReviewId($metaReviewId) |
|
50 | - { |
|
51 | - $postId = $this->db->get_var(" |
|
45 | + /** |
|
46 | + * @param string $metaReviewId |
|
47 | + * @return int |
|
48 | + */ |
|
49 | + public function getPostIdFromReviewId($metaReviewId) |
|
50 | + { |
|
51 | + $postId = $this->db->get_var(" |
|
52 | 52 | SELECT p.ID |
53 | 53 | FROM {$this->db->posts} AS p |
54 | 54 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -56,17 +56,17 @@ discard block |
||
56 | 56 | AND m.meta_key = '_review_id' |
57 | 57 | AND m.meta_value = '{$metaReviewId}' |
58 | 58 | "); |
59 | - return intval($postId); |
|
60 | - } |
|
59 | + return intval($postId); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * @param int $lastPostId |
|
64 | - * @param int $limit |
|
65 | - * @return array |
|
66 | - */ |
|
67 | - public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500) |
|
68 | - { |
|
69 | - return (array) $this->db->get_results(" |
|
62 | + /** |
|
63 | + * @param int $lastPostId |
|
64 | + * @param int $limit |
|
65 | + * @return array |
|
66 | + */ |
|
67 | + public function getReviewCounts(array $args, $lastPostId = 0, $limit = 500) |
|
68 | + { |
|
69 | + return (array) $this->db->get_results(" |
|
70 | 70 | SELECT DISTINCT p.ID, m1.meta_value AS rating, m2.meta_value AS type |
71 | 71 | FROM {$this->db->posts} AS p |
72 | 72 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -81,17 +81,17 @@ discard block |
||
81 | 81 | ORDER By p.ID ASC |
82 | 82 | LIMIT {$limit} |
83 | 83 | "); |
84 | - } |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @todo remove this? |
|
88 | - * @param string $metaKey |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public function getReviewCountsFor($metaKey) |
|
92 | - { |
|
93 | - $metaKey = Str::prefix('_', $metaKey); |
|
94 | - return (array) $this->db->get_results(" |
|
86 | + /** |
|
87 | + * @todo remove this? |
|
88 | + * @param string $metaKey |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public function getReviewCountsFor($metaKey) |
|
92 | + { |
|
93 | + $metaKey = Str::prefix('_', $metaKey); |
|
94 | + return (array) $this->db->get_results(" |
|
95 | 95 | SELECT DISTINCT m.meta_value AS name, COUNT(*) num_posts |
96 | 96 | FROM {$this->db->posts} AS p |
97 | 97 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | AND m.meta_key = '{$metaKey}' |
100 | 100 | GROUP BY name |
101 | 101 | "); |
102 | - } |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @todo remove this? |
|
106 | - * @param string $reviewType |
|
107 | - * @return array |
|
108 | - */ |
|
109 | - public function getReviewIdsByType($reviewType) |
|
110 | - { |
|
111 | - $results = $this->db->get_col(" |
|
104 | + /** |
|
105 | + * @todo remove this? |
|
106 | + * @param string $reviewType |
|
107 | + * @return array |
|
108 | + */ |
|
109 | + public function getReviewIdsByType($reviewType) |
|
110 | + { |
|
111 | + $results = $this->db->get_col(" |
|
112 | 112 | SELECT DISTINCT m1.meta_value AS review_id |
113 | 113 | FROM {$this->db->posts} AS p |
114 | 114 | INNER JOIN {$this->db->postmeta} AS m1 ON p.ID = m1.post_id |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | AND m2.meta_key = '_review_type' |
119 | 119 | AND m2.meta_value = '{$reviewType}' |
120 | 120 | "); |
121 | - return array_keys(array_flip($results)); |
|
122 | - } |
|
121 | + return array_keys(array_flip($results)); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @param int $greaterThanId |
|
126 | - * @param int $limit |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100) |
|
130 | - { |
|
131 | - sort($postIds); |
|
132 | - $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit); |
|
133 | - $postIds = implode(',', $postIds); |
|
134 | - return (array) $this->db->get_results(" |
|
124 | + /** |
|
125 | + * @param int $greaterThanId |
|
126 | + * @param int $limit |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public function getReviewRatingsFromIds(array $postIds, $greaterThanId = 0, $limit = 100) |
|
130 | + { |
|
131 | + sort($postIds); |
|
132 | + $postIds = array_slice($postIds, intval(array_search($greaterThanId, $postIds)), $limit); |
|
133 | + $postIds = implode(',', $postIds); |
|
134 | + return (array) $this->db->get_results(" |
|
135 | 135 | SELECT p.ID, m.meta_value AS rating |
136 | 136 | FROM {$this->db->posts} AS p |
137 | 137 | INNER JOIN {$this->db->postmeta} AS m ON p.ID = m.post_id |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | ORDER By p.ID ASC |
145 | 145 | LIMIT {$limit} |
146 | 146 | "); |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
150 | - * @param string $key |
|
151 | - * @param string $status |
|
152 | - * @return array |
|
153 | - */ |
|
154 | - public function getReviewsMeta($key, $status = 'publish') |
|
155 | - { |
|
156 | - $postStatusQuery = 'all' != $status && !empty($status) |
|
157 | - ? "AND p.post_status = '{$status}'" |
|
158 | - : ''; |
|
159 | - $key = Str::prefix('_', $key); |
|
160 | - $values = $this->db->get_col(" |
|
149 | + /** |
|
150 | + * @param string $key |
|
151 | + * @param string $status |
|
152 | + * @return array |
|
153 | + */ |
|
154 | + public function getReviewsMeta($key, $status = 'publish') |
|
155 | + { |
|
156 | + $postStatusQuery = 'all' != $status && !empty($status) |
|
157 | + ? "AND p.post_status = '{$status}'" |
|
158 | + : ''; |
|
159 | + $key = Str::prefix('_', $key); |
|
160 | + $values = $this->db->get_col(" |
|
161 | 161 | SELECT DISTINCT m.meta_value |
162 | 162 | FROM {$this->db->postmeta} m |
163 | 163 | LEFT JOIN {$this->db->posts} p ON p.ID = m.post_id |
@@ -168,42 +168,42 @@ discard block |
||
168 | 168 | GROUP BY p.ID -- remove duplicate meta_value entries |
169 | 169 | ORDER BY m.meta_id ASC -- sort by oldest meta_value |
170 | 170 | "); |
171 | - sort($values); |
|
172 | - return $values; |
|
173 | - } |
|
171 | + sort($values); |
|
172 | + return $values; |
|
173 | + } |
|
174 | 174 | |
175 | - /** |
|
176 | - * @param string $and |
|
177 | - * @return string |
|
178 | - */ |
|
179 | - protected function getAndForCounts(array $args, $and = '') |
|
180 | - { |
|
181 | - $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', []))); |
|
182 | - $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', []))); |
|
183 | - if (!empty($args['type'])) { |
|
184 | - $and.= "AND m2.meta_value = '{$args['type']}' "; |
|
185 | - } |
|
186 | - if ($postIds) { |
|
187 | - $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
188 | - } |
|
189 | - if ($termIds) { |
|
190 | - $and.= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
191 | - } |
|
192 | - return apply_filters('site-reviews/query/and-for-counts', $and); |
|
193 | - } |
|
175 | + /** |
|
176 | + * @param string $and |
|
177 | + * @return string |
|
178 | + */ |
|
179 | + protected function getAndForCounts(array $args, $and = '') |
|
180 | + { |
|
181 | + $postIds = implode(',', array_filter(Arr::get($args, 'post_ids', []))); |
|
182 | + $termIds = implode(',', array_filter(Arr::get($args, 'term_ids', []))); |
|
183 | + if (!empty($args['type'])) { |
|
184 | + $and.= "AND m2.meta_value = '{$args['type']}' "; |
|
185 | + } |
|
186 | + if ($postIds) { |
|
187 | + $and.= "AND m3.meta_key = '_assigned_to' AND m3.meta_value IN ({$postIds}) "; |
|
188 | + } |
|
189 | + if ($termIds) { |
|
190 | + $and.= "AND tr.term_taxonomy_id IN ({$termIds}) "; |
|
191 | + } |
|
192 | + return apply_filters('site-reviews/query/and-for-counts', $and); |
|
193 | + } |
|
194 | 194 | |
195 | - /** |
|
196 | - * @param string $innerJoin |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - protected function getInnerJoinForCounts(array $args, $innerJoin = '') |
|
200 | - { |
|
201 | - if (!empty(Arr::get($args, 'post_ids'))) { |
|
202 | - $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
203 | - } |
|
204 | - if (!empty(Arr::get($args, 'term_ids'))) { |
|
205 | - $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
206 | - } |
|
207 | - return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin); |
|
208 | - } |
|
195 | + /** |
|
196 | + * @param string $innerJoin |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + protected function getInnerJoinForCounts(array $args, $innerJoin = '') |
|
200 | + { |
|
201 | + if (!empty(Arr::get($args, 'post_ids'))) { |
|
202 | + $innerJoin.= "INNER JOIN {$this->db->postmeta} AS m3 ON p.ID = m3.post_id "; |
|
203 | + } |
|
204 | + if (!empty(Arr::get($args, 'term_ids'))) { |
|
205 | + $innerJoin.= "INNER JOIN {$this->db->term_relationships} AS tr ON p.ID = tr.object_id "; |
|
206 | + } |
|
207 | + return apply_filters('site-reviews/query/inner-join-for-counts', $innerJoin); |
|
208 | + } |
|
209 | 209 | } |
@@ -9,91 +9,91 @@ |
||
9 | 9 | |
10 | 10 | class TermCountsManager |
11 | 11 | { |
12 | - /** |
|
13 | - * @var CountsManager |
|
14 | - */ |
|
15 | - protected $manager; |
|
12 | + /** |
|
13 | + * @var CountsManager |
|
14 | + */ |
|
15 | + protected $manager; |
|
16 | 16 | |
17 | - public function __construct() |
|
18 | - { |
|
19 | - $this->manager = glsr(CountsManager::class); |
|
20 | - } |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + $this->manager = glsr(CountsManager::class); |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param int $termTaxonomyId |
|
24 | - * @return array |
|
25 | - */ |
|
26 | - public function build($termTaxonomyId) |
|
27 | - { |
|
28 | - return $this->manager->buildCounts([ |
|
29 | - 'term_ids' => [$termTaxonomyId], |
|
30 | - ]); |
|
31 | - } |
|
22 | + /** |
|
23 | + * @param int $termTaxonomyId |
|
24 | + * @return array |
|
25 | + */ |
|
26 | + public function build($termTaxonomyId) |
|
27 | + { |
|
28 | + return $this->manager->buildCounts([ |
|
29 | + 'term_ids' => [$termTaxonomyId], |
|
30 | + ]); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function decrease(Review $review) |
|
37 | - { |
|
38 | - foreach ($review->term_ids as $termId) { |
|
39 | - if (empty($counts = $this->get($termId))) { |
|
40 | - continue; |
|
41 | - } |
|
42 | - $this->update($termId, |
|
43 | - $this->manager->decreaseRating($counts, $review->review_type, $review->rating) |
|
44 | - ); |
|
45 | - } |
|
46 | - } |
|
33 | + /** |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function decrease(Review $review) |
|
37 | + { |
|
38 | + foreach ($review->term_ids as $termId) { |
|
39 | + if (empty($counts = $this->get($termId))) { |
|
40 | + continue; |
|
41 | + } |
|
42 | + $this->update($termId, |
|
43 | + $this->manager->decreaseRating($counts, $review->review_type, $review->rating) |
|
44 | + ); |
|
45 | + } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @param int $termId |
|
50 | - * @return array |
|
51 | - */ |
|
52 | - public function get($termId) |
|
53 | - { |
|
54 | - return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true)); |
|
55 | - } |
|
48 | + /** |
|
49 | + * @param int $termId |
|
50 | + * @return array |
|
51 | + */ |
|
52 | + public function get($termId) |
|
53 | + { |
|
54 | + return array_filter((array) get_term_meta($termId, CountsManager::META_COUNT, true)); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return void |
|
59 | - */ |
|
60 | - public function increase(Review $review) |
|
61 | - { |
|
62 | - $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids)); |
|
63 | - foreach ($terms as $term) { |
|
64 | - $counts = $this->get($term['term_id']); |
|
65 | - $counts = empty($counts) |
|
66 | - ? $this->build($term['term_taxonomy_id']) |
|
67 | - : $this->manager->increaseRating($counts, $review->review_type, $review->rating); |
|
68 | - $this->update($term['term_id'], $counts); |
|
69 | - } |
|
70 | - } |
|
57 | + /** |
|
58 | + * @return void |
|
59 | + */ |
|
60 | + public function increase(Review $review) |
|
61 | + { |
|
62 | + $terms = glsr(ReviewManager::class)->normalizeTerms(implode(',', $review->term_ids)); |
|
63 | + foreach ($terms as $term) { |
|
64 | + $counts = $this->get($term['term_id']); |
|
65 | + $counts = empty($counts) |
|
66 | + ? $this->build($term['term_taxonomy_id']) |
|
67 | + : $this->manager->increaseRating($counts, $review->review_type, $review->rating); |
|
68 | + $this->update($term['term_id'], $counts); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param int $termId |
|
74 | - * @return void |
|
75 | - */ |
|
76 | - public function update($termId, array $reviewCounts) |
|
77 | - { |
|
78 | - $term = get_term($termId, Application::TAXONOMY); |
|
79 | - if (isset($term->term_id)) { |
|
80 | - $ratingCounts = $this->manager->flatten($reviewCounts); |
|
81 | - update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts); |
|
82 | - update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts)); |
|
83 | - update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts)); |
|
84 | - } |
|
85 | - } |
|
72 | + /** |
|
73 | + * @param int $termId |
|
74 | + * @return void |
|
75 | + */ |
|
76 | + public function update($termId, array $reviewCounts) |
|
77 | + { |
|
78 | + $term = get_term($termId, Application::TAXONOMY); |
|
79 | + if (isset($term->term_id)) { |
|
80 | + $ratingCounts = $this->manager->flatten($reviewCounts); |
|
81 | + update_term_meta($termId, CountsManager::META_COUNT, $reviewCounts); |
|
82 | + update_term_meta($termId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts)); |
|
83 | + update_term_meta($termId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts)); |
|
84 | + } |
|
85 | + } |
|
86 | 86 | |
87 | - /** |
|
88 | - * @return void |
|
89 | - */ |
|
90 | - public function updateAll() |
|
91 | - { |
|
92 | - $terms = glsr(Database::class)->getTerms([ |
|
93 | - 'fields' => 'all', |
|
94 | - ]); |
|
95 | - foreach ($terms as $term) { |
|
96 | - $this->update($term->term_id, $this->build($term->term_taxonomy_id)); |
|
97 | - } |
|
98 | - } |
|
87 | + /** |
|
88 | + * @return void |
|
89 | + */ |
|
90 | + public function updateAll() |
|
91 | + { |
|
92 | + $terms = glsr(Database::class)->getTerms([ |
|
93 | + 'fields' => 'all', |
|
94 | + ]); |
|
95 | + foreach ($terms as $term) { |
|
96 | + $this->update($term->term_id, $this->build($term->term_taxonomy_id)); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | } |
@@ -7,85 +7,85 @@ |
||
7 | 7 | |
8 | 8 | class PostCountsManager |
9 | 9 | { |
10 | - /** |
|
11 | - * @var CountsManager |
|
12 | - */ |
|
13 | - protected $manager; |
|
10 | + /** |
|
11 | + * @var CountsManager |
|
12 | + */ |
|
13 | + protected $manager; |
|
14 | 14 | |
15 | - public function __construct() |
|
16 | - { |
|
17 | - $this->manager = glsr(CountsManager::class); |
|
18 | - } |
|
15 | + public function __construct() |
|
16 | + { |
|
17 | + $this->manager = glsr(CountsManager::class); |
|
18 | + } |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param int $postId |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public function build($postId) |
|
25 | - { |
|
26 | - return $this->manager->buildCounts([ |
|
27 | - 'post_ids' => [$postId], |
|
28 | - ]); |
|
29 | - } |
|
20 | + /** |
|
21 | + * @param int $postId |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public function build($postId) |
|
25 | + { |
|
26 | + return $this->manager->buildCounts([ |
|
27 | + 'post_ids' => [$postId], |
|
28 | + ]); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return void |
|
33 | - */ |
|
34 | - public function decrease(Review $review) |
|
35 | - { |
|
36 | - if (empty($counts = $this->get($review->assigned_to))) { |
|
37 | - return; |
|
38 | - } |
|
39 | - $this->update($review->assigned_to, |
|
40 | - $this->manager->decreaseRating($counts, $review->review_type, $review->rating) |
|
41 | - ); |
|
42 | - } |
|
31 | + /** |
|
32 | + * @return void |
|
33 | + */ |
|
34 | + public function decrease(Review $review) |
|
35 | + { |
|
36 | + if (empty($counts = $this->get($review->assigned_to))) { |
|
37 | + return; |
|
38 | + } |
|
39 | + $this->update($review->assigned_to, |
|
40 | + $this->manager->decreaseRating($counts, $review->review_type, $review->rating) |
|
41 | + ); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param int $postId |
|
46 | - * @return array |
|
47 | - */ |
|
48 | - public function get($postId) |
|
49 | - { |
|
50 | - return array_filter((array) get_post_meta($postId, CountsManager::META_COUNT, true)); |
|
51 | - } |
|
44 | + /** |
|
45 | + * @param int $postId |
|
46 | + * @return array |
|
47 | + */ |
|
48 | + public function get($postId) |
|
49 | + { |
|
50 | + return array_filter((array) get_post_meta($postId, CountsManager::META_COUNT, true)); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return void |
|
55 | - */ |
|
56 | - public function increase(Review $review) |
|
57 | - { |
|
58 | - if (!(get_post($review->assigned_to) instanceof \WP_Post)) { |
|
59 | - return; |
|
60 | - } |
|
61 | - $counts = $this->get($review->assigned_to); |
|
62 | - $counts = empty($counts) |
|
63 | - ? $this->build($review->assigned_to) |
|
64 | - : $this->manager->increaseRating($counts, $review->review_type, $review->rating); |
|
65 | - $this->update($review->assigned_to, $counts); |
|
66 | - } |
|
53 | + /** |
|
54 | + * @return void |
|
55 | + */ |
|
56 | + public function increase(Review $review) |
|
57 | + { |
|
58 | + if (!(get_post($review->assigned_to) instanceof \WP_Post)) { |
|
59 | + return; |
|
60 | + } |
|
61 | + $counts = $this->get($review->assigned_to); |
|
62 | + $counts = empty($counts) |
|
63 | + ? $this->build($review->assigned_to) |
|
64 | + : $this->manager->increaseRating($counts, $review->review_type, $review->rating); |
|
65 | + $this->update($review->assigned_to, $counts); |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @param int $postId |
|
70 | - * @return void |
|
71 | - */ |
|
72 | - public function update($postId, array $reviewCounts) |
|
73 | - { |
|
74 | - $ratingCounts = $this->manager->flatten($reviewCounts); |
|
75 | - update_post_meta($postId, CountsManager::META_COUNT, $reviewCounts); |
|
76 | - update_post_meta($postId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts)); |
|
77 | - update_post_meta($postId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts)); |
|
78 | - } |
|
68 | + /** |
|
69 | + * @param int $postId |
|
70 | + * @return void |
|
71 | + */ |
|
72 | + public function update($postId, array $reviewCounts) |
|
73 | + { |
|
74 | + $ratingCounts = $this->manager->flatten($reviewCounts); |
|
75 | + update_post_meta($postId, CountsManager::META_COUNT, $reviewCounts); |
|
76 | + update_post_meta($postId, CountsManager::META_AVERAGE, glsr(Rating::class)->getAverage($ratingCounts)); |
|
77 | + update_post_meta($postId, CountsManager::META_RANKING, glsr(Rating::class)->getRanking($ratingCounts)); |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function updateAll() |
|
84 | - { |
|
85 | - glsr(SqlQueries::class)->deletePostCountMetaKeys(); // @todo test this with SiteGround for race conditions |
|
86 | - $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to'); |
|
87 | - foreach ($postIds as $postId) { |
|
88 | - $this->update($postId, $this->build($postId)); |
|
89 | - } |
|
90 | - } |
|
80 | + /** |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function updateAll() |
|
84 | + { |
|
85 | + glsr(SqlQueries::class)->deletePostCountMetaKeys(); // @todo test this with SiteGround for race conditions |
|
86 | + $postIds = glsr(SqlQueries::class)->getReviewsMeta('assigned_to'); |
|
87 | + foreach ($postIds as $postId) { |
|
88 | + $this->update($postId, $this->build($postId)); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | } |
@@ -1,558 +1,558 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'settings.general.style' => [ |
|
5 | - 'default' => 'default', |
|
6 | - 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | - 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | - 'options' => [ |
|
9 | - 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | - 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | - 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | - 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | - 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | - 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | - 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | - 'divi' => 'Theme: Divi (v3)', |
|
17 | - 'materialize' => 'Theme: Materialize', |
|
18 | - 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | - 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | - 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | - ], |
|
22 | - 'type' => 'select', |
|
23 | - ], |
|
24 | - 'settings.general.require.approval' => [ |
|
25 | - 'default' => 'no', |
|
26 | - 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | - 'label' => __('Require Approval', 'site-reviews'), |
|
28 | - 'type' => 'yes_no', |
|
29 | - ], |
|
30 | - 'settings.general.require.login' => [ |
|
31 | - 'default' => 'no', |
|
32 | - 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | - 'label' => __('Require Login', 'site-reviews'), |
|
34 | - 'type' => 'yes_no', |
|
35 | - ], |
|
36 | - 'settings.general.require.login_register' => [ |
|
37 | - 'default' => 'no', |
|
38 | - 'depends_on' => [ |
|
39 | - 'settings.general.require.login' => 'yes', |
|
40 | - ], |
|
41 | - 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | - '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | - ), |
|
44 | - 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | - 'type' => 'yes_no', |
|
46 | - ], |
|
47 | - 'settings.general.multilingual' => [ |
|
48 | - 'default' => '', |
|
49 | - 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | - 'label' => __('Multilingual', 'site-reviews'), |
|
51 | - 'options' => [ |
|
52 | - '' => __('No Integration', 'site-reviews'), |
|
53 | - 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | - 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | - ], |
|
56 | - 'type' => 'select', |
|
57 | - ], |
|
58 | - 'settings.general.trustalyze' => [ |
|
59 | - 'default' => 'no', |
|
60 | - 'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | - '<a href="https://trustalyze.com/plans?ref=105" target="_blank">Trustalyze Confidence System</a>' |
|
62 | - ), |
|
63 | - 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | - 'type' => 'yes_no', |
|
65 | - ], |
|
66 | - 'settings.general.trustalyze_email' => [ |
|
67 | - 'default' => '', |
|
68 | - 'depends_on' => [ |
|
69 | - 'settings.general.trustalyze' => ['yes'], |
|
70 | - ], |
|
71 | - 'description' => __('Enter your Trustalyze account email here.', 'site-reviews'), |
|
72 | - 'label' => __('Trustalyze Email', 'site-reviews'), |
|
73 | - 'type' => 'text', |
|
74 | - ], |
|
75 | - 'settings.general.trustalyze_serial' => [ |
|
76 | - 'default' => '', |
|
77 | - 'depends_on' => [ |
|
78 | - 'settings.general.trustalyze' => ['yes'], |
|
79 | - ], |
|
80 | - 'description' => __('Enter your Trustalyze account serial key here.', 'site-reviews'), |
|
81 | - 'label' => __('Trustalyze Serial Key', 'site-reviews'), |
|
82 | - 'type' => 'password', |
|
83 | - ], |
|
84 | - 'settings.general.notifications' => [ |
|
85 | - 'default' => [], |
|
86 | - 'label' => __('Notifications', 'site-reviews'), |
|
87 | - 'options' => [ |
|
88 | - 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | - 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | - 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | - 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | - ], |
|
93 | - 'type' => 'checkbox', |
|
94 | - ], |
|
95 | - 'settings.general.notification_email' => [ |
|
96 | - 'default' => '', |
|
97 | - 'depends_on' => [ |
|
98 | - 'settings.general.notifications' => ['custom'], |
|
99 | - ], |
|
100 | - 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | - 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | - 'type' => 'text', |
|
103 | - ], |
|
104 | - 'settings.general.notification_slack' => [ |
|
105 | - 'default' => '', |
|
106 | - 'depends_on' => [ |
|
107 | - 'settings.general.notifications' => ['slack'], |
|
108 | - ], |
|
109 | - 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | - '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | - ), |
|
112 | - 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | - 'type' => 'text', |
|
114 | - ], |
|
115 | - 'settings.general.notification_message' => [ |
|
116 | - 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | - 'depends_on' => [ |
|
118 | - 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | - ], |
|
120 | - 'description' => __( |
|
121 | - 'To restore the default text, save an empty template. '. |
|
122 | - 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
123 | - '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | - '<br><code>{review_title}</code> The review title'. |
|
125 | - '<br><code>{review_content}</code> The review content'. |
|
126 | - '<br><code>{review_author}</code> The review author'. |
|
127 | - '<br><code>{review_email}</code> The email of the review author'. |
|
128 | - '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | - '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | - 'site-reviews' |
|
131 | - ), |
|
132 | - 'label' => __('Notification Template', 'site-reviews'), |
|
133 | - 'rows' => 10, |
|
134 | - 'type' => 'code', |
|
135 | - ], |
|
136 | - 'settings.reviews.date.format' => [ |
|
137 | - 'default' => '', |
|
138 | - 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | - '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | - ), |
|
141 | - 'label' => __('Date Format', 'site-reviews'), |
|
142 | - 'options' => [ |
|
143 | - '' => __('Use the default date format', 'site-reviews'), |
|
144 | - 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | - 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | - ], |
|
147 | - 'type' => 'select', |
|
148 | - ], |
|
149 | - 'settings.reviews.date.custom' => [ |
|
150 | - 'default' => get_option('date_format'), |
|
151 | - 'depends_on' => [ |
|
152 | - 'settings.reviews.date.format' => 'custom', |
|
153 | - ], |
|
154 | - 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
155 | - 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | - 'type' => 'text', |
|
157 | - ], |
|
158 | - 'settings.reviews.name.format' => [ |
|
159 | - 'default' => '', |
|
160 | - 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | - 'label' => __('Name Format', 'site-reviews'), |
|
162 | - 'options' => [ |
|
163 | - '' => __('Use the name as given', 'site-reviews'), |
|
164 | - 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | - 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | - 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | - 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | - ], |
|
169 | - 'type' => 'select', |
|
170 | - ], |
|
171 | - 'settings.reviews.name.initial' => [ |
|
172 | - 'default' => '', |
|
173 | - 'depends_on' => [ |
|
174 | - 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | - ], |
|
176 | - 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | - 'label' => __('Initial Format', 'site-reviews'), |
|
178 | - 'options' => [ |
|
179 | - '' => __('Initial with a space', 'site-reviews'), |
|
180 | - 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | - 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | - ], |
|
183 | - 'type' => 'select', |
|
184 | - ], |
|
185 | - 'settings.reviews.assigned_links' => [ |
|
186 | - 'default' => 'no', |
|
187 | - 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | - 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | - 'type' => 'yes_no', |
|
190 | - ], |
|
191 | - 'settings.reviews.avatars' => [ |
|
192 | - 'default' => 'no', |
|
193 | - 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | - 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | - 'type' => 'yes_no', |
|
196 | - ], |
|
197 | - 'settings.reviews.avatars_regenerate' => [ |
|
198 | - 'default' => 'no', |
|
199 | - 'depends_on' => [ |
|
200 | - 'settings.reviews.avatars' => 'yes', |
|
201 | - ], |
|
202 | - 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | - 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | - 'type' => 'yes_no', |
|
205 | - ], |
|
206 | - 'settings.reviews.avatars_size' => [ |
|
207 | - 'default' => 40, |
|
208 | - 'depends_on' => [ |
|
209 | - 'settings.reviews.avatars' => 'yes', |
|
210 | - ], |
|
211 | - 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | - 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | - 'type' => 'number', |
|
214 | - ], |
|
215 | - 'settings.reviews.excerpts' => [ |
|
216 | - 'default' => 'yes', |
|
217 | - 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | - 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | - 'type' => 'yes_no', |
|
220 | - ], |
|
221 | - 'settings.reviews.excerpts_length' => [ |
|
222 | - 'default' => 55, |
|
223 | - 'depends_on' => [ |
|
224 | - 'settings.reviews.excerpts' => 'yes', |
|
225 | - ], |
|
226 | - 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | - 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | - 'type' => 'number', |
|
229 | - ], |
|
230 | - 'settings.reviews.fallback' => [ |
|
231 | - 'default' => 'yes', |
|
232 | - 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
233 | - '<a href="'.admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | - '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | - ), |
|
236 | - 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | - 'type' => 'yes_no', |
|
238 | - ], |
|
239 | - 'settings.reviews.pagination.url_parameter' => [ |
|
240 | - 'default' => 'yes', |
|
241 | - 'description' => sprintf(_x('Use the <code>?%s={page_number}</code> URL parameter with AJAX pagination.', 'admin-text', 'site-reviews'), glsr()->constant('PAGED_QUERY_VAR')), |
|
242 | - 'label' => esc_html_x('Pagination URL Parameter', 'admin-text', 'site-reviews'), |
|
243 | - 'type' => 'yes_no', |
|
244 | - ], |
|
245 | - 'settings.schema.type.default' => [ |
|
246 | - 'default' => 'LocalBusiness', |
|
247 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
248 | - 'label' => __('Default Schema Type', 'site-reviews'), |
|
249 | - 'options' => [ |
|
250 | - 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
251 | - 'Product' => __('Product', 'site-reviews'), |
|
252 | - 'custom' => __('Custom', 'site-reviews'), |
|
253 | - ], |
|
254 | - 'type' => 'select', |
|
255 | - ], |
|
256 | - 'settings.schema.type.custom' => [ |
|
257 | - 'default' => '', |
|
258 | - 'depends_on' => [ |
|
259 | - 'settings.schema.type.default' => 'custom', |
|
260 | - ], |
|
261 | - 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
262 | - 'label' => __('Custom Schema Type', 'site-reviews'), |
|
263 | - 'type' => 'text', |
|
264 | - ], |
|
265 | - 'settings.schema.name.default' => [ |
|
266 | - 'default' => 'post', |
|
267 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
268 | - 'label' => __('Default Name', 'site-reviews'), |
|
269 | - 'options' => [ |
|
270 | - 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
271 | - 'custom' => __('Enter a custom title', 'site-reviews'), |
|
272 | - ], |
|
273 | - 'type' => 'select', |
|
274 | - ], |
|
275 | - 'settings.schema.name.custom' => [ |
|
276 | - 'default' => '', |
|
277 | - 'depends_on' => [ |
|
278 | - 'settings.schema.name.default' => 'custom', |
|
279 | - ], |
|
280 | - 'label' => __('Custom Name', 'site-reviews'), |
|
281 | - 'type' => 'text', |
|
282 | - ], |
|
283 | - 'settings.schema.description.default' => [ |
|
284 | - 'default' => 'post', |
|
285 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
286 | - 'label' => __('Default Description', 'site-reviews'), |
|
287 | - 'options' => [ |
|
288 | - 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
289 | - 'custom' => __('Enter a custom description', 'site-reviews'), |
|
290 | - ], |
|
291 | - 'type' => 'select', |
|
292 | - ], |
|
293 | - 'settings.schema.description.custom' => [ |
|
294 | - 'default' => '', |
|
295 | - 'depends_on' => [ |
|
296 | - 'settings.schema.description.default' => 'custom', |
|
297 | - ], |
|
298 | - 'label' => __('Custom Description', 'site-reviews'), |
|
299 | - 'type' => 'text', |
|
300 | - ], |
|
301 | - 'settings.schema.url.default' => [ |
|
302 | - 'default' => 'post', |
|
303 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
304 | - 'label' => __('Default URL', 'site-reviews'), |
|
305 | - 'options' => [ |
|
306 | - 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
307 | - 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
308 | - ], |
|
309 | - 'type' => 'select', |
|
310 | - ], |
|
311 | - 'settings.schema.url.custom' => [ |
|
312 | - 'default' => '', |
|
313 | - 'depends_on' => [ |
|
314 | - 'settings.schema.url.default' => 'custom', |
|
315 | - ], |
|
316 | - 'label' => __('Custom URL', 'site-reviews'), |
|
317 | - 'type' => 'text', |
|
318 | - ], |
|
319 | - 'settings.schema.image.default' => [ |
|
320 | - 'default' => 'post', |
|
321 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
322 | - 'label' => __('Default Image', 'site-reviews'), |
|
323 | - 'options' => [ |
|
324 | - 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
325 | - 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
326 | - ], |
|
327 | - 'type' => 'select', |
|
328 | - ], |
|
329 | - 'settings.schema.image.custom' => [ |
|
330 | - 'default' => '', |
|
331 | - 'depends_on' => [ |
|
332 | - 'settings.schema.image.default' => 'custom', |
|
333 | - ], |
|
334 | - 'label' => __('Custom Image URL', 'site-reviews'), |
|
335 | - 'type' => 'text', |
|
336 | - ], |
|
337 | - 'settings.schema.address' => [ |
|
338 | - 'default' => '', |
|
339 | - 'depends_on' => [ |
|
340 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
341 | - ], |
|
342 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
343 | - 'label' => __('Address', 'site-reviews'), |
|
344 | - 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
345 | - 'type' => 'text', |
|
346 | - ], |
|
347 | - 'settings.schema.telephone' => [ |
|
348 | - 'default' => '', |
|
349 | - 'depends_on' => [ |
|
350 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
351 | - ], |
|
352 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
353 | - 'label' => __('Telephone Number', 'site-reviews'), |
|
354 | - 'placeholder' => '+1 (877) 273-3049', |
|
355 | - 'type' => 'text', |
|
356 | - ], |
|
357 | - 'settings.schema.pricerange' => [ |
|
358 | - 'default' => '', |
|
359 | - 'depends_on' => [ |
|
360 | - 'settings.schema.type.default' => 'LocalBusiness', |
|
361 | - ], |
|
362 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
363 | - 'label' => __('Price Range', 'site-reviews'), |
|
364 | - 'placeholder' => '$$-$$$', |
|
365 | - 'type' => 'text', |
|
366 | - ], |
|
367 | - 'settings.schema.offertype' => [ |
|
368 | - 'default' => 'AggregateOffer', |
|
369 | - 'depends_on' => [ |
|
370 | - 'settings.schema.type.default' => 'Product', |
|
371 | - ], |
|
372 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
373 | - 'label' => __('Offer Type', 'site-reviews'), |
|
374 | - 'options' => [ |
|
375 | - 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
376 | - 'Offer' => __('Offer', 'site-reviews'), |
|
377 | - ], |
|
378 | - 'type' => 'select', |
|
379 | - ], |
|
380 | - 'settings.schema.price' => [ |
|
381 | - 'default' => '', |
|
382 | - 'depends_on' => [ |
|
383 | - 'settings.schema.type.default' => 'Product', |
|
384 | - 'settings.schema.offertype' => 'Offer', |
|
385 | - ], |
|
386 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
387 | - 'label' => __('Price', 'site-reviews'), |
|
388 | - 'placeholder' => '50.00', |
|
389 | - 'type' => 'text', |
|
390 | - ], |
|
391 | - 'settings.schema.lowprice' => [ |
|
392 | - 'default' => '', |
|
393 | - 'depends_on' => [ |
|
394 | - 'settings.schema.type.default' => 'Product', |
|
395 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
396 | - ], |
|
397 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
398 | - 'label' => __('Low Price', 'site-reviews'), |
|
399 | - 'placeholder' => '10.00', |
|
400 | - 'type' => 'text', |
|
401 | - ], |
|
402 | - 'settings.schema.highprice' => [ |
|
403 | - 'default' => '', |
|
404 | - 'depends_on' => [ |
|
405 | - 'settings.schema.type.default' => 'Product', |
|
406 | - 'settings.schema.offertype' => 'AggregateOffer', |
|
407 | - ], |
|
408 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
409 | - 'label' => __('High Price', 'site-reviews'), |
|
410 | - 'placeholder' => '100.00', |
|
411 | - 'type' => 'text', |
|
412 | - ], |
|
413 | - 'settings.schema.pricecurrency' => [ |
|
414 | - 'default' => '', |
|
415 | - 'depends_on' => [ |
|
416 | - 'settings.schema.type.default' => 'Product', |
|
417 | - ], |
|
418 | - 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
419 | - 'label' => __('Price Currency', 'site-reviews'), |
|
420 | - 'placeholder' => 'USD', |
|
421 | - 'type' => 'text', |
|
422 | - ], |
|
423 | - 'settings.submissions.required' => [ |
|
424 | - 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
425 | - 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
426 | - 'label' => __('Required Fields', 'site-reviews'), |
|
427 | - 'options' => [ |
|
428 | - 'rating' => __('Rating', 'site-reviews'), |
|
429 | - 'title' => __('Title', 'site-reviews'), |
|
430 | - 'content' => __('Review', 'site-reviews'), |
|
431 | - 'name' => __('Name', 'site-reviews'), |
|
432 | - 'email' => __('Email', 'site-reviews'), |
|
433 | - 'terms' => __('Terms', 'site-reviews'), |
|
434 | - ], |
|
435 | - 'type' => 'checkbox', |
|
436 | - ], |
|
437 | - 'settings.submissions.limit' => [ |
|
438 | - 'default' => '', |
|
439 | - 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
440 | - 'label' => __('Limit Reviews', 'site-reviews'), |
|
441 | - 'options' => [ |
|
442 | - '' => __('No Limit', 'site-reviews'), |
|
443 | - 'email' => __('By Email Address', 'site-reviews'), |
|
444 | - 'ip_address' => __('By IP Address', 'site-reviews'), |
|
445 | - 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
446 | - ], |
|
447 | - 'type' => 'select', |
|
448 | - ], |
|
449 | - 'settings.submissions.limit_whitelist.email' => [ |
|
450 | - 'default' => '', |
|
451 | - 'depends_on' => [ |
|
452 | - 'settings.submissions.limit' => ['email'], |
|
453 | - ], |
|
454 | - 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
455 | - 'label' => __('Email Whitelist', 'site-reviews'), |
|
456 | - 'rows' => 5, |
|
457 | - 'type' => 'code', |
|
458 | - ], |
|
459 | - 'settings.submissions.limit_whitelist.ip_address' => [ |
|
460 | - 'default' => '', |
|
461 | - 'depends_on' => [ |
|
462 | - 'settings.submissions.limit' => ['ip_address'], |
|
463 | - ], |
|
464 | - 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
465 | - 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
466 | - 'rows' => 5, |
|
467 | - 'type' => 'code', |
|
468 | - ], |
|
469 | - 'settings.submissions.limit_whitelist.username' => [ |
|
470 | - 'default' => '', |
|
471 | - 'depends_on' => [ |
|
472 | - 'settings.submissions.limit' => ['username'], |
|
473 | - ], |
|
474 | - 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
475 | - 'label' => __('Username Whitelist', 'site-reviews'), |
|
476 | - 'rows' => 5, |
|
477 | - 'type' => 'code', |
|
478 | - ], |
|
479 | - 'settings.submissions.recaptcha.integration' => [ |
|
480 | - 'default' => '', |
|
481 | - 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
482 | - 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
483 | - 'options' => [ |
|
484 | - '' => 'Do not use reCAPTCHA', |
|
485 | - 'all' => 'Use reCAPTCHA', |
|
486 | - 'guest' => 'Use reCAPTCHA only for guest users', |
|
487 | - ], |
|
488 | - 'type' => 'select', |
|
489 | - ], |
|
490 | - 'settings.submissions.recaptcha.key' => [ |
|
491 | - 'default' => '', |
|
492 | - 'depends_on' => [ |
|
493 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
494 | - ], |
|
495 | - 'label' => __('Site Key', 'site-reviews'), |
|
496 | - 'type' => 'text', |
|
497 | - ], |
|
498 | - 'settings.submissions.recaptcha.secret' => [ |
|
499 | - 'default' => '', |
|
500 | - 'depends_on' => [ |
|
501 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
502 | - ], |
|
503 | - 'label' => __('Site Secret', 'site-reviews'), |
|
504 | - 'type' => 'text', |
|
505 | - ], |
|
506 | - 'settings.submissions.recaptcha.position' => [ |
|
507 | - 'default' => 'bottomleft', |
|
508 | - 'depends_on' => [ |
|
509 | - 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
510 | - ], |
|
511 | - 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
512 | - 'label' => __('Badge Position', 'site-reviews'), |
|
513 | - 'options' => [ |
|
514 | - 'bottomleft' => 'Bottom Left', |
|
515 | - 'bottomright' => 'Bottom Right', |
|
516 | - 'inline' => 'Inline', |
|
517 | - ], |
|
518 | - 'type' => 'select', |
|
519 | - ], |
|
520 | - 'settings.submissions.akismet' => [ |
|
521 | - 'default' => 'no', |
|
522 | - 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
523 | - 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
524 | - 'type' => 'yes_no', |
|
525 | - ], |
|
526 | - 'settings.submissions.blacklist.integration' => [ |
|
527 | - 'default' => '', |
|
528 | - 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
529 | - '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
530 | - ), |
|
531 | - 'label' => __('Blacklist', 'site-reviews'), |
|
532 | - 'options' => [ |
|
533 | - '' => 'Use the Site Reviews Blacklist', |
|
534 | - 'comments' => 'Use the WordPress Comment Blacklist', |
|
535 | - ], |
|
536 | - 'type' => 'select', |
|
537 | - ], |
|
538 | - 'settings.submissions.blacklist.entries' => [ |
|
539 | - 'default' => '', |
|
540 | - 'depends_on' => [ |
|
541 | - 'settings.submissions.blacklist.integration' => [''], |
|
542 | - ], |
|
543 | - 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
544 | - 'label' => __('Review Blacklist', 'site-reviews'), |
|
545 | - 'rows' => 10, |
|
546 | - 'type' => 'code', |
|
547 | - ], |
|
548 | - 'settings.submissions.blacklist.action' => [ |
|
549 | - 'default' => 'unapprove', |
|
550 | - 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
551 | - 'label' => __('Blacklist Action', 'site-reviews'), |
|
552 | - 'options' => [ |
|
553 | - 'unapprove' => __('Require approval', 'site-reviews'), |
|
554 | - 'reject' => __('Reject submission', 'site-reviews'), |
|
555 | - ], |
|
556 | - 'type' => 'select', |
|
557 | - ], |
|
4 | + 'settings.general.style' => [ |
|
5 | + 'default' => 'default', |
|
6 | + 'description' => __('Site Reviews relies on the CSS of your theme to style the submission form. If your theme does not provide proper CSS rules for form elements and you are using a WordPress plugin/theme or CSS Framework listed here, please try selecting it, otherwise choose "Site Reviews (default)".', 'site-reviews'), |
|
7 | + 'label' => __('Plugin Style', 'site-reviews'), |
|
8 | + 'options' => [ |
|
9 | + 'bootstrap_4' => 'CSS Framework: Bootstrap 4', |
|
10 | + 'bootstrap_4_custom' => 'CSS Framework: Bootstrap 4 (Custom Forms)', |
|
11 | + 'contact_form_7' => 'Plugin: Contact Form 7 (v5)', |
|
12 | + 'ninja_forms' => 'Plugin: Ninja Forms (v3)', |
|
13 | + 'wpforms' => 'Plugin: WPForms Lite (v1)', |
|
14 | + 'default' => __('Site Reviews (default)', 'site-reviews'), |
|
15 | + 'minimal' => __('Site Reviews (minimal)', 'site-reviews'), |
|
16 | + 'divi' => 'Theme: Divi (v3)', |
|
17 | + 'materialize' => 'Theme: Materialize', |
|
18 | + 'twentyfifteen' => 'Theme: Twenty Fifteen', |
|
19 | + 'twentyseventeen' => 'Theme: Twenty Seventeen', |
|
20 | + 'twentynineteen' => 'Theme: Twenty Nineteen', |
|
21 | + ], |
|
22 | + 'type' => 'select', |
|
23 | + ], |
|
24 | + 'settings.general.require.approval' => [ |
|
25 | + 'default' => 'no', |
|
26 | + 'description' => __('Set the status of new review submissions to "unapproved".', 'site-reviews'), |
|
27 | + 'label' => __('Require Approval', 'site-reviews'), |
|
28 | + 'type' => 'yes_no', |
|
29 | + ], |
|
30 | + 'settings.general.require.login' => [ |
|
31 | + 'default' => 'no', |
|
32 | + 'description' => __('Only allow review submissions from registered users.', 'site-reviews'), |
|
33 | + 'label' => __('Require Login', 'site-reviews'), |
|
34 | + 'type' => 'yes_no', |
|
35 | + ], |
|
36 | + 'settings.general.require.login_register' => [ |
|
37 | + 'default' => 'no', |
|
38 | + 'depends_on' => [ |
|
39 | + 'settings.general.require.login' => 'yes', |
|
40 | + ], |
|
41 | + 'description' => sprintf(__('Show a link for a new user to register. The %s Membership option must be enabled in General Settings for this to work.', 'site-reviews'), |
|
42 | + '<a href="'.admin_url('options-general.php#users_can_register').'">'.__('Anyone can register', 'site-reviews').'</a>' |
|
43 | + ), |
|
44 | + 'label' => __('Show Registration Link', 'site-reviews'), |
|
45 | + 'type' => 'yes_no', |
|
46 | + ], |
|
47 | + 'settings.general.multilingual' => [ |
|
48 | + 'default' => '', |
|
49 | + 'description' => __('Integrate with a multilingual plugin to calculate ratings for all languages of a post.', 'site-reviews'), |
|
50 | + 'label' => __('Multilingual', 'site-reviews'), |
|
51 | + 'options' => [ |
|
52 | + '' => __('No Integration', 'site-reviews'), |
|
53 | + 'polylang' => __('Integrate with Polylang', 'site-reviews'), |
|
54 | + 'wpml' => __('Integrate with WPML', 'site-reviews'), |
|
55 | + ], |
|
56 | + 'type' => 'select', |
|
57 | + ], |
|
58 | + 'settings.general.trustalyze' => [ |
|
59 | + 'default' => 'no', |
|
60 | + 'description' => sprintf(__('Integrate with the %s and validate your reviews on the blockchain to increase online reputation, trust, and transparency.', 'site-reviews'), |
|
61 | + '<a href="https://trustalyze.com/plans?ref=105" target="_blank">Trustalyze Confidence System</a>' |
|
62 | + ), |
|
63 | + 'label' => __('Blockchain Validation', 'site-reviews'), |
|
64 | + 'type' => 'yes_no', |
|
65 | + ], |
|
66 | + 'settings.general.trustalyze_email' => [ |
|
67 | + 'default' => '', |
|
68 | + 'depends_on' => [ |
|
69 | + 'settings.general.trustalyze' => ['yes'], |
|
70 | + ], |
|
71 | + 'description' => __('Enter your Trustalyze account email here.', 'site-reviews'), |
|
72 | + 'label' => __('Trustalyze Email', 'site-reviews'), |
|
73 | + 'type' => 'text', |
|
74 | + ], |
|
75 | + 'settings.general.trustalyze_serial' => [ |
|
76 | + 'default' => '', |
|
77 | + 'depends_on' => [ |
|
78 | + 'settings.general.trustalyze' => ['yes'], |
|
79 | + ], |
|
80 | + 'description' => __('Enter your Trustalyze account serial key here.', 'site-reviews'), |
|
81 | + 'label' => __('Trustalyze Serial Key', 'site-reviews'), |
|
82 | + 'type' => 'password', |
|
83 | + ], |
|
84 | + 'settings.general.notifications' => [ |
|
85 | + 'default' => [], |
|
86 | + 'label' => __('Notifications', 'site-reviews'), |
|
87 | + 'options' => [ |
|
88 | + 'admin' => __('Send to administrator', 'site-reviews').' <code>'.(string) get_option('admin_email').'</code>', |
|
89 | + 'author' => __('Send to author of the page that the review is assigned to', 'site-reviews'), |
|
90 | + 'custom' => __('Send to one or more email addresses', 'site-reviews'), |
|
91 | + 'slack' => __('Send to <a href="https://slack.com/">Slack</a>', 'site-reviews'), |
|
92 | + ], |
|
93 | + 'type' => 'checkbox', |
|
94 | + ], |
|
95 | + 'settings.general.notification_email' => [ |
|
96 | + 'default' => '', |
|
97 | + 'depends_on' => [ |
|
98 | + 'settings.general.notifications' => ['custom'], |
|
99 | + ], |
|
100 | + 'label' => __('Send Notification Emails To', 'site-reviews'), |
|
101 | + 'placeholder' => __('Separate multiple emails with a comma', 'site-reviews'), |
|
102 | + 'type' => 'text', |
|
103 | + ], |
|
104 | + 'settings.general.notification_slack' => [ |
|
105 | + 'default' => '', |
|
106 | + 'depends_on' => [ |
|
107 | + 'settings.general.notifications' => ['slack'], |
|
108 | + ], |
|
109 | + 'description' => sprintf(__('To send notifications to Slack, create a new %s and then paste the provided Webhook URL in the field above.', 'site-reviews'), |
|
110 | + '<a href="https://api.slack.com/incoming-webhooks">'.__('Incoming WebHook', 'site-reviews').'</a>' |
|
111 | + ), |
|
112 | + 'label' => __('Slack Webhook URL', 'site-reviews'), |
|
113 | + 'type' => 'text', |
|
114 | + ], |
|
115 | + 'settings.general.notification_message' => [ |
|
116 | + 'default' => glsr('Modules\Html\Template')->build('templates/email-notification'), |
|
117 | + 'depends_on' => [ |
|
118 | + 'settings.general.notifications' => ['admin', 'author', 'custom', 'slack'], |
|
119 | + ], |
|
120 | + 'description' => __( |
|
121 | + 'To restore the default text, save an empty template. '. |
|
122 | + 'If you are sending notifications to Slack then this template will only be used as a fallback in the event that <a href="https://api.slack.com/docs/attachments">Message Attachments</a> have been disabled. Available template tags:'. |
|
123 | + '<br><code>{review_rating}</code> The review rating number (1-5)'. |
|
124 | + '<br><code>{review_title}</code> The review title'. |
|
125 | + '<br><code>{review_content}</code> The review content'. |
|
126 | + '<br><code>{review_author}</code> The review author'. |
|
127 | + '<br><code>{review_email}</code> The email of the review author'. |
|
128 | + '<br><code>{review_ip}</code> The IP address of the review author'. |
|
129 | + '<br><code>{review_link}</code> The link to edit/view a review', |
|
130 | + 'site-reviews' |
|
131 | + ), |
|
132 | + 'label' => __('Notification Template', 'site-reviews'), |
|
133 | + 'rows' => 10, |
|
134 | + 'type' => 'code', |
|
135 | + ], |
|
136 | + 'settings.reviews.date.format' => [ |
|
137 | + 'default' => '', |
|
138 | + 'description' => sprintf(__('The default date format is the one set in your %s.', 'site-reviews'), |
|
139 | + '<a href="'.admin_url('options-general.php#date_format_custom').'">'.__('WordPress settings', 'site-reviews').'</a>' |
|
140 | + ), |
|
141 | + 'label' => __('Date Format', 'site-reviews'), |
|
142 | + 'options' => [ |
|
143 | + '' => __('Use the default date format', 'site-reviews'), |
|
144 | + 'relative' => __('Use a relative date format', 'site-reviews'), |
|
145 | + 'custom' => __('Use a custom date format', 'site-reviews'), |
|
146 | + ], |
|
147 | + 'type' => 'select', |
|
148 | + ], |
|
149 | + 'settings.reviews.date.custom' => [ |
|
150 | + 'default' => get_option('date_format'), |
|
151 | + 'depends_on' => [ |
|
152 | + 'settings.reviews.date.format' => 'custom', |
|
153 | + ], |
|
154 | + 'description' => __('Enter a custom date format (<a href="https://codex.wordpress.org/Formatting_Date_and_Time">documentation on date and time formatting</a>).', 'site-reviews'), |
|
155 | + 'label' => __('Custom Date Format', 'site-reviews'), |
|
156 | + 'type' => 'text', |
|
157 | + ], |
|
158 | + 'settings.reviews.name.format' => [ |
|
159 | + 'default' => '', |
|
160 | + 'description' => __('Choose how names are shown in your reviews.', 'site-reviews'), |
|
161 | + 'label' => __('Name Format', 'site-reviews'), |
|
162 | + 'options' => [ |
|
163 | + '' => __('Use the name as given', 'site-reviews'), |
|
164 | + 'first' => __('Use the first name only', 'site-reviews'), |
|
165 | + 'first_initial' => __('Convert first name to an initial', 'site-reviews'), |
|
166 | + 'last_initial' => __('Convert last name to an initial', 'site-reviews'), |
|
167 | + 'initials' => __('Convert to all initials', 'site-reviews'), |
|
168 | + ], |
|
169 | + 'type' => 'select', |
|
170 | + ], |
|
171 | + 'settings.reviews.name.initial' => [ |
|
172 | + 'default' => '', |
|
173 | + 'depends_on' => [ |
|
174 | + 'settings.reviews.name.format' => ['first_initial', 'last_initial', 'initials'], |
|
175 | + ], |
|
176 | + 'description' => __('Choose how the initial is displayed.', 'site-reviews'), |
|
177 | + 'label' => __('Initial Format', 'site-reviews'), |
|
178 | + 'options' => [ |
|
179 | + '' => __('Initial with a space', 'site-reviews'), |
|
180 | + 'period' => __('Initial with a period', 'site-reviews'), |
|
181 | + 'period_space' => __('Initial with a period and a space', 'site-reviews'), |
|
182 | + ], |
|
183 | + 'type' => 'select', |
|
184 | + ], |
|
185 | + 'settings.reviews.assigned_links' => [ |
|
186 | + 'default' => 'no', |
|
187 | + 'description' => __('Display a link to the assigned post of a review.', 'site-reviews'), |
|
188 | + 'label' => __('Enable Assigned Links', 'site-reviews'), |
|
189 | + 'type' => 'yes_no', |
|
190 | + ], |
|
191 | + 'settings.reviews.avatars' => [ |
|
192 | + 'default' => 'no', |
|
193 | + 'description' => __('Display reviewer avatars. These are generated from the email address of the reviewer using <a href="https://gravatar.com">Gravatar</a>.', 'site-reviews'), |
|
194 | + 'label' => __('Enable Avatars', 'site-reviews'), |
|
195 | + 'type' => 'yes_no', |
|
196 | + ], |
|
197 | + 'settings.reviews.avatars_regenerate' => [ |
|
198 | + 'default' => 'no', |
|
199 | + 'depends_on' => [ |
|
200 | + 'settings.reviews.avatars' => 'yes', |
|
201 | + ], |
|
202 | + 'description' => __('Regenerate the avatar whenever a local review is shown?', 'site-reviews'), |
|
203 | + 'label' => __('Regenerate Avatars', 'site-reviews'), |
|
204 | + 'type' => 'yes_no', |
|
205 | + ], |
|
206 | + 'settings.reviews.avatars_size' => [ |
|
207 | + 'default' => 40, |
|
208 | + 'depends_on' => [ |
|
209 | + 'settings.reviews.avatars' => 'yes', |
|
210 | + ], |
|
211 | + 'description' => __('Set the avatar size in pixels.', 'site-reviews'), |
|
212 | + 'label' => __('Avatar Size', 'site-reviews'), |
|
213 | + 'type' => 'number', |
|
214 | + ], |
|
215 | + 'settings.reviews.excerpts' => [ |
|
216 | + 'default' => 'yes', |
|
217 | + 'description' => __('Display an excerpt instead of the full review.', 'site-reviews'), |
|
218 | + 'label' => __('Enable Excerpts', 'site-reviews'), |
|
219 | + 'type' => 'yes_no', |
|
220 | + ], |
|
221 | + 'settings.reviews.excerpts_length' => [ |
|
222 | + 'default' => 55, |
|
223 | + 'depends_on' => [ |
|
224 | + 'settings.reviews.excerpts' => 'yes', |
|
225 | + ], |
|
226 | + 'description' => __('Set the excerpt word length.', 'site-reviews'), |
|
227 | + 'label' => __('Excerpt Length', 'site-reviews'), |
|
228 | + 'type' => 'number', |
|
229 | + ], |
|
230 | + 'settings.reviews.fallback' => [ |
|
231 | + 'default' => 'yes', |
|
232 | + 'description' => sprintf(__('Display the fallback text when there are no reviews to display. This can be changed on the %s page. You may also override this by using the "fallback" option on the shortcode. The default fallback text is: %s', 'site-reviews'), |
|
233 | + '<a href="'.admin_url('edit.php?post_type='.glsr()->post_type.'&page=settings#tab-translations').'">'.__('Translations', 'site-reviews').'</a>', |
|
234 | + '<code>'.__('There are no reviews yet. Be the first one to write one.', 'site-reviews').'</code>' |
|
235 | + ), |
|
236 | + 'label' => __('Enable Fallback Text', 'site-reviews'), |
|
237 | + 'type' => 'yes_no', |
|
238 | + ], |
|
239 | + 'settings.reviews.pagination.url_parameter' => [ |
|
240 | + 'default' => 'yes', |
|
241 | + 'description' => sprintf(_x('Use the <code>?%s={page_number}</code> URL parameter with AJAX pagination.', 'admin-text', 'site-reviews'), glsr()->constant('PAGED_QUERY_VAR')), |
|
242 | + 'label' => esc_html_x('Pagination URL Parameter', 'admin-text', 'site-reviews'), |
|
243 | + 'type' => 'yes_no', |
|
244 | + ], |
|
245 | + 'settings.schema.type.default' => [ |
|
246 | + 'default' => 'LocalBusiness', |
|
247 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_type</code>', |
|
248 | + 'label' => __('Default Schema Type', 'site-reviews'), |
|
249 | + 'options' => [ |
|
250 | + 'LocalBusiness' => __('Local Business', 'site-reviews'), |
|
251 | + 'Product' => __('Product', 'site-reviews'), |
|
252 | + 'custom' => __('Custom', 'site-reviews'), |
|
253 | + ], |
|
254 | + 'type' => 'select', |
|
255 | + ], |
|
256 | + 'settings.schema.type.custom' => [ |
|
257 | + 'default' => '', |
|
258 | + 'depends_on' => [ |
|
259 | + 'settings.schema.type.default' => 'custom', |
|
260 | + ], |
|
261 | + 'description' => '<a href="https://schema.org/docs/schemas.html">'.__('View more information on schema types here', 'site-reviews').'</a>', |
|
262 | + 'label' => __('Custom Schema Type', 'site-reviews'), |
|
263 | + 'type' => 'text', |
|
264 | + ], |
|
265 | + 'settings.schema.name.default' => [ |
|
266 | + 'default' => 'post', |
|
267 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_name</code>', |
|
268 | + 'label' => __('Default Name', 'site-reviews'), |
|
269 | + 'options' => [ |
|
270 | + 'post' => __('Use the assigned or current page title', 'site-reviews'), |
|
271 | + 'custom' => __('Enter a custom title', 'site-reviews'), |
|
272 | + ], |
|
273 | + 'type' => 'select', |
|
274 | + ], |
|
275 | + 'settings.schema.name.custom' => [ |
|
276 | + 'default' => '', |
|
277 | + 'depends_on' => [ |
|
278 | + 'settings.schema.name.default' => 'custom', |
|
279 | + ], |
|
280 | + 'label' => __('Custom Name', 'site-reviews'), |
|
281 | + 'type' => 'text', |
|
282 | + ], |
|
283 | + 'settings.schema.description.default' => [ |
|
284 | + 'default' => 'post', |
|
285 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_description</code>', |
|
286 | + 'label' => __('Default Description', 'site-reviews'), |
|
287 | + 'options' => [ |
|
288 | + 'post' => __('Use the assigned or current page excerpt', 'site-reviews'), |
|
289 | + 'custom' => __('Enter a custom description', 'site-reviews'), |
|
290 | + ], |
|
291 | + 'type' => 'select', |
|
292 | + ], |
|
293 | + 'settings.schema.description.custom' => [ |
|
294 | + 'default' => '', |
|
295 | + 'depends_on' => [ |
|
296 | + 'settings.schema.description.default' => 'custom', |
|
297 | + ], |
|
298 | + 'label' => __('Custom Description', 'site-reviews'), |
|
299 | + 'type' => 'text', |
|
300 | + ], |
|
301 | + 'settings.schema.url.default' => [ |
|
302 | + 'default' => 'post', |
|
303 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_url</code>', |
|
304 | + 'label' => __('Default URL', 'site-reviews'), |
|
305 | + 'options' => [ |
|
306 | + 'post' => __('Use the assigned or current page URL', 'site-reviews'), |
|
307 | + 'custom' => __('Enter a custom URL', 'site-reviews'), |
|
308 | + ], |
|
309 | + 'type' => 'select', |
|
310 | + ], |
|
311 | + 'settings.schema.url.custom' => [ |
|
312 | + 'default' => '', |
|
313 | + 'depends_on' => [ |
|
314 | + 'settings.schema.url.default' => 'custom', |
|
315 | + ], |
|
316 | + 'label' => __('Custom URL', 'site-reviews'), |
|
317 | + 'type' => 'text', |
|
318 | + ], |
|
319 | + 'settings.schema.image.default' => [ |
|
320 | + 'default' => 'post', |
|
321 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_image</code>', |
|
322 | + 'label' => __('Default Image', 'site-reviews'), |
|
323 | + 'options' => [ |
|
324 | + 'post' => __('Use the featured image of the assigned or current page', 'site-reviews'), |
|
325 | + 'custom' => __('Enter a custom image URL', 'site-reviews'), |
|
326 | + ], |
|
327 | + 'type' => 'select', |
|
328 | + ], |
|
329 | + 'settings.schema.image.custom' => [ |
|
330 | + 'default' => '', |
|
331 | + 'depends_on' => [ |
|
332 | + 'settings.schema.image.default' => 'custom', |
|
333 | + ], |
|
334 | + 'label' => __('Custom Image URL', 'site-reviews'), |
|
335 | + 'type' => 'text', |
|
336 | + ], |
|
337 | + 'settings.schema.address' => [ |
|
338 | + 'default' => '', |
|
339 | + 'depends_on' => [ |
|
340 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
341 | + ], |
|
342 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_address</code>', |
|
343 | + 'label' => __('Address', 'site-reviews'), |
|
344 | + 'placeholder' => '60 29th Street #343, San Francisco, CA 94110, US', |
|
345 | + 'type' => 'text', |
|
346 | + ], |
|
347 | + 'settings.schema.telephone' => [ |
|
348 | + 'default' => '', |
|
349 | + 'depends_on' => [ |
|
350 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
351 | + ], |
|
352 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_telephone</code>', |
|
353 | + 'label' => __('Telephone Number', 'site-reviews'), |
|
354 | + 'placeholder' => '+1 (877) 273-3049', |
|
355 | + 'type' => 'text', |
|
356 | + ], |
|
357 | + 'settings.schema.pricerange' => [ |
|
358 | + 'default' => '', |
|
359 | + 'depends_on' => [ |
|
360 | + 'settings.schema.type.default' => 'LocalBusiness', |
|
361 | + ], |
|
362 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricerange</code>', |
|
363 | + 'label' => __('Price Range', 'site-reviews'), |
|
364 | + 'placeholder' => '$$-$$$', |
|
365 | + 'type' => 'text', |
|
366 | + ], |
|
367 | + 'settings.schema.offertype' => [ |
|
368 | + 'default' => 'AggregateOffer', |
|
369 | + 'depends_on' => [ |
|
370 | + 'settings.schema.type.default' => 'Product', |
|
371 | + ], |
|
372 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_offertype</code>', |
|
373 | + 'label' => __('Offer Type', 'site-reviews'), |
|
374 | + 'options' => [ |
|
375 | + 'AggregateOffer' => __('AggregateOffer', 'site-reviews'), |
|
376 | + 'Offer' => __('Offer', 'site-reviews'), |
|
377 | + ], |
|
378 | + 'type' => 'select', |
|
379 | + ], |
|
380 | + 'settings.schema.price' => [ |
|
381 | + 'default' => '', |
|
382 | + 'depends_on' => [ |
|
383 | + 'settings.schema.type.default' => 'Product', |
|
384 | + 'settings.schema.offertype' => 'Offer', |
|
385 | + ], |
|
386 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_price</code>', |
|
387 | + 'label' => __('Price', 'site-reviews'), |
|
388 | + 'placeholder' => '50.00', |
|
389 | + 'type' => 'text', |
|
390 | + ], |
|
391 | + 'settings.schema.lowprice' => [ |
|
392 | + 'default' => '', |
|
393 | + 'depends_on' => [ |
|
394 | + 'settings.schema.type.default' => 'Product', |
|
395 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
396 | + ], |
|
397 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_lowprice</code>', |
|
398 | + 'label' => __('Low Price', 'site-reviews'), |
|
399 | + 'placeholder' => '10.00', |
|
400 | + 'type' => 'text', |
|
401 | + ], |
|
402 | + 'settings.schema.highprice' => [ |
|
403 | + 'default' => '', |
|
404 | + 'depends_on' => [ |
|
405 | + 'settings.schema.type.default' => 'Product', |
|
406 | + 'settings.schema.offertype' => 'AggregateOffer', |
|
407 | + ], |
|
408 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_highprice</code>', |
|
409 | + 'label' => __('High Price', 'site-reviews'), |
|
410 | + 'placeholder' => '100.00', |
|
411 | + 'type' => 'text', |
|
412 | + ], |
|
413 | + 'settings.schema.pricecurrency' => [ |
|
414 | + 'default' => '', |
|
415 | + 'depends_on' => [ |
|
416 | + 'settings.schema.type.default' => 'Product', |
|
417 | + ], |
|
418 | + 'description' => __('Custom Field name', 'site-reviews').': <code>schema_pricecurrency</code>', |
|
419 | + 'label' => __('Price Currency', 'site-reviews'), |
|
420 | + 'placeholder' => 'USD', |
|
421 | + 'type' => 'text', |
|
422 | + ], |
|
423 | + 'settings.submissions.required' => [ |
|
424 | + 'default' => ['content', 'email', 'name', 'rating', 'terms', 'title'], |
|
425 | + 'description' => __('Choose which fields should be required in the submission form.', 'site-reviews'), |
|
426 | + 'label' => __('Required Fields', 'site-reviews'), |
|
427 | + 'options' => [ |
|
428 | + 'rating' => __('Rating', 'site-reviews'), |
|
429 | + 'title' => __('Title', 'site-reviews'), |
|
430 | + 'content' => __('Review', 'site-reviews'), |
|
431 | + 'name' => __('Name', 'site-reviews'), |
|
432 | + 'email' => __('Email', 'site-reviews'), |
|
433 | + 'terms' => __('Terms', 'site-reviews'), |
|
434 | + ], |
|
435 | + 'type' => 'checkbox', |
|
436 | + ], |
|
437 | + 'settings.submissions.limit' => [ |
|
438 | + 'default' => '', |
|
439 | + 'description' => __('Limits the number of reviews that can be submitted to one-per-person. If you are assigning reviews, then the limit will be applied to the assigned page or category.', 'site-reviews'), |
|
440 | + 'label' => __('Limit Reviews', 'site-reviews'), |
|
441 | + 'options' => [ |
|
442 | + '' => __('No Limit', 'site-reviews'), |
|
443 | + 'email' => __('By Email Address', 'site-reviews'), |
|
444 | + 'ip_address' => __('By IP Address', 'site-reviews'), |
|
445 | + 'username' => __('By Username (will only work for registered users)', 'site-reviews'), |
|
446 | + ], |
|
447 | + 'type' => 'select', |
|
448 | + ], |
|
449 | + 'settings.submissions.limit_whitelist.email' => [ |
|
450 | + 'default' => '', |
|
451 | + 'depends_on' => [ |
|
452 | + 'settings.submissions.limit' => ['email'], |
|
453 | + ], |
|
454 | + 'description' => __('One Email per line. All emails in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
455 | + 'label' => __('Email Whitelist', 'site-reviews'), |
|
456 | + 'rows' => 5, |
|
457 | + 'type' => 'code', |
|
458 | + ], |
|
459 | + 'settings.submissions.limit_whitelist.ip_address' => [ |
|
460 | + 'default' => '', |
|
461 | + 'depends_on' => [ |
|
462 | + 'settings.submissions.limit' => ['ip_address'], |
|
463 | + ], |
|
464 | + 'description' => __('One IP Address per line. All IP Addresses in the whitelist will be excluded from the review submission limit..', 'site-reviews'), |
|
465 | + 'label' => __('IP Address Whitelist', 'site-reviews'), |
|
466 | + 'rows' => 5, |
|
467 | + 'type' => 'code', |
|
468 | + ], |
|
469 | + 'settings.submissions.limit_whitelist.username' => [ |
|
470 | + 'default' => '', |
|
471 | + 'depends_on' => [ |
|
472 | + 'settings.submissions.limit' => ['username'], |
|
473 | + ], |
|
474 | + 'description' => __('One Username per line. All registered users with a Username in the whitelist will be excluded from the review submission limit.', 'site-reviews'), |
|
475 | + 'label' => __('Username Whitelist', 'site-reviews'), |
|
476 | + 'rows' => 5, |
|
477 | + 'type' => 'code', |
|
478 | + ], |
|
479 | + 'settings.submissions.recaptcha.integration' => [ |
|
480 | + 'default' => '', |
|
481 | + 'description' => __('Invisible reCAPTCHA is a free anti-spam service from Google. To use it, you will need to <a href="https://www.google.com/recaptcha/admin" target="_blank">sign up</a> for an API key pair for your site.', 'site-reviews'), |
|
482 | + 'label' => __('Invisible reCAPTCHA', 'site-reviews'), |
|
483 | + 'options' => [ |
|
484 | + '' => 'Do not use reCAPTCHA', |
|
485 | + 'all' => 'Use reCAPTCHA', |
|
486 | + 'guest' => 'Use reCAPTCHA only for guest users', |
|
487 | + ], |
|
488 | + 'type' => 'select', |
|
489 | + ], |
|
490 | + 'settings.submissions.recaptcha.key' => [ |
|
491 | + 'default' => '', |
|
492 | + 'depends_on' => [ |
|
493 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
494 | + ], |
|
495 | + 'label' => __('Site Key', 'site-reviews'), |
|
496 | + 'type' => 'text', |
|
497 | + ], |
|
498 | + 'settings.submissions.recaptcha.secret' => [ |
|
499 | + 'default' => '', |
|
500 | + 'depends_on' => [ |
|
501 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
502 | + ], |
|
503 | + 'label' => __('Site Secret', 'site-reviews'), |
|
504 | + 'type' => 'text', |
|
505 | + ], |
|
506 | + 'settings.submissions.recaptcha.position' => [ |
|
507 | + 'default' => 'bottomleft', |
|
508 | + 'depends_on' => [ |
|
509 | + 'settings.submissions.recaptcha.integration' => ['all', 'guest'], |
|
510 | + ], |
|
511 | + 'description' => __('This option may not work consistently if another plugin is loading reCAPTCHA on the same page as Site Reviews.', 'site-reviews'), |
|
512 | + 'label' => __('Badge Position', 'site-reviews'), |
|
513 | + 'options' => [ |
|
514 | + 'bottomleft' => 'Bottom Left', |
|
515 | + 'bottomright' => 'Bottom Right', |
|
516 | + 'inline' => 'Inline', |
|
517 | + ], |
|
518 | + 'type' => 'select', |
|
519 | + ], |
|
520 | + 'settings.submissions.akismet' => [ |
|
521 | + 'default' => 'no', |
|
522 | + 'description' => __('The <a href="https://akismet.com" target="_blank">Akismet plugin</a> integration provides spam-filtering for your reviews. In order for this setting to have any affect, you will need to first install and activate the Akismet plugin and set up a WordPress.com API key.', 'site-reviews'), |
|
523 | + 'label' => __('Enable Akismet Integration', 'site-reviews'), |
|
524 | + 'type' => 'yes_no', |
|
525 | + ], |
|
526 | + 'settings.submissions.blacklist.integration' => [ |
|
527 | + 'default' => '', |
|
528 | + 'description' => sprintf(__('Choose which Blacklist you would prefer to use for reviews. The %s can be found in the WordPress Discussion Settings page.', 'site-reviews'), |
|
529 | + '<a href="'.admin_url('options-discussion.php#users_can_register').'">'.__('Comment Blacklist', 'site-reviews').'</a>' |
|
530 | + ), |
|
531 | + 'label' => __('Blacklist', 'site-reviews'), |
|
532 | + 'options' => [ |
|
533 | + '' => 'Use the Site Reviews Blacklist', |
|
534 | + 'comments' => 'Use the WordPress Comment Blacklist', |
|
535 | + ], |
|
536 | + 'type' => 'select', |
|
537 | + ], |
|
538 | + 'settings.submissions.blacklist.entries' => [ |
|
539 | + 'default' => '', |
|
540 | + 'depends_on' => [ |
|
541 | + 'settings.submissions.blacklist.integration' => [''], |
|
542 | + ], |
|
543 | + 'description' => __('One entry or IP address per line. When a review contains any of these entries in its title, content, name, email, or IP address, it will be rejected. It is case-insensitive and will match partial words, so "press" will match "WordPress".', 'site-reviews'), |
|
544 | + 'label' => __('Review Blacklist', 'site-reviews'), |
|
545 | + 'rows' => 10, |
|
546 | + 'type' => 'code', |
|
547 | + ], |
|
548 | + 'settings.submissions.blacklist.action' => [ |
|
549 | + 'default' => 'unapprove', |
|
550 | + 'description' => __('Choose the action that should be taken when a review is blacklisted.', 'site-reviews'), |
|
551 | + 'label' => __('Blacklist Action', 'site-reviews'), |
|
552 | + 'options' => [ |
|
553 | + 'unapprove' => __('Require approval', 'site-reviews'), |
|
554 | + 'reject' => __('Reject submission', 'site-reviews'), |
|
555 | + ], |
|
556 | + 'type' => 'select', |
|
557 | + ], |
|
558 | 558 | ]; |