roles = $roles; } public function register_settings( $settings ) { $group = $settings->add_group( __( 'General', 'another-wordpress-classifieds-plugin' ), 'general-settings', 5 ); // Section: General - Ad Management Panel $key = $settings->add_section( $group, __( 'User Ad Management Panel', 'another-wordpress-classifieds-plugin' ), 'user-panel', 5, array( $settings, 'section' ) ); $help_text = __( 'You must have registered users to use this setting. Turning it on will automatically enable "Require Registration" for AWPCP. Make sure you site allows users to register under Settings->General.', 'another-wordpress-classifieds-plugin' ); $help_text = str_replace( '', sprintf( '', admin_url( 'options-general.php' ) ), $help_text ); $settings->add_setting( $key, 'enable-user-panel', __( 'Enable User Ad Management Panel', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, $help_text ); // Section: General - Default $key = $settings->add_section( $group, __( 'General Settings', 'another-wordpress-classifieds-plugin' ), 'default', 9, array( $settings, 'section' ) ); $settings->add_setting( $key, 'activatelanguages', __( 'Turn on translation file (POT)', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( "Enable translations. WordPress will look for an AWPCP-<language>.mo file in AWPCP's languages/ directory of the main plugin and premium modules. Example filenames are: AWPCP-en_US.mo, AWPCP-es_ES.mo. You can generate .mo files using POEdit and the AWPCP.pot or AWPCP-en_US.po files included with the plugin.", 'another-wordpress-classifieds-plugin' ) ); $settings->add_setting( $key, 'main_page_display', __( 'Show Ad listings on main page', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'If unchecked only categories will be displayed', 'another-wordpress-classifieds-plugin' ) ); $settings->add_setting( $key, 'view-categories-columns', __( 'Category columns in View Categories page', 'another-wordpress-classifieds-plugin' ), 'select', 2, '', array('options' => array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5))); $settings->add_setting( $key, 'collapse-categories-columns', __( 'Collapse Categories', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'If checked the list of sub-categories will be collapsed by default. Users would have to click the down arrow icon to expand the list and see the sub-categories.', 'another-wordpress-classifieds-plugin' ) ); $settings->add_setting( $key, 'noadsinparentcat', __( 'Prevent ads from being posted to top level categories?', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, '' ); $settings->add_setting( $key, 'use-multiple-category-dropdowns', __( 'Use multiple dropdowns to choose categories', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'If checked, a dropdown with top level categories will be shown. When the user chooses a category, a new dropdown will apper showing the sub-categories of the selected category, if any. Useful if your website supports a high number of categories.', 'another-wordpress-classifieds-plugin' ) ); $settings->add_setting( $key, 'hide-empty-categories-dropdown', __( 'Hide empty categories from dropdowns', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, '' ); $settings->add_setting( $key, 'uiwelcome', __( 'Welcome message in Classified page', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'Looking for a job? Trying to find a date? Looking for an apartment? Browse our classifieds. Have a job to advertise? An apartment to rent? Post a Classified Ad.', 'another-wordpress-classifieds-plugin' ), __( 'The welcome text for your classified page on the user side', 'another-wordpress-classifieds-plugin' ) ); $options = array('admin' => __( 'Administrator', 'another-wordpress-classifieds-plugin' ), 'admin,editor' => __( 'Administrator & Editor', 'another-wordpress-classifieds-plugin' ) ); $settings->add_setting( $key, 'awpcpadminaccesslevel', __( 'Who can access AWPCP Admin Dashboard', 'another-wordpress-classifieds-plugin' ), 'radio', 'admin', __( 'Role of WordPress users who can have admin access to Classifieds.', 'another-wordpress-classifieds-plugin' ), array( 'options' => $options ) ); $settings->add_setting( $key, 'awpcppagefilterswitch', __( 'Enable page filter', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'Uncheck this if you need to turn off the AWPCP page filter that prevents AWPCP classifieds children pages from showing up in your wp pages menu (You might need to do this if for example the AWPCP page filter is messing up your page menu. It means you will have to manually exclude the AWPCP children pages from showing in your page list. Some of the pages really should not be visible to your users by default).', 'another-wordpress-classifieds-plugin') ); $settings->add_setting( $key, 'show-mobile-menu-expanded', __( 'Auto-expand the Classifieds Menu for mobile devices?', 'another-wordpress-classifieds-plugin' ), 'checkbox', false, '' ); // Section: General - Date & Time Format $label = _x( 'Date & Time Format', 'settings', 'another-wordpress-classifieds-plugin' ); $key = $settings->add_section( $group, $label, 'date-time-format', 10, array( $settings, 'section_date_time_format' ) ); $datetime = current_time('timestamp'); $options = array( 'american' => sprintf( '%s: %s', __( 'American', 'another-wordpress-classifieds-plugin' ), awpcp_datetime( 'm/d/Y h:i:s', $datetime ) ), 'european' => sprintf( '%s: %s', __( 'European', 'another-wordpress-classifieds-plugin' ), awpcp_datetime( 'd/m/Y H:i:s', $datetime ) ), 'custom' => __( 'Your own.', 'another-wordpress-classifieds-plugin' ), ); $settings->add_setting( $key, 'x-date-time-format', __( 'Date Time Format', 'another-wordpress-classifieds-plugin' ), 'radio', 'american', '', array( 'options' => $options ) ); $settings->add_setting( $key, 'date-format', _x( 'Date Format', 'settings', 'another-wordpress-classifieds-plugin' ), 'textfield', 'm/d/Y', '' ); $settings->add_setting( $key, 'time-format', _x( 'Time Format', 'settings', 'another-wordpress-classifieds-plugin' ), 'textfield', 'h:i:s', '' ); $example = sprintf( '%s: %s', _x( 'Example output', 'settings', 'another-wordpress-classifieds-plugin' ), awpcp_datetime( 'awpcp' ) ); $description = _x( 'Full date/time output with any strings you wish to add. and %1$s', 'https://www.google.com/recaptcha/admin' ); $help_text = sprintf( __( 'You can get an API key from %s.', 'another-wordpress-classifieds-plugin' ), $link ); $settings->add_setting( $key, 'recaptcha-public-key', __( 'reCAPTCHA Site Key', 'another-wordpress-classifieds-plugin' ), 'textfield', '', $help_text ); $settings->add_setting( $key, 'recaptcha-private-key', __( 'reCAPTCHA Secret Key', 'another-wordpress-classifieds-plugin' ), 'textfield', '',$help_text ); $description = __( 'reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). The plugin will interrupt all interactions that receive a score under the configured threshold.', 'another-wordpress-classifieds-plugin' ) . '

' . __( "However, reCAPTCHA learns by seeing real traffic on your site. For this reason, scores in a staging environment or soon after implementing may differ from production. You can start using a threshold of 0.5 and find a better value looking at your traffic in the {console_link}admin console{/console_link}.", 'another-wordpress-classifieds-plugin' ); $description = str_replace( '{console_link}', '', $description ); $description = str_replace( '{/console_link}', '', $description ); $settings->add_setting( $key, 'recaptcha-v3-score-threshold', __( 'reCAPTCHA score threshold (v3 only)', 'another-wordpress-classifieds-plugin' ), 'textfield', '0.5', $description ); // Section: SEO Settings $key = $settings->add_section($group, __('SEO Settings', 'another-wordpress-classifieds-plugin'), 'seo-settings', 10, array( $settings, 'section' ) ); $settings->add_setting( $key, 'seofriendlyurls', __( 'Turn on Search Engine Friendly URLs', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Turn on Search Engine Friendly URLs? (SEO Mode)', 'another-wordpress-classifieds-plugin' ) ); } public function validate_group_settings( $options, $group ) { $current_roles = $this->roles->get_administrator_roles_names(); $selected_roles = $this->roles->get_administrator_roles_names_from_string( $options['awpcpadminaccesslevel'] ); $removed_roles = array_diff( $current_roles, $selected_roles ); $new_roles = array_diff( $selected_roles, $current_roles ); if ( ! empty( $removed_roles ) ) { array_walk( $removed_roles, array( $this->roles, 'remove_administrator_capabilities_from_role' ) ); } if ( ! empty( $new_roles ) ) { array_walk( $new_roles, array( $this->roles, 'add_administrator_capabilities_to_role' ) ); } return $options; } }