Beispiel #1
0
        $valid = $form->validate();
        if ($valid) {
            $data = $form->get_values();
            $data["module"] = adverts_config('config.module');
            update_option("adverts_config", $data);
            $flash->add_info(__("Settings updated.", "adverts"));
        } else {
            $flash->add_error(__("There are errors in your form.", "adverts"));
        }
    } else {
        $form->bind(adverts_config("config.ALL"));
    }
    include ADVERTS_PATH . 'addons/core/admin/options.php';
}
$currency_code_options = array();
foreach (adverts_currency_list() as $tmp_currency) {
    $sign = "";
    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
Beispiel #2
0
 * @uses Adverts
 * @uses adverts_config
 * 
 * @package     Adverts
 * @copyright   Copyright (c) 2015, Grzegorz Winiarski
 * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since       0.1
 */
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
// Set default "Post Ad" form structure and save it in Adverts Singleton
Adverts::instance()->set("form", array("name" => "advert", "action" => "", "field" => array(array("name" => "_post_id", "type" => "adverts_field_hidden", "order" => 10, "label" => ""), array("name" => "_adverts_action", "type" => "adverts_field_hidden", "order" => 10, "label" => ""), array("name" => "_contact_information", "type" => "adverts_field_header", "order" => 10, "label" => __('Contact Information', 'adverts')), array("name" => "_adverts_account", "type" => "adverts_field_account", "order" => 10, "label" => __("Account", "adverts")), array("name" => "adverts_person", "type" => "adverts_field_text", "order" => 10, "label" => __("Contact Person", "adverts"), "is_required" => true, "validator" => array(array("name" => "is_required"))), array("name" => "adverts_email", "type" => "adverts_field_text", "order" => 10, "label" => __("Email", "adverts"), "is_required" => true, "validator" => array(array("name" => "is_required"), array("name" => "is_email"))), array("name" => "adverts_phone", "type" => "adverts_field_text", "order" => 10, "label" => __("Phone Number", "adverts"), "validator" => array(array("name" => "string_length", "params" => array("min" => 5)))), array("name" => "_item_information", "type" => "adverts_field_header", "order" => 20, "label" => __('Item Information', 'adverts')), array("name" => "post_title", "type" => "adverts_field_text", "order" => 20, "label" => __("Title", "adverts"), "validator" => array(array("name" => "is_required"))), array("name" => "advert_category", "type" => "adverts_field_select", "order" => 20, "label" => __("Category", "adverts"), "max_choices" => 10, "options" => array(), "options_callback" => "adverts_taxonomies"), array("name" => "gallery", "type" => "adverts_field_gallery", "order" => 20, "label" => __("Gallery", "adverts")), array("name" => "post_content", "type" => "adverts_field_textarea", "order" => 20, "label" => __("Description", "adverts"), "validator" => array(array("name" => "is_required")), "mode" => "tinymce-mini"), array("name" => "adverts_price", "type" => "adverts_field_text", "order" => 20, "label" => __("Price", "adverts"), "description" => "", "attr" => array("key" => "value"), "filter" => array(array("name" => "money"))), array("name" => "adverts_location", "type" => "adverts_field_text", "order" => 20, "label" => __("Location", "adverts")))));
// Set default currency and save it in Adverts Singleton
Adverts::instance()->set("currency", array('code' => adverts_config("config.currency_code"), 'sign' => adverts_currency_list(adverts_config("config.currency_code"), 'sign'), 'sign_type' => adverts_config("config.currency_sign_type"), 'decimals' => adverts_config("config.currency_decimals"), 'char_decimal' => adverts_config("config.currency_char_decimal"), 'char_thousand' => adverts_config("config.currency_char_thousand")));
/** REGISTER FORM FIELDS */
// Register <span> input
/** @see adverts_field_label() */
adverts_form_add_field("adverts_field_label", array("renderer" => "adverts_field_label", "callback_save" => null, "callback_bind" => null));
// Register <input type="hidden" /> input
/** @see adverts_field_hidden() */
adverts_form_add_field("adverts_field_hidden", array("renderer" => "adverts_field_hidden", "callback_save" => "adverts_save_single", "callback_bind" => "adverts_bind_single"));
// Register <input type="text" /> input
/** @see adverts_field_text() */
adverts_form_add_field("adverts_field_text", array("renderer" => "adverts_field_text", "callback_save" => "adverts_save_single", "callback_bind" => "adverts_bind_single"));
// Register <textarea></textarea> input
/** @see adverts_field_textarea() */
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() */