• Varun Sridharan's avatar
    WooCommerce Quick Donation 1.3.x Beta Version · 9c660c91
    Varun Sridharan authored
    Redeveloping The Plugin.
    Created Custom Post Type
    Created Custom Taxonomy {Category & Tags}
    Created Short code
    Project Output Like Select , Radio [Single or grouped]
    Price Box Output
    Customization Template
    
    [admin/class-admin-init.php]
    
    Added woocommerce_screen_ids
    Removed Admin Notice Handler Class Init
    Added Plugins Settings Page ID To WC Screen ID
    
    [admin/class-admin-settings.php & admin/class-donation-settings.php]
    
    Working To Get A Prefect Settings Page
    
    [admin/includes/class-admin-functions.php]
    
    Changed WC_QD()->donation_id to WC_QD_ID
    
    [includes/class-quick-donation-process.php]
    
    Created Class To Process Front End Donation Form
    
    [includes/class-shortcode-handler.php]
    
    Created 2 Actions
    wc_quick_donation_before_donation_form
    wc_quick_donation_after_donation_form
    
    [woocommerce-quick-donation.php]
    
    Changed $donation_id from dynimic to static
    Added WC_QD_ID defined variable
    
    Rearranged Few Loading Files
    
    Added Donation Processing Email
    Added Prefect Settings Framework
    Added Seperate Page For Listing Donations
    9c660c91
date.php 2.64 KB
<?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;
		}
	}
}