Пример #1
0
/**
 * Form radio input(s) renderer
 * 
 * Prints (to browser) HTML for <input type="radio" /> input
 * 
 * $field params:
 * - name: string
 * - value: mixed (scalar or array)
 * - options: array (for example array(array("value"=>1, "text"=>"title")) )
 * 
 * @param array $field
 * @since 0.1
 * @return void
 */
function adverts_field_radio($field)
{
    $opts = "";
    $i = 1;
    if (!isset($field["value"])) {
        $value = null;
    } else {
        $value = $field["value"];
    }
    foreach ($field["options"] as $opt) {
        $checkbox = new Adverts_Html("input", array("type" => "radio", "name" => $field["name"], "id" => $field["name"] . '_' . $i, "value" => $opt["value"], "checked" => $opt["value"] == $value ? "checked" : null));
        $label = new Adverts_Html("label", array("for" => $field["name"] . '_' . $i), $checkbox->render() . ' ' . $opt["text"]);
        $opts .= "<div>" . $label->render() . "</div>";
        $i++;
    }
    echo Adverts_Html::build("div", array("class" => "adverts-form-input-group"), $opts);
}
Пример #2
0
/**
 * Display 'Pending' state on Classifieds list
 * 
 * This functions shows Expired state in the wp-admin / Classifieds panel
 * 
 * @see display_post_states filter
 * 
 * @global WP_Post $post
 * @param array $states
 * @return array
 */
function adext_payments_display_pending_state($states)
{
    global $post;
    $arg = get_query_var('post_status');
    if ($arg == 'advert-pending') {
        return $states;
    }
    if ($post->post_status != 'advert-pending') {
        return $states;
    }
    $loop = get_posts(array('post_type' => 'adverts-payment', 'post_status' => 'pending', 'posts_per_page' => 1, 'meta_query' => array(array('key' => '_adverts_object_id', 'value' => $post->ID))));
    if (isset($loop[0])) {
        $id = $loop[0]->ID;
    } else {
        $id = null;
    }
    $order_link = null;
    if ($id !== null) {
        $span = new Adverts_Html("span", array("class" => "dashicons dashicons-cart", "style" => "font-size: 18px"));
        $span->forceLongClosing(true);
        $order_link = new Adverts_Html("a", array("href" => admin_url("edit.php?post_type=advert&page=adext-payment-history&edit=" . $id), "title" => __("View order", "adverts")), $span->render());
    } else {
        $span = new Adverts_Html("span", array("class" => "dashicons dashicons-info", "title" => __('Abandoned', 'adverts'), "style" => "font-size: 18px"));
        $span->forceLongClosing(true);
        $order_link = $span->render();
    }
    return array(__('Pending Payment', 'adverts') . $order_link);
    return $states;
}
Пример #3
0
/**
 * Display 'Pending' state on Classifieds list
 * 
 * This functions shows Expired state in the wp-admin / Classifieds panel
 * 
 * @see display_post_states filter
 * 
 * @global WP_Post $post
 * @param array $states
 * @return array
 */
function adext_featured_post_state($states)
{
    global $post;
    if ($post->post_type == 'advert' && $post->menu_order > 0) {
        $span = new Adverts_Html("span", array("class" => "dashicons dashicons-flag", "title" => __('Featured', 'adverts'), "style" => "font-size: 18px"));
        $span->forceLongClosing(true);
        $states[] = $span->render();
    }
    return $states;
}