Sunday, May 24, 2015

Wordpress woocommerce shipping payment change on postcode

function custom_override_checkout_fields( $fields ) {
$fields['billing']['billing_postcode'] = array(
   'label'     => __('Postcode', 'woocommerce'),
   'placeholder'   => _x('Postcode', 'placeholder', 'woocommerce'),
   'required'    => true,
   'clear'       => false,
   'type'        => 'select',
            'class' => array('update_totals_on_change'),
   'options'     => array(
        'E1' => __('E1', 'woocommerce' ),
        'E2' => __('E2', 'woocommerce' )
        )
 );
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );


Thursday, February 19, 2015

How to include redux framework in your theme functions.php



if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( __FILE__ ) . '/redux-framework/ReduxCore/framework.php' ) ) {
    require_once( dirname( __FILE__ ) . '/redux-framework/ReduxCore/framework.php' );
}
if ( !isset( $redux_demo ) && file_exists( dirname( __FILE__ ) . '/redux-framework/sample/sample-config.php' ) ) {
    require_once( dirname( __FILE__ ) . '/redux-framework/sample/sample-config.php' );
}

Hook wp_enqueue_scripts load in header and footer


function load_scripts_basic() {

    global $wp_scripts;
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    wp_enqueue_style( 'style-bootstrap', get_template_directory_uri().'/css/bootstrap.min.css' );
    wp_enqueue_style( 'style-normalize', get_template_directory_uri().'/css/normalize.css' );
    wp_enqueue_style( 'style-awesome', get_template_directory_uri().'/css/font-awesome.min.css' );
    wp_enqueue_style( 'style-main', get_template_directory_uri().'/css/styles.css' );
    wp_enqueue_style( 'style-eng', get_template_directory_uri().'/engine1/style.css' );

    wp_enqueue_script( 'jquery-min', get_template_directory_uri() . '/js/jquery.min.js', false );
    wp_enqueue_script( 'jquery-res_collapse_menu', get_template_directory_uri() . '/js/res_collapse_menu.js', array(), '1.0.0', false );
  

    wp_enqueue_script( 'jquery-fade', get_template_directory_uri() . '/js/fade.js', array(), '1.0.0', false );
    wp_enqueue_script( 'bootstrap.newsbox', get_template_directory_uri() . '/js/jquery.bootstrap.newsbox.min.js', array(), '1.0.0', false );

    wp_register_script('html5shiv',get_bloginfo('template_url').'/js/html5shiv.js',array(),'1.0.0');
    $wp_scripts->add_data( 'html5shiv', 'conditional', 'lt IE 9' );

    wp_register_script('respond.min', get_bloginfo('template_url').'/js/respond.min.js', array(), '1.0.0' );
    $wp_scripts->add_data( 'respond.min', 'conditional', 'lt IE 9' );

// load script in footer
    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0.0', true );
    wp_enqueue_script( 'cbpAnimatedHeader', get_template_directory_uri() . '/js/cbpAnimatedHeader.js', array(), '1.0.0', true );
    wp_enqueue_script( 'custom', get_template_directory_uri() . '/js/custom.js', array(), '1.0.0', true );


}
add_action( 'wp_enqueue_scripts', 'load_scripts_basic' );

Creating a meta box for posts Titan Framework



if ( !class_exists( 'TitanFramework' ) && file_exists( dirname( __FILE__ ) . '/titan/titan-framework-embedder.php' ) ) {
    require_once( dirname( __FILE__ ) . '/titan/titan-framework-embedder.php' );
}


function theme_meta_options() {
    $titan = TitanFramework::getInstance( 'pmi' );
    $myMetaBox = $titan->createMetaBox( array(
        'name' => 'Event Option',
        'post_type'  =>array('post')
    ) );

    $myMetaBox->createOption(array(
        'name'  => 'Event Start Date & Time',
        'type'  => 'date',
        'id'    => 'eventdatentime',
        'desc'  => 'Event Data & time',
        'date'  => true,
        'time'  => true
    )) ;


    $myMetaBox->createOption( array(
        'name' => 'Venue',
        'id' => 'event_venue',
        'type' => 'text',
        'desc' => 'Venue Address',

    ) );

    $myMetaBox->createOption(array(
        'name'  => 'End Date & Time',
        'type'  => 'date',
        'id'    => 'eventenddatentime',
        'desc'  => 'Event End Data & time',
        'date'  => true,
        'time'  => true
    )) ;

}

add_action( 'tf_create_options', 'theme_meta_options' );

Friday, October 10, 2014

Create custom add_menu_page and add_submenu_page in admin panel


function theme_options_panel(){
  add_menu_page('Theme page title', 'Theme menu label', 'manage_options', 'theme-options', 'wps_theme_func');
  add_submenu_page( 'theme-options', 'Settings page title', 'Settings menu label', 'manage_options', 'theme-op-settings', 'wps_theme_func_settings');
  add_submenu_page( 'theme-options', 'FAQ page title', 'FAQ menu label', 'manage_options', 'theme-op-faq', 'wps_theme_func_faq');
}
add_action('admin_menu', 'theme_options_panel');

function wps_theme_func(){
                
}
function wps_theme_func_settings(){
                
}
function wps_theme_func_faq(){
                
}

Wednesday, May 7, 2014

Remove shortcode from the_content_rss


 
function filter_shortcode_from_content_rss($content) {
$content = strip_shortcodes($content);
return $content;
}
add_filter('the_content_rss', 'filter_shortcode_from_content_rss');

Thursday, February 6, 2014

Deleting WordPress Revisions


DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'