我檢查了一些其他話題,並沒有適合我的設置複選框的頁面加載時檢查框。PHP設置複選框檢查默認WordPresspress
該複選框與數據庫沒有關聯,只是讓代碼查看它是否被選中。我知道如何在HTML和PHP中做到這一點,但我有一個Wordpress插件,它有一個複選框,我需要在頁面加載時進行檢查。
下面顯示的複選框的代碼,但我不知道該怎麼添加,使其設置複選框選中在頁面加載時:
$is_offers_enabled = get_post_meta($object_id, 'offers_for_woocommerce_enabled', true);
$is_offers_enabled = ($is_offers_enabled == 'yes') ? 'yes' : 'no';
WCVendors_Pro_Form_Helper::input(apply_filters('ofwcv_offers_for_woocommerce_enabled', array(
'id' => 'offers_for_woocommerce_enabled',
'label' => __('Enable Offers?', 'offers-for-woocommerce-wc-vendors'),
'type' => 'checkbox',
'value' => $is_offers_enabled,
'class' => 'ofwcv_offers_for_woocommerce_enabled',
'wrapper_start' => '<div class="wcv-cols-group wcv-horizontal-gutters"><div class="all-50 small-100">',
'wrapper_end' => '</div>'
))
);
難道你不能將'checked'=>'checked'添加到該數組嗎? – IsThisJavascript