function adext_payments_init() { $args = array('labels' => array(), 'public' => false, 'show_ui' => false, 'supports' => array('title'), 'has_archive' => false); register_post_type('adverts-pricing', apply_filters('adverts_post_type', $args, 'adverts-pricing')); $args = array('labels' => array(), 'public' => false, 'show_ui' => false, 'supports' => array('title'), 'has_archive' => false); register_post_type('adverts-payment', apply_filters('adverts_post_type', $args, 'adverts-payment')); register_post_status('completed', array('label' => _x('Completed', 'completed status payment', 'adverts'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Unread <span class="count">(%s)</span>', 'Unread <span class="count">(%s)</span>', 'adverts'))); register_post_status('failed', array('label' => _x('Failed', 'failed status payment', 'adverts'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'adverts'))); register_post_status('pending', array('label' => _x('Pending', 'pending status payment', 'adverts'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'adverts'))); register_post_status('refunded', array('label' => _x('Refunded', 'refunded status payment', 'adverts'), 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'adverts'))); register_post_status('advert-pending', array('label' => _x('Pending', 'post'), 'public' => is_admin() || current_user_can("edit_pages"), 'label_count' => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'adverts'))); adverts_form_add_field('adverts_field_listing_type', array('')); add_action("adverts_install_module_payments", "adext_payments_install"); add_filter("adverts_form_load", "adext_payments_form_load"); }
if ($tmp_currency['sign']) { $sign = ' (' . $tmp_currency['sign'] . ')'; } $currency_code_options[] = array("value" => $tmp_currency["code"], "text" => $tmp_currency["label"] . $sign); } /** * Register <select> input with list of Pages as options. * * This is basically a wrapper for wp_dropdown_pages() WordPress function. * * @see wp_dropdown_pages() * * @param array $field Fields settings * @since 0.3 * @return void */ function adverts_dropdown_pages($field) { if (isset($field["value"])) { $value = $field["value"]; } else { $value = null; } $args = array('selected' => $value, 'echo' => 1, 'name' => $field["name"], 'id' => $field["name"], 'show_option_none' => ' ', 'option_none_value' => 0); wp_dropdown_pages($args); } // Register <select> with list of pages /** @see adverts_dropdown_pages() */ adverts_form_add_field("adverts_dropdown_pages", array("renderer" => "adverts_dropdown_pages", "callback_bind" => "adverts_bind_single", "callback_save" => "adverts_save_single")); // Core options config form Adverts::instance()->set("form_core_config", array("name" => "", "action" => "", "field" => array(array("name" => "_common_settings", "type" => "adverts_field_header", "order" => 10, "label" => __('Common Settings', 'adverts'), "title" => __('Common Settings', 'adverts')), array("name" => "ads_list_id", "type" => "adverts_dropdown_pages", "order" => 10, "label" => __("Default Ads List Page", "adverts"), "hint" => __("Select page on which the main [adverts_list] shortcode is being used.", "adverts")), array("name" => "visibility", "type" => "adverts_field_text", "order" => 10, "label" => __("Default Visibility", "adverts"), "hint" => __("Number of days Ad will be visible by default.", "adverts"), "validator" => array(array("name" => "is_required"), array("name" => "is_integer"))), array("name" => "_currency_settings", "type" => "adverts_field_header", "order" => 10, "label" => __('Currency Settings', 'adverts'), "title" => __('Currency Settings', 'adverts')), array("name" => "currency_code", "type" => "adverts_field_select", "order" => 10, "label" => __("Currency", "adverts"), "options" => $currency_code_options), array("name" => "currency_sign_type", "type" => "adverts_field_select", "order" => 10, "label" => __("Currency Position", "adverts"), "options" => array(array("value" => "p", "text" => __("Prefix - \$10", "adverts")), array("value" => "s", "text" => __("Suffix - 10\$", "adverts")))), array("name" => "currency_decimals", "type" => "adverts_field_text", "order" => 10, "label" => __("Decimal Places", "adverts"), "validator" => array(array("name" => "is_required"), array("name" => "is_integer"))), array("name" => "currency_char_decimal", "type" => "adverts_field_text", "order" => 10, "label" => __("Decimal Separator", "adverts")), array("name" => "currency_char_thousand", "type" => "adverts_field_text", "order" => 10, "label" => __("Thousands Separator", "adverts")))));
adverts_form_add_field("adverts_field_textarea", array("renderer" => "adverts_field_textarea", "callback_save" => "adverts_save_single", "callback_bind" => "adverts_bind_single")); // Register <select>...</select> input /** @see adverts_field_select() */ adverts_form_add_field("adverts_field_select", array("renderer" => "adverts_field_select", "callback_save" => "adverts_save_multi", "callback_bind" => "adverts_bind_multi")); // Register <input type="checkbox" /> input /** @see adverts_field_checkbox() */ adverts_form_add_field("adverts_field_checkbox", array("renderer" => "adverts_field_checkbox", "callback_save" => "adverts_save_multi", "callback_bind" => "adverts_bind_multi")); // Register <input type="radio" /> input /** @see adverts_field_radio() */ adverts_form_add_field("adverts_field_radio", array("renderer" => "adverts_field_radio", "callback_save" => "adverts_save_single", "callback_bind" => "adverts_bind_single")); // Register custom image upload field /** @see adverts_field_gallery() */ adverts_form_add_field("adverts_field_gallery", array("renderer" => "adverts_field_gallery", "callback_save" => null, "callback_bind" => null)); // Register <input type="hidden" /> input /** @see adverts_field_account() */ adverts_form_add_field("adverts_field_account", array("renderer" => "adverts_field_account", "callback_save" => "adverts_save_multi", "callback_bind" => "adverts_bind_multi")); /* REGISTER FORM FILTERS */ // Register money filter (text input with currency validation) /** @see adverts_filter_money() */ adverts_form_add_filter("money", array("callback" => "adverts_filter_money")); /* REGISTER FORM VALIDATORS */ // Register "is required" validator /** @see adverts_is_required() */ adverts_form_add_validator("is_required", array("callback" => "adverts_is_required", "label" => __("Is Required", "adverts"), "params" => array(), "default_error" => __("Field cannot be empty.", "adverts"), "on_failure" => "break", "validate_empty" => true)); // Register "is email" validator /** @see adverts_is_email() */ adverts_form_add_validator("is_email", array("callback" => "adverts_is_email", "label" => __("Email", "adverts"), "params" => array(), "default_error" => __("Provided email address is invalid.", "adverts"), "validate_empty" => false)); // Register "is integer" validator /** @see adverts_is_integer() */ adverts_form_add_validator("is_integer", array("callback" => "adverts_is_integer", "label" => __("Is Integer", "adverts"), "params" => array(), "default_error" => __("Provided value is not an integer.", "adverts"), "validate_empty" => false)); // Register "string length" validator