Commit fedef0a4 authored by Varun Sridharan's avatar Varun Sridharan

Updated

Added Donation Processing Email
Added Prefect Settings Framework
Added Seperate Page For Listing Donations
parent b8063aa9
This diff is collapsed.
This diff is collapsed.
<?php
/**
* WooCommerce General Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WooCommerce_Advanced_Settings' ) ) :
/**
* WC_Admin_Settings_General
*/
class WooCommerce_Advanced_Settings extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'wc_intergation_advanced';
$this->label = __( 'WC Advanced Intergation', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_filter( 'woocommerce_sections_'.$this->id, array( $this, 'output_sections' ));
add_filter( 'woocommerce_settings_'.$this->id, array( $this, 'output_settings' ));
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Get sections
*
* @return array
*/
public function get_sections() {
$sections = array(
'' => __( 'Simple Inputs', 'woocommerce' ),
'advanced_input' => __( 'Advanced Inputs','woocommerce' ),
'predefined_input' => __('Predefined Inputs','woocommerce' ),
);
return apply_filters( 'woocommerce_get_sections_' . $this->id, $sections );
}
public function output_settings(){
global $current_section;
$settings = $this->get_settings( $current_section );
WC_Admin_Settings::output_fields( $settings );
}
/**
* Get settings array
*
* @return array
*/
public function get_settings($section = null) {
var_dump($section);
$settings = array(
array(
'title' => __( 'Simple Inputs', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'wc_advanced_simple_inputs_intergation'
),
array(
'title' => __( 'Text Box', 'woocommerce' ),
'desc' => __( 'This is a simple textbox', 'woocommerce' ),
'id' =>'wc_simple_textbox',
'css' => 'min-width:350px;',
'default' => 'Simple TextBox',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'TextArea', 'woocommerce' ),
'id' => 'wc_simple_textarea',
'default' => __( 'Simple TextArea.', 'woocommerce' ),
'type' => 'textarea',
'css' => 'width:350px; height: 65px;',
'autoload' => false
),
array(
'title' => __( 'Radio Buttons', 'woocommerce' ),
'desc' => __( 'A Simple Radio Button', 'woocommerce' ),
'id' => 'wc_simple_radio',
'default' => 'all',
'type' => 'radio',
'desc_tip' => true,
'options' => array(
'option1' => __( 'option 1', 'woocommerce' ),
'option2' => __( 'option 2', 'woocommerce' )
)
),
array(
'title' => __( 'Option 1', 'woocommerce' ),
'id' => 'wc_simple_checkbox_1',
'default' => 'no',
'type' => 'checkbox',
),
array(
'title' => __( 'Option 2', 'woocommerce' ),
'id' => 'wc_simple_checkbox_2',
'default' => 'no',
'type' => 'checkbox',
),
array( 'type' => 'sectionend', 'id' => 'wc_advanced_simple_inputs_intergation'),
);
return $settings;
}
/**
* Save settings
*/
public function save() {
$settings = $this->get_settings();
WC_Admin_Settings::save_fields( $settings );
}
}
endif;
return new WooCommerce_Advanced_Settings();
<?php
/**
* WooCommerce General Settings
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WooCommerce_Simple_Settings' ) ) :
/**
* WC_Admin_Settings_General
*/
class WooCommerce_Simple_Settings extends WC_Settings_Page {
/**
* Constructor.
*/
public function __construct() {
$this->id = 'wc_intergation_simple';
$this->label = __( 'WC Simple Intergation', 'woocommerce' );
add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
}
/**
* Get settings array
*
* @return array
*/
public function get_settings() {
$settings = array(
array(
'title' => __( 'Simple Options', 'woocommerce' ),
'type' => 'title',
'desc' => '',
'id' => 'wc_simple_intergation'
),
array(
'title' => __( 'Text Box', 'woocommerce' ),
'desc' => __( 'This is a simple textbox', 'woocommerce' ),
'id' =>'wc_simple_textbox',
'css' => 'min-width:350px;',
'default' => 'GB',
'type' => 'text',
'desc_tip' => true,
),
array(
'title' => __( 'TextArea', 'woocommerce' ),
'desc' => '',
'id' => 'wc_simple_textarea',
'default' => __( 'SOme Value.', 'woocommerce' ),
'type' => 'textarea',
'css' => 'width:350px; height: 65px;',
'autoload' => false
),
array(
'title' => __( 'Radio Buttons', 'woocommerce' ),
'desc' => __( 'A Simple Radio Button', 'woocommerce' ),
'id' => 'wc_simple_radio',
'default' => 'all',
'type' => 'radio',
'desc_tip' => true,
'options' => array(
'all' => __( 'Sell to all countries', 'woocommerce' ),
'specific' => __( 'Sell to specific countries only', 'woocommerce' )
)
),
array(
'title' => __( 'Checbox', 'woocommerce' ),
'desc' => __( 'A Simple Checkbox', 'woocommerce' ),
'id' => 'wc_simple_checkboxx',
'default' => 'no',
'type' => 'checkbox'
),
array( 'type' => 'sectionend', 'id' => 'wc_simple_intergation'),
);
return $settings;
}
/**
* Save settings
*/
public function save() {
$settings = $this->get_settings();
WC_Admin_Settings::save_fields( $settings );
}
}
endif;
return new WooCommerce_Simple_Settings();
<?php
global $options;
$options = array();
WC_QD()->load_files(WC_QD_ADMIN.'settings/settings-*.php');
?>
\ No newline at end of file
......@@ -19,9 +19,33 @@ class WooCommerce_Quick_Donation_Admin_Function {
public function __construct(){
add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2);
add_filter( 'pre_get_posts', array($this,'hide_donation_order_woocommerce_order'));
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),99,2);
}
public function hide_donation_order_woocommerce_order($query) {
global $pagenow,$post_type;
$query = $query;
if(!defined('WC_QD_QRY_OVERRIDE')){
if( 'edit.php' == $pagenow || $query->is_admin && 'shop_order' == $post_type){
$query->set('meta_query',array('relation' => 'AND', array('key' => '_is_donation','compare' => 'NOT EXISTS')));
}
}
return $query;
}
public function add_wc_order_types($order_types,$type){
$order_type = $order_types;
if('' == $type){
$order_type[] = WC_QD_PT;
}
return $order_type;
}
/**
* Protects Donation Product By
* @filter_user post_row_actions
......@@ -37,7 +61,8 @@ class WooCommerce_Quick_Donation_Admin_Function {
unset($actions['inline hide-if-no-js']);
unset($actions['trash']);
unset($actions['duplicate']);
$actions['trash'] = '<a href="javascript:alert(\'Remove Woocommerce Quick Donation Plugin To Remove This Product \');"> Trash </a>';
$text = __('Remove '.WC_QD.' Plugin To Remove This Product',WC_QD_TXT);
$actions['trash'] = '<a href="javascript:alert(\' '.$text.' \');"> Trash </a>';
}
}
......
......@@ -16,51 +16,99 @@
if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Admin {
private $settings_page_hook;
/**
* Initialize the class and set its properties.
* @since 0.1
*/
public function __construct() {
WC_QD()->load_files(WC_QD_PATH.'admin/includes/*.php');
$this->load_required_files();
$this->init_hooks();
}
public function load_required_files(){
WC_QD()->load_files(WC_QD_ADMIN.'metabox_framework/meta-box.php');
}
public function init_hooks(){
add_action( 'admin_menu', array( $this, 'sub_donation_order_menu' ) );
add_action( 'admin_menu', array($this,'add_donation_notification_bubble'),99);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ),99);
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_init', array( $this, 'init_admin_class' ));
add_action( 'plugins_loaded', array( $this, 'init' ) );
add_filter( 'plugin_row_meta', array($this, 'plugin_row_links' ), 10, 2 );
add_filter( 'woocommerce_screen_ids',array($this,'set_wc_screen_ids'),99);
add_filter( 'custom_menu_order', array($this,'reorder_donation_menu' ));
add_filter('woocommerce_screen_ids',array($this,'set_wc_screen_ids'));
}
public function sub_donation_order_menu(){
$this->order_menu_slug = add_submenu_page('edit.php?post_type=wcqd_project','Donation Orders','Donation\'s','administrator','wc_qd_orders',array($this,'donation_orders_page'));
}
public function reorder_donation_menu ($menu_ord ) {
global $submenu;
//echo '<pre>'.print_r($submenu,true).'</pre>'; exit;
$name = 'edit.php?post_type='.WC_QD_PT;
$arr = array();
$arr[] = $submenu[$name][18];
$arr[] = $submenu[$name][5];
$arr[] = $submenu[$name][10];
$arr[] = $submenu[$name][15];
$arr[] = $submenu[$name][16];
$arr[] = $submenu[$name][17];
$submenu[$name] = $arr;
return $menu_ord;
}
public function add_donation_notification_bubble() {
global $submenu;
if(isset($submenu['edit.php?post_type='.WC_QD_PT])){
foreach($submenu['edit.php?post_type='.WC_QD_PT] as $menuK => $menu){
if($menu[2] === 'wc_qd_orders' ){
$submenu['edit.php?post_type='.WC_QD_PT][$menuK][0] .= "<span class='update-plugins count-1'>
<span class='update-count'>0</span></span>";
}
}
}
}
/**
* Inits Admin Sttings
*/
public function init_admin_class(){
$this->functions = new WooCommerce_Quick_Donation_Admin_Function;
# new WooCommerce_Plugin_Boiler_Plate_Admin_Settings;
}
/**
* Add a new integration to WooCommerce.
*/
public function settings_page( $integrations ) {
foreach(glob(WC_QD_PATH.'admin/woocommerce-settings*.php' ) as $file){
$integrations[] = require_once($file);
}
return $integrations;
public function donation_orders_page(){
global $wpdb;
define('WC_QD_QRY_OVERRIDE',true);
$order_ids = WC_QD()->db()->get_donation_order_ids();
$order_ids = WC_QD()->db()->extract_donation_id($order_ids);
$args = array('post_type' => 'shop_order', 'post_status' => array_keys(wc_get_order_statuses()),'post__in' => $order_ids );
$wp_query = new WP_Query($args);
require('wp-donation-listing-table.php');
tt_render_list_page($wp_query);
}
/**
* Register the stylesheets for the admin area.
*/
public function enqueue_styles() {
if('wcqd_project_page_WC_QD_settings' == $this->current_screen()){
wp_enqueue_style(WC_QD_SLUG.'_core_style',WC_QD_CSS.'admin-settings-style.css' , array(), WC_QD()->version, 'all' );
}
if(in_array($this->current_screen() , $this->get_screen_ids())) {
wp_enqueue_style(WC_QD_SLUG.'_core_style',plugins_url('css/style.css',__FILE__) , array(), WC_QD()->version, 'all' );
wp_enqueue_style(WC_QD_SLUG.'_core_style',WC_QD_CSS.'admin-style.css' , array(), WC_QD()->version, 'all' );
}
}
......@@ -70,15 +118,14 @@ class WooCommerce_Quick_Donation_Admin {
*/
public function enqueue_scripts() {
if(in_array($this->current_screen() , $this->get_screen_ids())) {
wp_enqueue_script(WC_QD_SLUG.'_core_script', plugins_url('js/script.js',__FILE__), array('jquery'), WC_QD()->version, false );
wp_enqueue_script(WC_QD_SLUG.'_core_script', WC_QD_JS.'admin-script.js', array('jquery'), WC_QD()->version, false );
}
}
public function set_wc_screen_ids($screen){
$screen[] = 'wcqd_project_page_wc_qd_settings';
public function set_wc_screen_ids($screens){
$screen = $screens;
$screen[] = 'wcqd_project_page_WC_QD_settings';
$screen[] = $this->order_menu_slug;
return $screen;
}
......@@ -99,7 +146,9 @@ class WooCommerce_Quick_Donation_Admin {
$screen_ids = array();
$screen_ids[] = 'edit-product';
$screen_ids[] = 'product';
$screen_ids[] = 'wcqd_project_page_wc_qd_settings';
$screen_ids[] = WC_QD_PT.'_page_wc_qd_settings';
$screen_ids[] = 'wcqd_project_page_WC_QD_settings';
$screen_ids[] = $this->order_menu_slug;
return $screen_ids;
}
......
<?php
class WooCommerce_Quick_Donation_Project_Meta_Box {
public function __construct() {
add_filter( 'wcqd_metabox_meta_boxes', array($this,'register_metabox' ));
}
public function register_metabox($meta_boxes){
// 1st meta box
$meta_boxes[] = array(
'id' => WC_QD_SLUG.'-metabox',
'title' => WC_QD,
'pages' => array(WC_QD_PT ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => __('Min Donation',WC_QD_TXT),
'desc' => __('Min Required Donation',WC_QD_TXT),
'id' => '_'.WC_QD_DB . 'min_req_donation',
'type' => 'number',
'std' => '10',
'class' => '',
'clone' => false,
),
array(
'name' => __('Max Donation',WC_QD_TXT),
'desc' => __('Max Required Donation',WC_QD_TXT),
'id' => '_'.WC_QD_DB . 'max_req_donation',
'type' => 'number',
'std' => '10000',
'class' => '',
'clone' => false,
) ,
array(
'name' => __('Visibility',WC_QD_TXT),
'desc' => __('Show Or Hide In Donation Form',WC_QD_TXT),
'id' => '_'.WC_QD_DB . 'visibility_project',
'type' => 'select_advanced',
'std' => 'show',
'class' => '',
'options'=>array('hide'=>'Hide Listing', 'show'=>'Show Listing'),
'clone' => false,
)
)
);
return $meta_boxes;
}
}
new WooCommerce_Quick_Donation_Project_Meta_Box;
\ No newline at end of file
<?php
// Example plugin class.
class WooCommerce_Quick_Donation_Admin_Settings {
private $page_hook;
private $settings;
private $settings_pages;
private $settings_section;
private $settings_fields;
function __construct($page_hook) {
$this->page_hook = $page_hook;
$this->settings_pages = array();
$this->settings_section = array();
$this->settings_fields = array();
$this->settings = new WooCommerce_Quick_Donation_Settings_Page();
}
/**
* Gets Settings Tab For Settings Page
* @return [[Type]] [[Description]]
*/
public function get_settings_page(){
$this->settings_pages[] = array('name' => __( 'Tab 2',WC_QD_TXT),
'type' => 'heading'
);
$this->settings_pages[] = array('name' => __( 'Tab 2',WC_QD_TXT),
'type' => 'heading'
);
$this->settings_pages = apply_filters('wc_quick_donation_settings_tab',$this->settings_pages);
return $this->settings_pages;
}
private function get_settings_section(){
$this->settings_section['example_page'] = array(
array('id'=> 'first_section',
'title'=> __('First Section',WC_QD_TXT),
'validate_callback' => array($this,'validate_section')
),
array('id'=> 'second_section',
'title' => __( 'Second Section.', WC_QD_TXT )
),
);
$this->settings_section['second_page'] = array(
array('id'=> 'second_page_first_section',
'title' => __( 'Welcome to the second page', WC_QD_TXT)
)
);
$this->settings_section = apply_filters('wc_quick_donation_settings_section',$this->settings_section);
return $this->settings_section;
}
private function get_settings_fields(){
$this->settings_fields['example_page']['first_section'] = array(array(
'id' => 'section_one_text', // required
'type' => 'text', // required
'label' => __( 'Text field label (required)', WC_QD_TXT),
'default' => 'default text',
'desc' => __( 'This is a required field.', WC_QD_TXT),
'attr' => array( 'class' => 'my_class' )
));
$this->settings_fields = apply_filters('wc_quick_donation_settings_fields',$this->settings_fields);
return $this->settings_fields;
}
function admin_init() {
$pages = $this->settings->add_pages($this->get_settings_page());
$sections = $this->get_settings_section();
$fields = $this->get_settings_fields();
foreach($sections as $section_id => $section){
$pages = $this->settings->add_sections($section_id,$section);
}
foreach($fields as $page_id => $fields){
foreach($fields as $section_id => $field){
$pages = $this->settings->add_fields($page_id, $section_id, $field );
}
}
// Create a $pages array with the add_page(), add_pages(), add_section(), add_sections(), add_field() and add_fields() methods.
$this->settings->init( $pages, $this->page_hook );
}
function admin_page() {
echo '<div class="wrap">';
settings_errors();
$this->settings->render_header( __( 'WP Settings Example', 'plugin-text-domain' ) );
echo $this->settings->debug;
// Use the function get_settings() to get all the settings.
$settings = $this->settings->get_settings();
// Use the function get get_current_admin_page() to check what page you're on
// $page = $this->settings->get_current_admin_page();
// $current_page = $page['id'];
// Display the form(s).
$this->settings->render_form();
echo '</div>';
}
function validate_section( $fields ) {
// Validation of the section_one_text text input.
// Show an error if it's empty.
// to check the section that's being validated you can check the 'section_id'
// that was added with a hidden field in the admin page form.
//
// example
// if( 'first_section' === $fields['section_id'] ) { // do stuff }
if ( empty( $fields['section_one_text'] ) ) {
// Use add_settings_error() to show an error messages.
add_settings_error(
'section_one_text', // Form field id.
'texterror', // Error id.
__( 'Error: please enter some text.', 'plugin-text-domain' ), // Error message.
'error' // Type of message. Use 'error' or 'updated'.
);
}
// Don't forget to return the fields
return $fields;
}
} // end of class
?>
\ No newline at end of file
.rwmb-autocomplete-result {
border-bottom: 1px solid #ccc;
padding: 1em 0;
overflow: hidden;
}
.rwmb-autocomplete-result .label {
float: left;
width: 90%;
}
.rwmb-autocomplete-result .actions {
width: 10%;
float: right;
cursor: pointer;
}
\ No newline at end of file
.rwmb-checkbox-wrapper .description {
display: inline;
font-style: normal;
}
.rwmb-color-picker {
display: none; /* Hidden by default */
z-index: 100;
background: rgb(238, 238, 238);
border: 1px solid rgb(204, 204, 204);
position: absolute;
}
.rwmb-color-wrapper .wp-picker-container {
position: relative;
}
.rwmb-color-wrapper .wp-picker-holder {
position: absolute;
z-index: 1;
}
This diff is collapsed.
/* =Styles for 'divider' field
-------------------------------------------------------------- */
.rwmb-divider-wrapper hr {
border: none;
border-top: 1px solid #e6e6e6;
}
\ No newline at end of file
.rwmb-file li {
width: 250px;
margin: 0 10px 10px 0;
-webkit-transition: width .25s, opacity .25s, -webkit-opacity .25s;
transition: width .25s, opacity .25s;
}
.rwmb-file .rwmb-icon {
width: 60px;
text-align: center;
vertical-align: middle;
overflow: hidden;
}
.rwmb-file .rwmb-icon img {
max-height: 60px;
max-width: 60px;
}
.rwmb-file .rwmb-info {
width: 180px;
vertical-align: top;
overflow: hidden;
}
.rwmb-file .rwmb-info p {
margin: .1em 0;
}
.rwmb-file .rwmb-info a {
font-weight: bold;
text-decoration: none;
}
.rwmb-file li,
.rwmb-file .rwmb-icon,
.rwmb-file .rwmb-info {
display: inline-block;
}
.rwmb-file .rwmb-icon,
.rwmb-file .rwmb-info {
margin: 0 0 2px 2px;
}
.rwmb-file li.removed {
width: 0;
margin: 0;
opacity: 0;
-webkit-opacity: 0;
-moz-opacity: 0;
-o-opacity: 0;
}
.rwmb-file li.removed:after {
content: ' ';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
opacity: .4;
background-color: #f00;
}
\ No newline at end of file
/* =Styles for 'heading' field
-------------------------------------------------------------- */
.rwmb-heading-wrapper h4 {
display: block;
font-size: .75rem;
line-height: 1.4;
border-bottom: 1px solid rgb(230, 230, 230);
text-transform: uppercase;
padding: .75rem 0 .375rem;
margin: 0 0 6px;
}
\ No newline at end of file
.rwmb-image-select {
display: inline-block;
width: 80px;
height: 80px;
float: left;
margin: 0 10px 10px 0;
border: 3px solid #d8d8d8;
border-radius: 3px;
padding: 1px;
}
.rwmb-image-select img {
width: 100%;
height: 100%;
}
.rwmb-image-select:hover,
.rwmb-image-select.rwmb-active {
border-color: #0074a2;
}
.rwmb-image-select input {
display: none;
}
\ No newline at end of file
/* Uploaded image */
.rwmb-images {
overflow: hidden;
}
.rwmb-images li {
margin: 0 10px 10px 0;
float: left;
width: 150px;
height: 150px;
text-align: center;
cursor: move;
position: relative;
-webkit-transition: width .25s, opacity .25s, -webkit-opacity .25s;
transition: width .25s, opacity .25s;
}
.rwmb-images img {
width: 150px;
height: 150px;
}
.rwmb-image-bar {
color: #fff;
font-weight: bold;
background: #000;
background: rgba(0, 0, 0, .5);
position: absolute;
top: 0;
right: 0;
padding: 5px;
display: none;
text-align: center;
}
li:hover .rwmb-image-bar {
display: block;
}
.rwmb-image-bar a {
color: #fff;
font-weight: bold;
text-decoration: none;
vertical-align: middle;
}
.rwmb-image-bar a.rwmb-delete-file {
font-size: 23px;
width: 18px;
font-weight: normal;
}
.rwmb-images li.removed {
width: 0;
margin: 0;
opacity: 0;
-webkit-opacity: 0;
-moz-opacity: 0;
-o-opacity: 0;
}
.rwmb-images li.removed:after {
content: ' ';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
opacity: .4;
background-color: #f00;
}
.rwmb-images li.ui-state-highlight {
background: #ddd;
}
\ No newline at end of file
/*! jQuery Timepicker Addon - v1.5.0 - 2014-09-01
* http://trentrichardson.com/examples/timepicker
* Copyright (c) 2014 Trent Richardson; Licensed MIT */
.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{float:left;clear:left;padding:0 0 0 5px}.ui-timepicker-div dl dd{margin:0 10px 10px 40%}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0 0;border:0;margin:0;padding:0}.ui-timepicker-rtl{direction:rtl}.ui-timepicker-rtl dl{text-align:right;padding:0 5px 0 0}.ui-timepicker-rtl dl dt{float:right;clear:right}.ui-timepicker-rtl dl dd{margin:0 40% 10px 10px}
\ No newline at end of file
/*
* jQuery UI CSS Framework 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Theming/API
*/
/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
.ui-helper-clearfix:after { clear: both; }
.ui-helper-clearfix { zoom: 1; }
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
/* Interaction Cues
----------------------------------*/
.ui-state-disabled { cursor: default !important; }
/* Icons
----------------------------------*/
/* states and images */
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
/* Misc visuals
----------------------------------*/
/* Overlays */
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
/*
* jQuery UI Datepicker 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Datepicker#theming
*/
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
.ui-datepicker .ui-datepicker-prev { left:2px; }
.ui-datepicker .ui-datepicker-next { right:2px; }
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
.ui-datepicker select.ui-datepicker-month,
.ui-datepicker select.ui-datepicker-year { width: 49%;}
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
.ui-datepicker td { border: 0; padding: 1px; }
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
/* with multiple calendars */
.ui-datepicker.ui-datepicker-multi { width:auto; }
.ui-datepicker-multi .ui-datepicker-group { float:left; }
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
/* RTL support */
.ui-datepicker-rtl { direction: rtl; }
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
.ui-datepicker-cover {
display: none; /*sorry for IE5*/
display/**/: block; /*sorry for IE5*/
position: absolute; /*must have*/
z-index: -1; /*must have*/
filter: mask(); /*must have*/
top: -4px; /*must have*/
left: -4px; /*must have*/
width: 200px; /*must have*/
height: 200px; /*must have*/
}
\ No newline at end of file
/*
* jQuery UI Slider 1.8.17
*
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Slider#theming
*/
.ui-slider { position: relative; text-align: left; }
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
.ui-slider-horizontal { height: .8em; }
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
.ui-slider-vertical { width: .8em; height: 100px; }
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
.ui-slider-vertical .ui-slider-range-max { top: 0; }
\ No newline at end of file
.rwmb-map-canvas {
width: 100%;
height: 400px;
}
.rwmb-oembed-wrapper .spinner {
float: none;
vertical-align: top;
display: inline-block;
}
.rwmb-oembed-wrapper .embed-code {
margin-top: 1em;
}
.rwmb-oembed-wrapper .embed-code iframe {
max-width: 100%;
}
\ No newline at end of file
div.rwmb-drag-drop {
border: 4px dashed #ddd;
height: 200px;
}
div.rwmb-image-uploading-bar {
position: absolute;
width: 100%;
height: 0;
bottom: 0;
}
div.rwmb-image-uploading-status {
position: absolute;
}
li.rwmb-image-error {
border: 3px solid #c00;
background: #903838;
}
.rwmb-image-uploading-status .rwmb-loader {
width: 64px;
height: 64px;
top: 43px;
left: 43px;
position: relative;
}
\ No newline at end of file
input[type='range'] {
border-radius: 2px;
border: 1px solid #dfdfdf;
}
\ No newline at end of file
#post-body .rwmb-select-advanced {
height: auto;
min-width: 200px;
}
#post-body .rwmb-select-all {
margin-top: 5px;
}
\ No newline at end of file
#post-body .rwmb-select {
height: auto;
min-width: 200px;
}
#post-body .rwmb-select-all {
margin-top: 5px;
}
\ No newline at end of file
This diff is collapsed.
.rwmb-slider {
display: inline-block;
vertical-align: middle;
width: 50%;
}
.rwmb-slider-value-label {
margin-left: 10px;
vertical-align: middle;
}
/* Fix slider handle being visible through jQuery panel */
.ui-slider .ui-slider-handle {
z-index: 1;
}
\ No newline at end of file
/* =Styles for 'normal' meta boxes
-------------------------------------------------------------- */
.rwmb-field {
margin: 0 0 10px;
}
.rwmb-label,
.rwmb-input {
display: inline-block;
vertical-align: top;
}
.rwmb-label {
width: 24%;
}
.rwmb-label.required > span {
color: #c00;
font-weight: bold;
}
/* 75% if field has label, 100% if no label */
.rwmb-input {
width: 100%;
}
.rwmb-label ~ .rwmb-input {
width: 75%;
}
.rwmb-input h4 {
margin: 0;
}
.rwmb-textarea {
resize: vertical;
}
/* Clone */
.rwmb-clone {
min-height: 24px;
margin-bottom: 10px;
position: relative;
clear: both;
background: #fff;
}
.rwmb-clone > input[type='radio'],
.rwmb-clone > input[type='checkbox'] {
margin: 6px 0 0 4px;
}
.rwmb-button {
float: right;
}
.rwmb-button.remove-clone {
position: absolute;
top: 0;
right: 0;
}
.rwmb-clone-icon {
cursor: move;
background: url(../img/drag_icon.gif) no-repeat;
height: 23px;
width: 15px;
float: left;
margin-left: -15px;
}
/* Fix empty block below admin footer (issue #24) */
#ui-datepicker-div {
display: none;
}
/* jQuery validation */
label.error {
padding-left: 3px;
color: red;
}
input.error,
textarea.error,
select.error {
border: #c00 solid 1px !important;
background: #ffebe8 !important;
}
/* =Styles for 'side' meta boxes
-------------------------------------------------------------- */
#side-sortables .rwmb-label,
#side-sortables .rwmb-input {
width: 100%;
}
.rw-taxonomy-tree {
margin-left: 15px;
margin-top: 5px;
}
.rwmb-input > .rw-taxonomy-tree {
margin-left: 0;
margin-top: 0;
}
.rw-taxonomy-tree.active {
display: inline-block;
}
.rw-taxonomy-tree.disabled {
display: none;
}
.rwmb-field .mceIframeContainer {
background: #fff;
}
\ No newline at end of file
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Common' ) )
{
/**
* Common functions for the plugin
* Independent from meta box/field classes
*/
class WCQD_METABOX_Common
{
/**
* Do actions when class is loaded
*
* @return void
*/
public static function on_load()
{
self::load_textdomain();
$plugin = 'meta-box/meta-box.php';
add_filter( "plugin_action_links_$plugin", array( __CLASS__, 'plugin_links' ) );
}
/**
* Load plugin translation
*
* @return void
*/
public static function load_textdomain()
{
// l18n translation files
$locale = get_locale();
$dir = trailingslashit( WCQD_METABOX_DIR . 'lang' );
$mofile = "{$dir}{$locale}.mo";
// In themes/plugins/mu-plugins directory
load_textdomain( 'meta-box', $mofile );
}
/**
* Add links to Documentation and Extensions in plugin's list of action links
*
* @since 4.3.11
*
* @param array $links Array of action links
*
* @return array
*/
public static function plugin_links( $links )
{
$links[] = '<a href="http://metabox.io/docs/">' . __( 'Documentation', 'meta-box' ) . '</a>';
$links[] = '<a href="http://metabox.io/plugins/">' . __( 'Extensions', 'meta-box' ) . '</a>';
return $links;
}
}
WCQD_METABOX_Common::on_load();
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Field_Multiple_Values' ) )
{
/**
* This class implements common methods used in fields which have multiple values
* like checkbox list, autocomplete, etc.
*
* The difference when handling actions for these fields are the way they get/set
* meta value. Briefly:
* - If field is cloneable, value is saved as a single entry in the database
* - Otherwise value is saved as multiple entries
*/
class WCQD_METABOX_Field_Multiple_Values extends WCQD_METABOX_Field
{
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field['multiple'] = true;
$field['field_name'] = $field['id'];
if ( ! $field['clone'] )
$field['field_name'] .= '[]';
return $field;
}
/**
* Output the field value
* Display option name instead of option value
*
* @param array $field Field parameters
* @param array $args Additional arguments. Not used for these fields.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Field value
*/
static function the_value( $field, $args = array(), $post_id = null )
{
$value = self::get_value( $field, $args, $post_id );
if ( ! $value )
return '';
$output = '<ul>';
if ( $field['clone'] )
{
foreach ( $value as $subvalue )
{
$output .= '<li>';
$output .= '<ul>';
foreach ( $subvalue as $option )
{
$output .= '<li>' . $field['options'][$option] . '</li>';
}
$output .= '</ul>';
$output .= '</li>';
}
}
else
{
foreach ( $value as $option )
{
$output .= '<li>' . $field['options'][$option] . '</li>';
}
}
$output .= '</ul>';
return $output;
}
}
}
This diff is collapsed.
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Autocomplete_Field' ) )
{
class WCQD_METABOX_Autocomplete_Field extends WCQD_METABOX_Field_Multiple_Values
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style( 'rwmb-autocomplete', WCQD_METABOX_CSS_URL . 'autocomplete.css', array( 'wp-admin' ), WCQD_METABOX_VER );
wp_enqueue_script( 'rwmb-autocomplete', WCQD_METABOX_JS_URL . 'autocomplete.js', array( 'jquery-ui-autocomplete' ), WCQD_METABOX_VER, true );
wp_localize_script( 'rwmb-autocomplete', 'WCQD_METABOX_Autocomplete', array( 'delete' => __( 'Delete', 'meta-box' ) ) );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
if ( ! is_array( $meta ) )
$meta = array( $meta );
if ( is_string( $field['options'] ) )
{
$options = $field['options'];
}
else
{
$options = array();
foreach ( $field['options'] as $value => $label )
{
$options[] = array(
'value' => $value,
'label' => $label,
);
}
$options = wp_json_encode( $options );
}
// Input field that triggers autocomplete.
// This field doesn't store field values, so it doesn't have "name" attribute.
// The value(s) of the field is store in hidden input(s). See below.
$html = sprintf(
'<input type="text" class="rwmb-autocomplete" id="%s" data-name="%s" data-options="%s" size="%s">',
$field['id'],
$field['field_name'],
esc_attr( $options ),
$field['size']
);
$html .= '<div class="rwmb-autocomplete-results">';
// Each value is displayed with label and 'Delete' option
// The hidden input has to have ".rwmb-*" class to make clone work
$tpl = '
<div class="rwmb-autocomplete-result">
<div class="label">%s</div>
<div class="actions">%s</div>
<input type="hidden" class="rwmb-autocomplete-value" name="%s" value="%s">
</div>
';
if ( is_array( $field['options'] ) )
{
foreach ( $field['options'] as $value => $label )
{
if ( in_array( $value, $meta ) )
{
$html .= sprintf(
$tpl,
$label,
__( 'Delete', 'meta-box' ),
$field['field_name'],
$value
);
}
}
}
else
{
foreach ( $meta as $value )
{
if ( empty( $value ) )
continue;
$label = apply_filters( 'wcqd_metabox_autocomplete_result_label', $value, $field );
$html .= sprintf(
$tpl,
$label,
__( 'Delete', 'meta-box' ),
$field['field_name'],
$value
);
}
}
$html .= '</div>'; // .rwmb-autocomplete-results
return $html;
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field = parent::normalize_field( $field );
$field = wp_parse_args( $field, array(
'size' => 30,
) );
return $field;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Button_Field' ) )
{
class WCQD_METABOX_Button_Field extends WCQD_METABOX_Field
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<a href="#" id="%s" class="button hide-if-no-js">%s</a>',
$field['id'],
$field['std']
);
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field['std'] = $field['std'] ? $field['std'] : __( 'Click me', 'meta-box' );
return $field;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Checkbox_List_Field' ) )
{
class WCQD_METABOX_Checkbox_List_Field extends WCQD_METABOX_Field_Multiple_Values
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
$meta = (array) $meta;
$html = array();
$tpl = '<label><input type="checkbox" class="rwmb-checkbox-list" name="%s" value="%s"%s> %s</label>';
foreach ( $field['options'] as $value => $label )
{
$html[] = sprintf(
$tpl,
$field['field_name'],
$value,
checked( in_array( $value, $meta ), 1, false ),
$label
);
}
return implode( '<br>', $html );
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Checkbox_Field' ) )
{
class WCQD_METABOX_Checkbox_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style( 'rwmb-checkbox', WCQD_METABOX_CSS_URL . 'checkbox.css', array(), WCQD_METABOX_VER );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<input type="checkbox" class="rwmb-checkbox" name="%s" id="%s" value="1" %s>',
$field['field_name'],
$field['id'],
checked( ! empty( $meta ), 1, false )
);
}
/**
* Set the value of checkbox to 1 or 0 instead of 'checked' and empty string
* This prevents using default value once the checkbox has been unchecked
*
* @link https://github.com/rilwis/meta-box/issues/6
*
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
*
* @return int
*/
static function value( $new, $old, $post_id, $field )
{
return empty( $new ) ? 0 : 1;
}
/**
* Output the field value
* Display 'Yes' or 'No' instead of '1' and '0'
*
* Note: we don't echo the field value directly. We return the output HTML of field, which will be used in
* wcqd_metabox_the_field function later.
*
* @use self::get_value()
* @see wcqd_metabox_the_field()
*
* @param array $field Field parameters
* @param array $args Additional arguments. Rarely used. See specific fields for details
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return string HTML output of the field
*/
static function the_value( $field, $args = array(), $post_id = null )
{
$value = self::get_value( $field, $args, $post_id );
return $value ? __( 'Yes', 'meta-box' ) : __( 'No', 'meta-box' );
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Color_Field' ) )
{
class WCQD_METABOX_Color_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style( 'rwmb-color', WCQD_METABOX_CSS_URL . 'color.css', array( 'wp-color-picker' ), WCQD_METABOX_VER );
wp_enqueue_script( 'rwmb-color', WCQD_METABOX_JS_URL . 'color.js', array( 'wp-color-picker' ), WCQD_METABOX_VER, true );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<input class="rwmb-color" type="text" name="%s" id="%s" value="%s" size="%s" />
<div class="rwmb-color-picker"></div>',
$field['field_name'],
empty( $field['clone'] ) ? $field['id'] : '',
$meta,
$field['size']
);
}
/**
* Don't save '#' when no color is chosen
*
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
*
* @return int
*/
static function value( $new, $old, $post_id, $field )
{
return '#' === $new ? '' : $new;
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field = wp_parse_args( $field, array(
'size' => 7,
) );
return $field;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Custom_Html_Field' ) )
{
class WCQD_METABOX_Custom_Html_Field extends WCQD_METABOX_Field
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
$html = ! empty( $field['std'] ) ? $field['std'] : '';
if ( ! empty( $field['callback'] ) && is_callable( $field['callback'] ) )
{
$html = call_user_func_array( $field['callback'], array( $meta, $field ) );
}
return $html;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Date_Field' ) )
{
class WCQD_METABOX_Date_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
$url = WCQD_METABOX_CSS_URL . 'jqueryui';
wp_register_style( 'jquery-ui-core', "{$url}/jquery.ui.core.css", array(), '1.8.17' );
wp_register_style( 'jquery-ui-theme', "{$url}/jquery.ui.theme.css", array(), '1.8.17' );
wp_register_style( 'wp-datepicker', WCQD_METABOX_CSS_URL ."datepicker.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
wp_enqueue_style( 'jquery-ui-datepicker', "{$url}/jquery.ui.datepicker.css", array( 'wp-datepicker' ), '1.8.17' );
// Load localized scripts
$locale = str_replace( '_', '-', get_locale() );
$file_paths = array( 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . $locale . '.js' );
// Also check alternate i18n filename (e.g. jquery.ui.datepicker-de.js instead of jquery.ui.datepicker-de-DE.js)
if ( strlen( $locale ) > 2 )
$file_paths[] = 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . substr( $locale, 0, 2 ) . '.js';
$deps = array( 'jquery-ui-datepicker' );
foreach ( $file_paths as $file_path )
{
if ( file_exists( WCQD_METABOX_DIR . 'js/' . $file_path ) )
{
wp_register_script( 'jquery-ui-datepicker-i18n', WCQD_METABOX_JS_URL . $file_path, $deps, '1.8.17', true );
$deps[] = 'jquery-ui-datepicker-i18n';
break;
}
}
wp_enqueue_script( 'rwmb-date', WCQD_METABOX_JS_URL . 'date.js', $deps, WCQD_METABOX_VER, true );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<input type="text" class="rwmb-date" name="%s" value="%s" id="%s" size="%s" data-options="%s" />',
$field['field_name'],
$meta,
isset( $field['clone'] ) && $field['clone'] ? '' : $field['id'],
$field['size'],
esc_attr( wp_json_encode( $field['js_options'] ) )
);
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field = wp_parse_args( $field, array(
'size' => 30,
'js_options' => array(),
) );
// Deprecate 'format', but keep it for backward compatible
// Use 'js_options' instead
$field['js_options'] = wp_parse_args( $field['js_options'], array(
'dateFormat' => empty( $field['format'] ) ? 'yy-mm-dd' : $field['format'],
'showButtonPanel' => true,
) );
return $field;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Datetime_Field' ) )
{
class WCQD_METABOX_Datetime_Field extends WCQD_METABOX_Field
{
/**
* Translate date format from jQuery UI datepicker to PHP date()
* It's used to store timestamp value of the field
* Missing: 'o' => '', '!' => '', 'oo' => '', '@' => '', "''" => "'"
* @var array
*/
static $date_format_translation = array(
'd' => 'j', 'dd' => 'd', 'oo' => 'z', 'D' => 'D', 'DD' => 'l',
'm' => 'n', 'mm' => 'm', 'M' => 'M', 'MM' => 'F', 'y' => 'y', 'yy' => 'Y',
);
/**
* Translate date format from jQuery UI datepicker to PHP date()
* It's used to store timestamp value of the field
* Missing: 't' => '', T' => '', 'm' => '', 's' => ''
* @var array
*/
static $time_format_translation = array(
'H' => 'G', 'HH' => 'H', 'h' => 'g', 'hh' => 'h',
'mm' => 'i', 'ss' => 's', 'l' => 'u', 'tt' => 'a', 'TT' => 'A',
);
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
$url = WCQD_METABOX_CSS_URL . 'jqueryui';
wp_register_style( 'jquery-ui-core', "{$url}/jquery.ui.core.css", array(), '1.8.17' );
wp_register_style( 'jquery-ui-theme', "{$url}/jquery.ui.theme.css", array(), '1.8.17' );
wp_register_style( 'jquery-ui-datepicker', "{$url}/jquery.ui.datepicker.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
wp_register_style( 'wp-datepicker', WCQD_METABOX_CSS_URL ."datepicker.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
wp_register_style( 'jquery-ui-slider', "{$url}/jquery.ui.slider.css", array( 'jquery-ui-core', 'jquery-ui-theme' ), '1.8.17' );
wp_enqueue_style( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.min.css", array( 'jquery-ui-datepicker', 'jquery-ui-slider', 'wp-datepicker' ), '1.5.0' );
$url = WCQD_METABOX_JS_URL . 'jqueryui';
wp_register_script( 'jquery-ui-timepicker', "{$url}/jquery-ui-timepicker-addon.min.js", array( 'jquery-ui-datepicker', 'jquery-ui-slider' ), '1.5.0', true );
/**
* Localization
* Use 1 minified JS file for timepicker which contains all languages for simpilicity (in version < 4.4.2 we use separated JS files).
* The language is set in Javascript
*
* Note: we use full locale (de-DE) and fallback to short locale (de)
*/
$locale = str_replace( '_', '-', get_locale() );
$locale_short = substr( $locale, 0, 2 );
wp_register_script( 'jquery-ui-timepicker-i18n', "{$url}/jquery-ui-timepicker-addon-i18n.min.js", array( 'jquery-ui-timepicker' ), '1.5.0', true );
$date_paths = array( 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . $locale . '.js' );
if ( strlen( $locale ) > 2 )
{
// Also check alternate i18n filenames
// (e.g. jquery.ui.datepicker-de.js instead of jquery.ui.datepicker-de-DE.js)
$date_paths[] = 'jqueryui/datepicker-i18n/jquery.ui.datepicker-' . substr( $locale, 0, 2 ) . '.js';
}
$deps = array( 'jquery-ui-timepicker-i18n' );
foreach ( $date_paths as $date_path )
{
if ( file_exists( WCQD_METABOX_DIR . 'js/' . $date_path ) )
{
wp_register_script( 'jquery-ui-datepicker-i18n', WCQD_METABOX_JS_URL . $date_path, array( 'jquery-ui-datepicker' ), '1.8.17', true );
$deps[] = 'jquery-ui-datepicker-i18n';
break;
}
}
wp_enqueue_script( 'rwmb-datetime', WCQD_METABOX_JS_URL . 'datetime.js', $deps, WCQD_METABOX_VER, true );
wp_localize_script( 'rwmb-datetime', 'WCQD_METABOX_Datetimepicker', array(
'locale' => $locale,
'localeShort' => $locale_short,
) );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
$meta = $field['timestamp'] && $meta ? date( self::translate_format( $field ), intval( $meta ) ) : $meta;
return sprintf(
'<input type="text" class="rwmb-datetime" name="%s" value="%s" id="%s" size="%s" data-options="%s">',
$field['field_name'],
$meta,
$field['clone'] ? '' : $field['id'],
$field['size'],
esc_attr( wp_json_encode( $field['js_options'] ) )
);
}
/**
* Calculates the timestamp from the datetime string and returns it
* if $field['timestamp'] is set or the datetime string if not
*
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
*
* @return string|int
*/
static function value( $new, $old, $post_id, $field )
{
if ( ! $field['timestamp'] )
return $new;
$d = DateTime::createFromFormat( self::translate_format( $field ), $new );
return $d ? $d->getTimestamp() : 0;
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field = wp_parse_args( $field, array(
'size' => 30,
'js_options' => array(),
'timestamp' => false,
) );
// Deprecate 'format', but keep it for backward compatible
// Use 'js_options' instead
$field['js_options'] = wp_parse_args( $field['js_options'], array(
'dateFormat' => empty( $field['format'] ) ? 'yy-mm-dd' : $field['format'],
'timeFormat' => 'HH:mm',
'showButtonPanel' => true,
'separator' => ' ',
) );
return $field;
}
/**
* Returns a date() compatible format string from the JavaScript format
*
* @see http://www.php.net/manual/en/function.date.php
*
* @param array $field
*
* @return string
*/
static function translate_format( $field )
{
return strtr( $field['js_options']['dateFormat'], self::$date_format_translation )
. $field['js_options']['separator']
. strtr( $field['js_options']['timeFormat'], self::$time_format_translation );
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Divider_Field' ) )
{
class WCQD_METABOX_Divider_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style( 'rwmb-divider', WCQD_METABOX_CSS_URL . 'divider.css', array(), WCQD_METABOX_VER );
}
/**
* Show begin HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function begin_html( $meta, $field )
{
$attributes = empty( $field['id'] ) ? '' : " id='{$field['id']}'";
return "<hr$attributes>";
}
/**
* Show end HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html( $meta, $field )
{
return '';
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
// Make sure "text" field is loaded
require_once WCQD_METABOX_FIELDS_DIR . 'text.php';
if ( ! class_exists( 'WCQD_METABOX_Email_Field' ) )
{
class WCQD_METABOX_Email_Field extends WCQD_METABOX_Text_Field
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<input type="email" class="rwmb-email" name="%s" id="%s" value="%s" size="%s" placeholder="%s"/>',
$field['field_name'],
$field['id'],
$meta,
$field['size'],
$field['placeholder']
);
}
/**
* Sanitize email
*
* @param mixed $new
* @param mixed $old
* @param int $post_id
* @param array $field
*
* @return string
*/
static function value( $new, $old, $post_id, $field )
{
if ( $field['clone'] )
{
$new = (array) $new;
$new = array_map( 'sanitize_email', $new );
}
else
{
$new = sanitize_email( $new );
}
return $new;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Fieldset_Text_Field' ) )
{
class WCQD_METABOX_Fieldset_Text_Field extends WCQD_METABOX_Field
{
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
$html = array();
$tpl = '<label>%s <input type="text" class="rwmb-fieldset-text" name="%s[%d][%s]" value="%s"></label>';
for ( $row = 0; $row < $field['rows']; $row ++ )
{
foreach ( $field['options'] as $key => $label )
{
$value = isset( $meta[$row][$key] ) ? $meta[$row][$key] : '';
$html[] = sprintf( $tpl, $label, $field['id'], $row, $key, $value );
}
$html[] = '<br>';
}
$out = '<fieldset><legend>' . $field['desc'] . '</legend>' . implode( ' ', $html ) . '</fieldset>';
return $out;
}
/**
* Show end HTML markup for fields
* Do not show field description. Field description is shown before list of fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html( $meta, $field )
{
$button = $field['clone'] ? call_user_func( array( RW_Meta_Box::get_class_name( $field ), 'add_clone_button' ), $field ) : '';
// Closes the container
$html = "$button</div>";
return $html;
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field['multiple'] = false;
return $field;
}
/**
* Output the field value
* Display options in format Label: value in unordered list
*
* @param array $field Field parameters
* @param array $args Additional arguments. Not used for these fields.
* @param int|null $post_id Post ID. null for current post. Optional.
*
* @return mixed Field value
*/
static function the_value( $field, $args = array(), $post_id = null )
{
$value = self::get_value( $field, $args, $post_id );
if ( ! $value )
return '';
$output = '<table>';
$output .= '<thead><tr>';
foreach ( $field['options'] as $label )
{
$output .= "<th>$label</th>";
}
$output .= '</tr></thead><tbody>';
foreach ( $value as $subvalue )
{
$output .= '<tr>';
foreach ( $subvalue as $value )
{
$output .= "<td>$value</td>";
}
$output .= '</tr>';
}
$output .= '</tbody></table>';
return $output;
}
}
}
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
require_once WCQD_METABOX_FIELDS_DIR . 'file.php';
if ( ! class_exists( 'WCQD_METABOX_File_Advanced_Field' ) )
{
class WCQD_METABOX_File_Advanced_Field extends WCQD_METABOX_File_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
parent::admin_enqueue_scripts();
// Make sure scripts for new media uploader in WordPress 3.5 is enqueued
wp_enqueue_media();
wp_enqueue_script( 'rwmb-file-advanced', WCQD_METABOX_JS_URL . 'file-advanced.js', array( 'jquery', 'underscore' ), WCQD_METABOX_VER, true );
wp_localize_script( 'rwmb-file-advanced', 'rwmbFileAdvanced', array(
'frameTitle' => __( 'Select Files', 'meta-box' ),
) );
}
/**
* Add actions
*
* @return void
*/
static function add_actions()
{
parent::add_actions();
// Attach images via Ajax
add_action( 'wp_ajax_wcqd_metabox_attach_file', array( __CLASS__, 'wp_ajax_attach_file' ) );
add_action( 'print_media_templates', array( __CLASS__, 'print_templates' ) );
}
static function wp_ajax_attach_file()
{
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0;
$field_id = isset( $_POST['field_id'] ) ? $_POST['field_id'] : 0;
$attachment_ids = isset( $_POST['attachment_ids'] ) ? (array) $_POST['attachment_ids'] : array();
check_ajax_referer( "rwmb-attach-file_{$field_id}" );
foreach ( $attachment_ids as $attachment_id )
{
add_post_meta( $post_id, $field_id, $attachment_id, false );
}
wp_send_json_success();
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
$i18n_title = apply_filters( 'wcqd_metabox_file_advanced_select_string', _x( 'Select or Upload Files', 'file upload', 'meta-box' ), $field );
$attach_nonce = wp_create_nonce( "rwmb-attach-file_{$field['id']}" );
// Uploaded files
$html = self::get_uploaded_files( $meta, $field );
// Show form upload
$classes = array( 'button', 'rwmb-file-advanced-upload', 'hide-if-no-js', 'new-files' );
if ( ! empty( $field['max_file_uploads'] ) && count( $meta ) >= (int) $field['max_file_uploads'] )
$classes[] = 'hidden';
$classes = implode( ' ', $classes );
$html .= "<a href='#' class='{$classes}' data-attach_file_nonce={$attach_nonce}>{$i18n_title}</a>";
return $html;
}
/**
* Get field value
* It's the combination of new (uploaded) images and saved images
*
* @param array $new
* @param array $old
* @param int $post_id
* @param array $field
*
* @return array|mixed
*/
static function value( $new, $old, $post_id, $field )
{
$new = (array) $new;
return array_unique( array_merge( $old, $new ) );
}
static function print_templates()
{
$i18n_delete = apply_filters( 'wcqd_metabox_file_delete_string', _x( 'Delete', 'file upload', 'meta-box' ) );
$i18n_edit = apply_filters( 'wcqd_metabox_file_edit_string', _x( 'Edit', 'file upload', 'meta-box' ) );
?>
<script id="tmpl-rwmb-file-advanced" type="text/html">
<# _.each( attachments, function( attachment ) { #>
<li id="item_{{{ attachment.id }}}">
<div class="rwmb-icon">
<img src="<# if ( attachment.type == 'image' ){ #>{{{ attachment.sizes.thumbnail.url }}}<# } else { #>{{{ attachment.icon }}}<# } #>">
</div>
<div class="rwmb-info">
<a href="{{{ attachment.url }}}" target="_blank">{{{ attachment.title }}}</a>
<p>{{{ attachment.mime }}}</p>
<a title="<?php echo esc_attr( $i18n_edit ); ?>" href="{{{ attachment.editLink }}}" target="_blank"><?php echo esc_html( $i18n_edit ); ?></a> |
<a title="<?php echo esc_attr( $i18n_delete ); ?>" class="rwmb-delete-file" href="#" data-attachment_id="{{{ attachment.id }}}"><?php echo esc_html( $i18n_delete ); ?></a>
</div>
</li>
<# } ); #>
</script>
<?php
}
}
}
<?php
if ( ! class_exists( 'WCQD_METABOX_File_Input_Field' ) )
{
class WCQD_METABOX_File_Input_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
// Make sure scripts for new media uploader in WordPress 3.5 is enqueued
wp_enqueue_media();
wp_enqueue_script( 'rwmb-file-input', WCQD_METABOX_JS_URL . 'file-input.js', array( 'jquery' ), WCQD_METABOX_VER, true );
wp_localize_script( 'rwmb-file-input', 'rwmbFileInput', array(
'frameTitle' => __( 'Select File', 'meta-box' ),
) );
}
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html( $meta, $field )
{
return sprintf(
'<input type="text" class="rwmb-file-input" name="%s" id="%s" value="%s" placeholder="%s" size="%s">
<a href="#" class="rwmb-file-input-select button-primary">%s</a>
<a href="#" class="rwmb-file-input-remove button %s">%s</a>',
$field['field_name'],
$field['id'],
$meta,
$field['placeholder'],
$field['size'],
__( 'Select', 'meta-box' ),
$meta ? '' : 'hidden',
__( 'Remove', 'meta-box' )
);
}
/**
* Normalize parameters for field
*
* @param array $field
*
* @return array
*/
static function normalize_field( $field )
{
$field = wp_parse_args( $field, array(
'size' => 30,
'placeholder' => '',
) );
return $field;
}
}
}
This diff is collapsed.
<?php
// Prevent loading this file directly
defined( 'ABSPATH' ) || exit;
if ( ! class_exists( 'WCQD_METABOX_Heading_Field' ) )
{
class WCQD_METABOX_Heading_Field extends WCQD_METABOX_Field
{
/**
* Enqueue scripts and styles
*
* @return void
*/
static function admin_enqueue_scripts()
{
wp_enqueue_style( 'rwmb-heading', WCQD_METABOX_CSS_URL . 'heading.css', array(), WCQD_METABOX_VER );
}
/**
* Show begin HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function begin_html( $meta, $field )
{
$attributes = empty( $field['id'] ) ? '' : " id='{$field['id']}'";
return sprintf( '<h4%s>%s</h4>', $attributes, $field['name'] );
}
/**
* Show end HTML markup for fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html( $meta, $field )
{
$id = $field['id'] ? " id='{$field['id']}-description'" : '';
return $field['desc'] ? "<p{$id} class='description'>{$field['desc']}</p>" : '';
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment