This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Step 1: Add Data in a Custom Session, on ‘Add to Cart’ Button Click | |
| <?php | |
| add_action('wp_ajax_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback'); | |
| add_action('wp_ajax_nopriv_wdm_add_user_custom_data_options', 'wdm_add_user_custom_data_options_callback'); | |
| function wdm_add_user_custom_data_options_callback() | |
| { | |
| //Custom data - Sent Via AJAX post method | |
| $product_id = $_POST['id']; //This is product ID | |
| $user_custom_data_values = $_POST['user_data']; //This is User custom value sent via AJAX |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'woocommerce_register_form_start', 'prefix_add_name_woo_account_registration' ); | |
| function prefix_add_name_woo_account_registration() { | |
| ?> | |
| <p class="form-row form-row-first"> | |
| <label for="reg_billing_first_name"><?php _e( 'First name', 'woocommerce' ); ?> <span class="required">*</span></label> | |
| <input type="text" class="input-text" name="billing_first_name" id="reg_billing_first_name" value="<?php if ( ! empty( $_POST['billing_first_name'] ) ) esc_attr_e( $_POST['billing_first_name'] ); ?>" /> | |
| </p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * Paginate Advanced Custom Field repeater | |
| */ | |
| if( get_query_var('page') ) { | |
| $page = get_query_var( 'page' ); | |
| } else { | |
| $page = 1; | |
| } | |
| // Variables |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'rest_prepare_(post_type)', 'function_name', 10, 3 ); | |
| function function_name( $data, $post, $request ) { | |
| $_data = $data->data; | |
| $thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
| $thumbnail_full = wp_get_attachment_image_src( $thumbnail_id, 'full' ); | |
| $thumbnail_thumb = wp_get_attachment_image_src( $thumbnail_id, 'thumbnail' ); | |
| $thumbnail_medium = wp_get_attachment_image_src( $thumbnail_id, 'medium' ); | |
| $thumbnail_large = wp_get_attachment_image_src( $thumbnail_id, 'large' ); | |
| if( ! empty($thumbnail_id) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $wp_customize->add_setting( 'themeslug_dropdownpages_setting_id', array( | |
| 'capability' => 'edit_theme_options', | |
| 'sanitize_callback' => 'themeslug_sanitize_dropdown_pages', | |
| ) ); | |
| $wp_customize->add_control( 'themeslug_dropdownpages_setting_id', array( | |
| 'type' => 'dropdown-pages', | |
| 'section' => 'custom_section', // Add a default or your own section | |
| 'label' => __( 'Custom Dropdown Pages' ), | |
| 'description' => __( 'This is a custom dropdown pages option.' ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $upload_dir = wp_upload_dir(); | |
| $image_data = file_get_contents($image_url); | |
| $filename = basename($image_url); | |
| if(wp_mkdir_p($upload_dir['path'])) $file = $upload_dir['path'] . '/' . $filename; | |
| else $file = $upload_dir['basedir'] . '/' . $filename; | |
| file_put_contents($file, $image_data); | |
| $wp_filetype = wp_check_filetype($filename, null ); | |
| $attachment = array( | |
| 'post_mime_type' => $wp_filetype['type'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_shortcode( 'front_end_post_form', 'front_end_post_form' ); | |
| function front_end_post_form( $atts ) { | |
| ob_start();?> | |
| <script type="text/javascript"> | |
| jQuery(document).ready(function($) { | |
| $('#succes').hide(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Custom table example | |
| Description: example plugin to demonstrate wordpress capatabilities | |
| Plugin URI: http://mac-blog.org.ua/ | |
| Author URI: http://mac-blog.org.ua/ | |
| Author: Marchenko Alexandr | |
| License: Public Domain | |
| Version: 1.1 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Abstract class which has helper functions to get data from the database | |
| */ | |
| abstract class Base_Custom_Data | |
| { | |
| /** | |
| * The current table name | |
| * | |
| * @var boolean |