PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 6.0.3
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v6.0.3
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
← All changes | includes/admin/settings/general.php +138 -0 5.7.4 → 6.0.3 View file →
@@ -1,0 +1,138 @@
1 +<?php
2 +/**
3 + * Admin General Settings
4 + *
5 + * @package AutomatorWP\Admin\Settings\General
6 + * @author AutomatorWP <[email protected]>, Ruben Garcia <[email protected]>
7 + * @since 1.3.2
8 + */
9 +// Exit if accessed directly
10 +if( !defined( 'ABSPATH' ) ) exit;
11 +
12 +/**
13 + * General Settings meta boxes
14 + *
15 + * @since 1.0.0
16 + *
17 + * @param array $meta_boxes
18 + *
19 + * @return array
20 + */
21 +function automatorwp_settings_general_meta_boxes( $meta_boxes ) {
22 +
23 + $meta_boxes['general-settings'] = array(
24 + 'title' => automatorwp_dashicon( 'admin-generic' ) . __( 'General Settings', 'automatorwp' ),
25 + 'fields' => apply_filters( 'automatorwp_general_settings_fields', array(
26 + 'minimum_role' => array(
27 + 'name' => __( 'Minimum Access Role', 'automatorwp' ),
28 + 'tooltip' => __( 'Minimum role a user needs to access to AutomatorWP management areas.', 'automatorwp' ),
29 + 'label_cb' => 'cmb_tooltip_label_cb',
30 + 'type' => 'select',
31 + 'options' => automatorwp_get_allowed_manager_capabilities(),
32 + ),
33 + 'auto_logs_cleanup_days' => array(
34 + 'name' => __( 'Logs Auto-Cleanup', 'automatorwp' ),
35 + 'tooltip' => __( 'Enter the number of days you want to keep logs stored. Leave empty to disable this.', 'automatorwp' )
36 + . '<br>' . __( 'Logs auto-cleanup will remove unused logs older than the number of days entered keeping only the important logs entries.', 'automatorwp' ),
37 + 'label_cb' => 'cmb_tooltip_label_cb',
38 + 'type' => 'text',
39 + ),
40 + 'disable_admin_bar_menu' => array(
41 + 'name' => __( 'Disable Top Bar Menu', 'automatorwp' ),
42 + 'tooltip' => __( 'Check this option to disable the AutomatorWP top bar menu.', 'automatorwp' ),
43 + 'label_cb' => 'cmb_tooltip_label_cb',
44 + 'type' => 'checkbox',
45 + 'classes' => 'cmb2-switch',
46 + ),
47 + ) )
48 + );
49 +
50 + return $meta_boxes;
51 +
52 +}
53 +add_filter( 'automatorwp_settings_general_meta_boxes', 'automatorwp_settings_general_meta_boxes' );
54 +
55 +/**
56 + * General Settings fields (extended)
57 + *
58 + * @since 1.0.0
59 + *
60 + * @param array $fields
61 + *
62 + * @return array
63 + */
64 +function automatorwp_general_settings_fields( $fields ) {
65 +
66 + if( class_exists( 'AutomatorWP_Pro' ) ) {
67 + return $fields;
68 + }
69 +
70 + $fields['disable_pro_recommendations'] = array(
71 + 'name' => __( 'Disable Recommendations', 'automatorwp' ),
72 + 'tooltip' => __( 'Check this option to disable PRO recommendations.', 'automatorwp' ),
73 + 'label_cb' => 'cmb_tooltip_label_cb',
74 + 'type' => 'checkbox',
75 + 'classes' => 'cmb2-switch',
76 + );
77 +
78 + return $fields;
79 +
80 +}
81 +add_filter( 'automatorwp_general_settings_fields', 'automatorwp_general_settings_fields' );
82 +
83 +/**
84 + * Get capability required for AutomatorWP administration.
85 + *
86 + * @since 1.0.0
87 + *
88 + * @return string User capability.
89 + */
90 +function automatorwp_get_manager_capability() {
91 +
92 + $minimum_role = automatorwp_get_option( 'minimum_role', 'manage_options' );
93 + $allowed_capabilities = array_keys( automatorwp_get_allowed_manager_capabilities() );
94 +
95 + // Do not allow to bypass subscribers capability in any way
96 + $excluded_capabilities = array( 'read' );
97 +
98 + // Check if capability is allowed
99 + if ( ! in_array( $minimum_role, $allowed_capabilities ) || in_array( $minimum_role, $excluded_capabilities ) ) {
100 + // If not allowed, manually update the settings
101 + $update_capability = get_option( 'automatorwp_settings' );
102 + $update_capability['minimum_role'] = 'manage_options';
103 + update_option( 'automatorwp_settings', $update_capability );
104 +
105 + // Set minimum role to manage_options
106 + $minimum_role = 'manage_options';
107 +
108 + }
109 +
110 + return $minimum_role;
111 +
112 +}
113 +
114 +/**
115 + * Allowed capabilities
116 + *
117 + * @since 6.0.0
118 + *
119 + * @return array
120 + */
121 +function automatorwp_get_allowed_manager_capabilities() {
122 +
123 + if ( did_action( 'init' ) ) {
124 + $allowed_capabilities = array(
125 + 'manage_options' => __( 'Administrator', 'automatorwp' ),
126 + 'delete_others_posts' => __( 'Editor', 'automatorwp' ),
127 + 'publish_posts' => __( 'Author', 'automatorwp' ),
128 + );
129 + } else {
130 + $allowed_capabilities = array(
131 + 'manage_options' => 'manage_options',
132 + 'delete_others_posts' => 'delete_others_posts',
133 + 'publish_posts' => 'publish_posts',
134 + );
135 + }
136 +
137 + return apply_filters( 'automatorwp_allowed_manager_capabilities', $allowed_capabilities );
138 +}