load(); } public static function instance() { if (is_null(self::$instance)) { self::$instance = new AWPCP_Settings_API(); } return self::$instance; } public function load() { $options = get_option($this->setting_name); $this->options = is_array($options) ? $options : array(); } public function register_settings() { register_setting($this->setting_name, $this->setting_name, array($this, 'validate')); // Group: Private $group = $this->add_group( __( 'Private Settings', 'another-wordpress-classifieds-plugin' ), 'private-settings', 0 ); // Group: Classified Pages $group = $this->add_group(__('Classifieds Pages', 'another-wordpress-classifieds-plugin'), 'pages-settings', 20); // Section: Classifieds Pages - Default $key = $this->add_section($group, __('Classifieds Pages', 'another-wordpress-classifieds-plugin'), 'default', 10, array($this, 'section')); $this->add_setting( $key, 'main-page-name', __( 'AWPCP Main page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'another-wordpress-classifieds-plugin', __( 'Name for Classifieds page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'show-ads-page-name', __( 'Show Ad page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Show Ad', __( 'Name for Show Ads page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'place-ad-page-name', __( 'Place Ad page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Place Ad', __( 'Name for Place Ads page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'edit-ad-page-name', __( 'Edit Ad page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Edit Ad', __( 'Name for edit ad page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'renew-ad-page-name', __( 'Renew Ad page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Renew Ad', __( 'Name for Renew Ad page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'reply-to-ad-page-name', __( 'Reply to Ad page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Reply To Ad', __( 'Name for Reply to Ad page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'browse-ads-page-name', __( 'Browse Ads page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Browse Ads', __( 'Name for Browse Ads page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'search-ads-page-name', __( 'Search Ads page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Search Ads', __( 'Name for Search Ads page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'view-categories-page-name', __( 'View Categories page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'View Categories', __( 'Name for categories view page. (Dynamic Page)', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'payment-thankyou-page-name', __( 'Payment Thank You page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Payment Thank You', __( 'Name for Payment Thank You page.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'payment-cancel-page-name', __( 'Payment Cancel page', 'another-wordpress-classifieds-plugin' ), 'textfield', 'Cancel Payment', __( 'Name for Payment Cancel page.', 'another-wordpress-classifieds-plugin' ) ); // Group: Ad/Listings $group = $this->add_group(__('Ad/Listings', 'another-wordpress-classifieds-plugin'), 'listings-settings', 30); // Section: Ad/Listings - Regions $key = $this->add_section( $group, __( 'Regions Settings', 'another-wordpress-classifieds-plugin' ), 'regions-settings', 20, array( $this, 'section' ) ); $this->add_setting( $key, 'allow-regions-modification', __( 'Allow Regions modification', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'If enabled, users will be allowed to change the region information associated with their Ads.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'allow-user-to-search-in-multiple-regions', __( 'Allow users to search Ads in multiple regions', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'If enabled, users will be allowed to search Ads in multiple regions.', 'another-wordpress-classifieds-plugin' ) ); // Section: Ad/Listings - Layout and Presentation $key = $this->add_section($group, __('Layout and Presentation', 'another-wordpress-classifieds-plugin'), 'layout', 30, array($this, 'section')); $this->add_setting( $key, 'show-ad-preview-before-payment', __( 'Show Ad preview before payment.', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'If enabled, a preview of the Ad being posted will be shown after the images have been uploaded and before the user is asked to pay. The user is allowed to go back and edit the Ad details and uploaded images or proceed with the posting process.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'allowhtmlinadtext', __( 'Allow HTML in Ad text', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Allow HTML in ad text (Not recommended).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'htmlstatustext', __( 'Display this text above ad detail text input box on ad post page', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'No HTML Allowed', 'another-wordpress-classifieds-plugin' ), ''); $this->add_setting( $key, 'characters-allowed-in-title', __( 'Maximum Ad title length', 'another-wordpress-classifieds-plugin' ), 'textfield', 100, __( 'Number of characters allowed in Ad title. Please note this is the default value and can be overwritten in Fees and Subscription Plans.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'maxcharactersallowed', __( 'Maximum Ad details length', 'another-wordpress-classifieds-plugin' ), 'textfield', 750, __( 'Number of characters allowed in Ad details. Please note this is the default value and can be overwritten in Fees and Subscription Plans.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'words-in-listing-excerpt', __( 'Number of words in Ad excerpt', 'another-wordpress-classifieds-plugin' ), 'textfield', 20, __( 'Number of words shown by the Ad excerpt placeholder.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'hidelistingcontactname', __( 'Hide contact name to anonymous users?', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Hide listing contact name to anonymous (non logged in) users.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'displayadlayoutcode', __( 'Ad Listings page layout', 'another-wordpress-classifieds-plugin' ), 'textarea', '
$awpcp_image_name_srccode

$title_link

$excerpt
$awpcpadpostdate $awpcp_city_display $awpcp_state_display $awpcp_display_adviews $awpcp_display_price $awpcpextrafields
', __( 'Modify as needed to control layout of ad listings page. Maintain code formatted as \$somecodetitle. Changing the code keys will prevent the elements they represent from displaying.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'awpcpshowtheadlayout', __( 'Single Ad page layout', 'another-wordpress-classifieds-plugin' ), 'textarea', '
$ad_title

$featureimg
' . __( "Contact Information",'another-wordpress-classifieds-plugin' ). '
' . __("Contact",'another-wordpress-classifieds-plugin') . ' $adcontact_name $adcontactphone $location $awpcpvisitwebsite
$aditemprice $awpcpextrafields
$showadsense1
' . __( "More Information", 'another-wordpress-classifieds-plugin' ) . '
$addetails
$showadsense2
    $awpcpshowadotherimages
$tweetbtn $sharebtn $flagad $awpcpadviews $showadsense3 $edit_listing_link
', __( 'Modify as needed to control layout of single ad view page. Maintain code formatted as \$somecodetitle. Changing the code keys will prevent the elements they represent from displaying.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'allow-wordpress-shortcodes-in-single-template', __( 'Allow WordPress Shortcodes in Single Ad page layout', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Shortcodes executed this way will be executed as if they were entered in the content of the WordPress page showing the listing (normally the Show Ad page, but in general any page that has the AWPCPSHOWAD shortcode).', 'another-wordpress-classifieds-plugin' ) ); $radio_options = array(1 => __( 'Date (newest first)', 'another-wordpress-classifieds-plugin' ), 9 => __( 'Date (oldest first)', 'another-wordpress-classifieds-plugin' ), 2 => __( 'Title (ascending)', 'another-wordpress-classifieds-plugin' ), 10 => __( 'Title (descending)', 'another-wordpress-classifieds-plugin' ), 3 => __( 'Paid status and date (paid first, then most recent)', 'another-wordpress-classifieds-plugin' ), 4 => __( 'Paid status and title (paid first, then by title)', 'another-wordpress-classifieds-plugin' ), 5 => __( 'Views (most viewed first, then by title)', 'another-wordpress-classifieds-plugin' ), 6 => __( 'Views (most viewed first, then by date)', 'another-wordpress-classifieds-plugin' ), 11 => __( 'Views (least viewed first, then by title)', 'another-wordpress-classifieds-plugin' ), 12 => __( 'Views (least viewed first, then by date)', 'another-wordpress-classifieds-plugin' ), 7 => __( 'Price (high to low, then by date)', 'another-wordpress-classifieds-plugin' ), 8 => __( 'Price (low to high, then by date)', 'another-wordpress-classifieds-plugin' ), ); $this->add_setting( $key, 'groupbrowseadsby', __( 'Order Ad Listings by', 'another-wordpress-classifieds-plugin' ), 'select', 1, '', array('options' => $radio_options)); $this->add_setting( $key, 'search-results-order', __( 'Order Ad Listings in Search results by', 'another-wordpress-classifieds-plugin' ), 'select', 1, '', array('options' => $radio_options)); $this->add_setting( $key, 'search-form-in-results', __( 'Search form display', 'another-wordpress-classifieds-plugin' ), 'radio', 'none', '', array( 'options' => array( 'above' => __( 'Above results', 'another-wordpress-classifieds-plugin' ), 'below' => __( 'Below results', 'another-wordpress-classifieds-plugin' ), 'none' => __( 'Don\'t show with results', 'another-wordpress-classifieds-plugin' ), ) ) ); $this->add_setting( $key, 'adresultsperpage', __( 'Default number of Ads per page', 'another-wordpress-classifieds-plugin' ), 'textfield', 10, ''); $pagination_options = array( 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 500 ); $this->add_setting( $key, 'pagination-options', __( 'Pagination Options', 'another-wordpress-classifieds-plugin' ), 'choice', $pagination_options, '', array( 'choices' => array_combine( $pagination_options, $pagination_options ) ) ); $this->add_setting( $key, 'buildsearchdropdownlists', __( 'Limits search to available locations.', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'The search form can attempt to build drop down country, state, city and county lists if data is available in the system. Note that with the regions module installed the value for this option is overridden.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'showadcount', __( 'Show Ad count in categories', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'Show how many ads a category contains.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'hide-empty-categories', __( 'Hide empty categories?', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( "If checked, categories with 0 listings in it won't be shown.", 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'displayadviews', __( 'Show Ad views', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'Show the number of times the ad has been viewed (simple count made by AWPCP &endash; warning, may not be accurate!)', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'hyperlinkurlsinadtext', __( 'Make URLs in ad text clickable', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, '' ); $this->add_setting( $key, 'visitwebsitelinknofollow', __( 'Add no follow to links in Ads', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); // Section: Ad/Listings - Classifieds Bar $key = $this->add_section( $group, __( 'Classifieds Bar', 'another-wordpress-classifieds-plugin' ), 'classifieds-bar', 60, array( $this, 'section' ) ); $this->add_setting( $key, 'show-classifieds-bar', __( 'Show Classifieds Bar', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'The Classifieds Bar is a section shown at the top of the plugin pages, displaying a Search Bar and multiple menu items. Each element of the bar can be enabled or disabled using the settings below.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'show-classifieds-search-bar', __( 'Show Search Bar', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); $this->add_setting( $key, 'show-menu-item-place-ad', __( 'Show Place Ad menu item', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); $this->add_setting( $key, 'show-menu-item-edit-ad', __( 'Show Edit Ad menu item', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); $this->add_setting( $key, 'show-menu-item-browse-ads', __( 'Show Browse Ads menu item', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); $this->add_setting( $key, 'show-menu-item-search-ads', __( 'Show Search Ads menu item', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, '' ); $this->add_behavior( $key, 'show-classifieds-search-bar', 'enabledIf', 'show-classifieds-bar' ); $this->add_behavior( $key, 'show-menu-item-place-ad', 'enabledIf', 'show-classifieds-bar' ); $this->add_behavior( $key, 'show-menu-item-edit-ad', 'enabledIf', 'show-classifieds-bar' ); $this->add_behavior( $key, 'show-menu-item-browse-ads', 'enabledIf', 'show-classifieds-bar' ); $this->add_behavior( $key, 'show-menu-item-search-ads', 'enabledIf', 'show-classifieds-bar' ); // Group: Payment Settings $group = $this->add_group( __( 'Payment', 'another-wordpress-classifieds-plugin') , 'payment-settings', 40 ); // Section: Payment Settings - PayPal $key = $this->add_section( $group, __( 'PayPal Settings', 'another-wordpress-classifieds-plugin' ), 'paypal', 20, array( $this, 'section' ) ); $this->add_setting($key, 'activatepaypal', __( 'Activate PayPal?', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'Activate PayPal?', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'paypalemail', __( 'PayPal receiver email', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'Email address for PayPal payments (if running in pay mode and if PayPal is activated).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'paypal_merchant_id', __( 'PayPal Merchant ID', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'Merchant ID associated with the PayPal account that will receive the payments. Go to https://www.paypal.com/myaccount/settings/ to obtain your Merchant ID.' ) ); $this->add_validation_rule( $key, 'paypalemail', 'required', array( 'depends' => 'activatepaypal' ) ); $this->add_validation_rule( $key, 'paypalemail', 'email', true, __( 'Please enter a valid email address.', 'another-wordpress-classifieds-plugin' ) ); $this->add_behavior( $key, 'paypalemail', 'enabledIf', 'activatepaypal' ); $this->add_behavior( $key, 'paypal_merchant_id', 'enabledIf', 'activatepaypal' ); $this->add_setting( $key, 'paypalcurrencycode', __( 'PayPal currency code', 'another-wordpress-classifieds-plugin' ), 'textfield', 'USD', __( 'The currency in which you would like to receive your PayPal payments', 'another-wordpress-classifieds-plugin' ) ); $supported_currencies = awpcp_paypal_supported_currencies(); $message = __( 'The PayPal Currency Code must be one of .', 'another-wordpress-classifieds-plugin' ); $message = str_replace( '', implode( ', ', $supported_currencies ), $message ); $this->add_validation_rule( $key, 'paypalcurrencycode', 'required', array( 'depends' => 'activatepaypal' ) ); $this->add_validation_rule( $key, 'paypalcurrencycode', 'oneof', array( 'param' => $supported_currencies ), $message ); $this->add_behavior( $key, 'paypalcurrencycode', 'enabledIf', 'activatepaypal' ); // Section: Payment Settings - 2Checkout $key = $this->add_section($group, __('2Checkout Settings', 'another-wordpress-classifieds-plugin'), '2checkout', 30, array($this, 'section')); $this->add_setting( $key, 'activate2checkout', __( 'Activate 2Checkout', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'Activate 2Checkout?', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, '2checkout', __( '2Checkout account', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'Account for 2Checkout payments.', 'another-wordpress-classifieds-plugin' ) ); $this->add_validation_rule( $key, '2checkout', 'required', array( 'depends' => 'activate2checkout' ) ); $this->add_behavior( $key, '2checkout', 'enabledIf', 'activate2checkout' ); $this->add_setting( $key, '2checkoutcurrencycode', __( '2Checkout Currency Code', 'another-wordpress-classifieds-plugin' ), 'textfield', 'USD', __( 'The currency in which you would like to receive your 2Checkout payments', 'another-wordpress-classifieds-plugin' ) ); $this->add_validation_rule( $key, '2checkoutcurrencycode', 'required', array( 'depends' => 'activate2checkout' ) ); $this->add_behavior( $key, '2checkoutcurrencycode', 'enabledIf', 'activate2checkout' ); // Group: AdSense $group = $this->add_group( __( 'AdSense', 'another-wordpress-classifieds-plugin' ), 'adsense-settings', 60 ); // Section: AdSense Settings $key = $this->add_section( $group, __( 'AdSense Settings', 'another-wordpress-classifieds-plugin' ), 'default', 10, array( $this, 'section' ) ); $options = array( 1 => __( 'Above Ad text.', 'another-wordpress-classifieds-plugin' ), 2 => __( 'Under Ad text.', 'another-wordpress-classifieds-plugin' ), 3 => __( 'Below Ad images.', 'another-wordpress-classifieds-plugin' ), ); $this->add_setting( $key, 'useadsense', __( 'Activate AdSense', 'another-wordpress-classifieds-plugin'), 'checkbox', 1, ''); $this->add_setting( $key, 'adsense', __( 'AdSense code', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'AdSense code', 'another-wordpress-classifieds-plugin' ), __( 'Your AdSense code (Best if 468x60 text or banner.)', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'adsenseposition', __( 'Show AdSense at position', 'another-wordpress-classifieds-plugin' ), 'radio', 2, '', array( 'options' => $options ) ); // Group: Registration $group = $this->add_group( __( 'Registration', 'another-wordpress-classifieds-plugin' ), 'registration-settings', 80); // Group: Email $group = $this->add_group('Email', 'email-settings', 90); // Section: General Email Settings $key = $this->add_section($group, __('General Email Settings', 'another-wordpress-classifieds-plugin'), 'default', 20, array($this, 'section')); $this->add_setting( $key, 'admin-recipient-email', __( 'TO email address for outgoing emails', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'Emails are sent to your WordPress admin email. If you prefer to receive emails in a different address, please enter it here.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'awpcpadminemail', __( 'FROM email address for outgoing emails', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'Emails go out using your WordPress admin email. If you prefer to use a different email enter it here. Some servers will not process outgoing emails that have an email address from gmail, yahoo, hotmail and other free email services in the FROM field. Some servers will also not process emails that have an email address that is different from the email address associated with your hosting account in the FROM field. If you are with such a webhost you need to make sure your WordPress admin email address is tied to your hosting account.', 'another-wordpress-classifieds-plugin' ) ); $setting_label = __( 'Use wordpress@ as the FROM email address for outgoing emails.', 'another-wordpress-classifieds-plugin' ); $setting_label = str_replace( '', awpcp_request()->domain( false ), $setting_label ); $this->add_setting( $key, 'sent-emails-using-wordpress-email-address', $setting_label, 'checkbox', 0, __( "That's the address WordPress uses to send its emails. If you are receiving the registration emails and other WordPress notifications succesfully, then you may want to enable this setting to use the same email address for all the outgoing messages. If enabled, the FROM email address for outgoing emails setting is ignored.", 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'usesenderemailinsteadofadmin', __( 'Use sender email for reply messages', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Check this to use the name and email of the sender in the FROM field when someone replies to an ad. When unchecked the messages go out with the website name and WP admin email address in the from field. Some servers will not process outgoing emails that have an email address from gmail, yahoo, hotmail and other free email services in the FROM field. Some servers will also not process emails that have an email address that is different from the email address associated with your hosting account in the FROM field. If you are with such a webhost you need to leave this option unchecked and make sure your WordPress admin email address is tied to your hosting account.', 'another-wordpress-classifieds-plugin' ) ); /* translators: full-email-address=John Doe , short-email-address=john.doe@example.com */ $description = __( 'If checked, whenever the name of the recipient is available, emails will be sent to instead of just . Some email servers, however, have problems handling email address that include the name of the recipient. If emails sent by the plugin are not being delivered properly, try unchecking this settting.' ); $description = str_replace( '', '' . esc_html( 'John Doe ' ) . '', $description ); $description = str_replace( '', '' . esc_html( 'john.doe@example.com' ) . '', $description ); $this->add_setting( $key, 'include-recipient-name-in-email-address', __( 'Include the name of the recipient in the email address', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, $description ); $this->add_setting( $key, 'include-ad-access-key', __( 'Include Ad access key in email messages', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( "Include Ad access key in email notifications. You may want to uncheck this option if you are using the Ad Management panel, but is not necessary.", 'another-wordpress-classifieds-plugin' ) ); // Section: Ad Posted Message $key = $this->add_section($group, __('Ad Posted Message', 'another-wordpress-classifieds-plugin'), 'ad-posted-message', 10, array($this, 'section')); $this->add_setting( $key, 'listingaddedsubject', __( 'Subject for Ad posted notification email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Your Classified Ad listing has been submitted', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when someone posts an Ad', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'listingaddedbody', __( 'Body for Ad posted notification email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'Thank you for submitting your Classified Ad. The details of your ad are shown below.', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when someone posts an Ad', 'another-wordpress-classifieds-plugin' ) ); // Section: Reply to Ad Message $key = $this->add_section($group, __('Reply to Ad Message', 'another-wordpress-classifieds-plugin'), 'reply-to-ad-message', 10, array($this, 'section')); $this->add_setting( $key, 'contactformsubjectline', __( 'Subject for Reply to Ad email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Response to your AWPCP Demo Ad', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when someone replies to Ad', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'contactformbodymessage', __( 'Body for Reply to Ad email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'Someone has responded to your AWPCP Demo Ad', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when someone replies to Ad', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'notify-admin-about-contact-message', __( 'Notify admin about contact message', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'An email will be sent to the administrator every time a visitor sends a message to one of the Ad posters through the Reply to Ad page.', 'another-wordpress-classifieds-plugin' ) ); // Section: Request Ad Message $key = $this->add_section($group, __('Resend Access Key Message', 'another-wordpress-classifieds-plugin'), 'request-ad-message', 10, array($this, 'section')); $this->add_setting( $key, 'resendakeyformsubjectline', __( 'Subject for Request Ad Access Key email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( "The Classified Ad's ad access key you requested", 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when someone requests their ad access key resent', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'resendakeyformbodymessage', __( 'Body for Request Ad Access Key email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( "You asked to have your Classified Ad's access key resent. Below are all the Ad access keys in the system that are tied to the email address you provided", 'another-wordpress-classifieds-plugin' ), __('Message body text for email sent out when someone requests their ad access key resent', 'another-wordpress-classifieds-plugin' ) ); // Section: Verify Email Message $key = $this->add_section($group, __('Verify Email Message', 'another-wordpress-classifieds-plugin'), 'verify-email-message', 10, array($this, 'section')); $this->add_setting( $key, 'verifyemailsubjectline', __( 'Subject for Verification email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Verify the email address used for Ad $title', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out to verify the email address.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'verifyemailbodymessage', __( 'Body for Verification email', 'another-wordpress-classifieds-plugin' ), 'textarea', _x( "Hello \$author_name \n\nYou recently posted the Ad \$title to \$website_name. \n\nIn order to complete the posting process you have to verify your email address. Please click the link below to complete the verification process. You will be redirected to the website where you can see your Ad. \n\n\$verification_link \n\nAfter you verify your email address, the administrator will be notified about the new Ad. If moderation is enabled, your Ad will remain in a disabled status until the administrator approves it.\n\n\$website_name\n\n\$website_url", 'another-wordpress-classifieds-plugin' ), __('You can use the following placeholders to personalize the body of the email: $title, $author_name,$verification_email, $website_name, $website_url.', 'another-wordpress-classifieds-plugin' ) ); // Section: Incomplete Payment Message $key = $this->add_section($group, __('Incomplete Payment Message', 'another-wordpress-classifieds-plugin'), 'incomplete-payment-message', 10, array($this, 'section')); $this->add_setting( $key, 'paymentabortedsubjectline', __( 'Subject for Incomplete Payment email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'There was a problem processing your payment', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when the payment processing does not complete', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'paymentabortedbodymessage', __( 'Body for Incomplete Payment email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'There was a problem encountered during your attempt to submit payment. If funds were removed from the account you tried to use to make a payment please contact the website admin or the payment website customer service for assistance.', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when the payment processing does not complete', 'another-wordpress-classifieds-plugin' ) ); // Section: Renew Ad Message $key = $this->add_section($group, __('Renew Ad Message', 'another-wordpress-classifieds-plugin'), 'renew-ad-message', 10, array($this, 'section')); $this->add_setting( $key, 'renew-ad-email-subject', __( 'Subject for Renew Ad email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Your classifieds listing Ad will expire in %d days.', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when an Ad is about to expire.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'renew-ad-email-body', __( 'Body for Renew Ad email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'This is an automated notification that your Classified Ad will expire in %d days.', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when an Ad is about to expire. Use %d as placeholder for the number of days before the Ad expires.', 'another-wordpress-classifieds-plugin' ) ); // Section: Ad Renewed Message $key = $this->add_section($group, __('Ad Renewed Message', 'another-wordpress-classifieds-plugin'), 'ad-renewed-message', 10, array($this, 'section')); $this->add_setting( $key, 'ad-renewed-email-subject', __( 'Subject for Ad Renewed email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Your classifieds listing "%s" has been successfully renewed.', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when an Ad is successfully renewed.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'ad-renewed-email-body', __( 'Body for Renew Ad email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'Your classifieds listing Ad has been successfully renewed. More information below:', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when an Ad is successfully renewed. ', 'another-wordpress-classifieds-plugin' ) ); // Section: Ad Expired Message $key = $this->add_section($group, __('Ad Expired Message', 'another-wordpress-classifieds-plugin'), 'ad-expired-message', 10, array($this, 'section')); $this->add_setting( $key, 'adexpiredsubjectline', __( 'Subject for Ad Expired email', 'another-wordpress-classifieds-plugin' ), 'textfield', __( 'Your classifieds listing at %s has expired', 'another-wordpress-classifieds-plugin' ), __( 'Subject line for email sent out when an ad has auto-expired', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'adexpiredbodymessage', __( 'Body for Ad Expired email', 'another-wordpress-classifieds-plugin' ), 'textarea', __( 'This is an automated notification that your Classified Ad has expired.', 'another-wordpress-classifieds-plugin' ), __( 'Message body text for email sent out when an ad has auto-expired', 'another-wordpress-classifieds-plugin' ) ); // Section: Advanced Email Configuration $key = $this->add_section( $group, __( 'Advanced Email Configuration', 'another-wordpress-classifieds-plugin' ), 'advanced', 30, array( $this, 'section' ) ); $this->add_setting( $key, 'usesmtp', __( 'Enable external SMTP server', 'another-wordpress-classifieds-plugin' ), 'checkbox', 0, __( 'Enabled external SMTP server (if emails not processing normally).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'smtphost', __( 'SMTP host', 'another-wordpress-classifieds-plugin' ), 'textfield', 'mail.example.com', __( 'SMTP host (if emails not processing normally).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'smtpport', __( 'SMTP port', 'another-wordpress-classifieds-plugin' ), 'textfield', '25', __( 'SMTP port (if emails not processing normally).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'smtpusername', __( 'SMTP username', 'another-wordpress-classifieds-plugin' ), 'textfield', 'smtp_username', __( 'SMTP username (if emails not processing normally).', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'smtppassword', __( 'SMTP password', 'another-wordpress-classifieds-plugin' ), 'password', '', __( 'SMTP password (if emails not processing normally).', 'another-wordpress-classifieds-plugin' ) ); // Group: Facebook $group = $this->add_group('Facebook', 'facebook-settings', 100); $key = $this->add_section( $group, __( 'General Settings', 'another-wordpress-classifieds-plugin' ), 'general', 10, array( $this, 'section' ) ); $this->add_setting( $key, 'facebook-integration-method', __( 'Facebook Integration Method', 'another-wordpress-classifieds-plugin' ), 'radio', 'webhooks', __( 'Please note that sending ads to Facebook Groups is currently not available using Webhooks, after Facebook significantly reduced access to their APIs across all apps. You can read more about these changes here: https://developers.facebook.com/blog/post/2018/04/04/facebook-api-platform-product-changes/', 'another-wordpress-classifieds-plugin' ), array( 'options' => array( 'facebook-api' => __( 'Facebook API', 'another-wordpress-classifieds-plugin' ), 'webhooks' => __( 'Zapier/IFTTT Webhooks', 'another-wordpress-classifieds-plugin' ), ), ) ); $this->add_setting( $key, 'sends-listings-to-facebook-automatically', __( 'Send Ads to Facebook Automatically', 'another-wordpress-classifieds-plugin' ), 'checkbox', 1, __( 'If checked, Ads will be sent to Facebook shortly after they are posted, enabled or edited, whichever occurs first. Please note that ads will be sent only once and disabled ads cannot be sent to Facebook.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'clear-facebook-cache-for-ads-pages', __( 'Ask Facebook to clear cache for ads pages', 'another-wordpress-classifieds-plugin' ), 'checkbox', false, __( 'Clearing Facebook cache is useful to ensure users always see the latest version when the ad is shared on Facebook Pages, Groups and user feeds.' ) ); $key = $this->add_section( $group, __( 'Facebook Application', 'another-wordpress-classifieds-plugin' ), 'facebook-application', 10, array( $this, 'facebook_application_settings_section' ) ); $this->add_setting( $key, 'facebook-app-id', __( 'App Id', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'An application identifier associates your site, its pages, and visitor actions with a registered Facebook application.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'facebook-app-secret', __( 'App Secret', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'An application secret is a secret shared between Facebook and your application, similar to a password.', 'another-wordpress-classifieds-plugin' ) ); $key = $this->add_section( $group, __( 'Facebook User Authorization', 'another-wordpress-classifieds-plugin' ), 'facebook-user-authorization', 10, array( $this, 'facebook_user_authorization_section' ) ); $this->add_setting( $key, 'facebook-user-access-token', __( 'User Access Token', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'You can manually enter your user access token (if you know it) or log in to Facebook to get one using the link above.', 'another-wordpress-classifieds-plugin' ) ); $key = $this->add_section( $group, __( 'Facebook Page and Group Selection', 'another-wordpress-classifieds-plugin' ), 'facebook-page-and-group-selection', 10, array( $this, 'facebook_page_and_group_selection_section' ) ); $this->add_setting( $key, 'facebook-page', __( 'Facebook Page', 'another-wordpress-classifieds-plugin' ), 'radio', '', '', array( 'options' => array( $this, 'facebook_page_options' ), ) ); $this->add_setting( $key, 'facebook-group', __( 'Facebook Group', 'another-wordpress-classifieds-plugin' ), 'radio', '', '', array( 'options' => array( $this, 'facebook_group_options' ), ) ); $this->add_setting( $key, 'facebook-page-access-token', __( 'Facebook Page Access Token', 'another-wordpress-classifieds-plugin' ), 'textfield', '', '', array( 'readonly' => true, ) ); $key = $this->add_section( $group, __( 'Zapier Integration', 'another-wordpress-classifieds-plugin' ), 'zapier', 10, array( $this, 'section' ) ); $this->add_setting( $key, 'zapier-webhook-for-facebook-page-integration', __( 'Zapier webhook used to send ads to a Facebook page', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'The plugin will post information to this URL the first time an ad becomes publicly available (after they are posted, enabled or edited) on the website or using the Send to Facebook Page action from the list of classified ads. Disabled ads are excluded.', 'another-wordpress-classifieds-plugin' ) ); $key = $this->add_section( $group, __( 'IFTTT Integration', 'another-wordpress-classifieds-plugin' ), 'ifttt', 10, array( $this, 'section' ) ); $this->add_setting( $key, 'ifttt-webhook-base-url-for-facebook-page-integration', __( 'URL used to send requests to IFTTT Webhooks service', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'The plugin will post information to the Webhooks service the first time an ad becomes publicly available (after they are posted, enabled or edited) on the website or when someone uses the Send to Facebook Page action from the list of classified ads. Disabled ads are excluded.', 'another-wordpress-classifieds-plugin' ) ); $this->add_setting( $key, 'ifttt-webhook-event-name-for-facebook-page-integration', __( 'The name of the event that will be posted to the Webhooks service', 'another-wordpress-classifieds-plugin' ), 'textfield', '', __( 'The plugin will post information about new ads to a unique URL built using the Webhooks URL and Event Name you define.', 'another-wordpress-classifieds-plugin' ) ); // save settings to database $this->skip = true; $this->save_settings(); $this->skip = false; } private function save_settings() { update_option( $this->setting_name, $this->options ); } /** * Hook actions and filters required by AWPCP Settings * to work. */ public function setup() { add_action('init', array($this, 'init'), 9999); add_action('admin_init', array($this, 'register')); // setup validate functions add_filter('awpcp_validate_settings_general-settings', array($this, 'validate_general_settings'), 10, 2); add_filter('awpcp_validate_settings_pages-settings', array($this, 'validate_classifieds_pages_settings'), 10, 2); add_filter('awpcp_validate_settings_payment-settings', array($this, 'validate_payment_settings'), 10, 2); add_filter('awpcp_validate_settings_registration-settings', array($this, 'validate_registration_settings'), 10, 2); add_filter('awpcp_validate_settings_smtp-settings', array($this, 'validate_smtp_settings'), 10, 2); add_filter( 'awpcp_validate_settings_facebook-settings', array( $this, 'validate_facebook_settings' ), 10, 2 ); add_filter( 'awpcp_validate_settings_email-settings', array( $this, 'validate_email_settings' ), 10, 2 ); } public function init() { do_action('awpcp_register_settings', $this); // save settings to database $this->skip = true; $this->save_settings(); $this->skip = false; $this->set_javascript_data(); } private function set_javascript_data() { $awpcp = awpcp(); $awpcp->js->set( 'show-popup-if-user-did-not-upload-files', (bool) $this->get_option( 'show-popup-if-user-did-not-upload-files' ) ); $awpcp->js->set( 'overwrite-contact-information-on-user-change', (bool) get_awpcp_option( 'overwrite-contact-information-on-user-change' ) ); $awpcp->js->set( 'decimal-separator', get_awpcp_option( 'decimal-separator' ) ); $awpcp->js->set( 'thousands-separator', get_awpcp_option( 'thousands-separator' ) ); $awpcp->js->set( 'date-format', awpcp_datepicker_format( get_awpcp_option( 'date-format') ) ); $awpcp->js->set( 'datetime-formats', array( 'american' => array( 'date' => 'm/d/Y', 'time' => 'h:i:s', 'format' => '