A hand crafted markdown document contains all major Javascript topics covered, taken from different sources. Brush Up your JS memory.
Single line comments start with //. For multi-line commands, you use /* ... */
// This is a single line comment| <?php | |
| if(!@copy('https://sajjadhossain.me/file.zip','./somefile.zip')) | |
| // change the remote server link to your own file link | |
| { | |
| $errors= error_get_last(); | |
| echo "COPY ERROR: ".$errors['type']; | |
| echo "<br />\n".$errors['message']; | |
| } else { | |
| echo "File copied from remote!"; | |
| } |
| // Pest this code snipest in theme functions php file | |
| function show_last_modified_date( $content ) { | |
| $original_time = get_the_time('U'); | |
| $modified_time = get_the_modified_time('U'); | |
| if ($modified_time >= $original_time + 86400) { | |
| $updated_time = get_the_modified_time('h:i a'); | |
| $updated_day = get_the_modified_time('F jS, Y'); | |
| $modified_content .= '<p class="last-modified">Last updated on '. $updated_day . '</p>'; | |
| } | |
| $modified_content .= $content; |
| // pest this function in your theme functions.php file | |
| // Remove Query string of css/js files | |
| function sss_rssv_scripts() { | |
| global $wp_scripts; | |
| if (!is_a($wp_scripts, 'WP_Scripts')) | |
| return; | |
| foreach ($wp_scripts->registered as $handle => $script) |
| <?php | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; // Exit if accessed directly. | |
| } | |
| global $wpdb; | |
| $prefixd=$wpdb->prefix; | |
| $table=$prefixd.'tbl_area'; |
| add_filter( 'avatar_defaults', 'wpb_new_gravatar' ); | |
| function wpb_new_gravatar ($avatar_defaults) { | |
| $myavatar = 'http://example.com/wp-content/uploads/2017/01/wpb-default-gravatar.png'; | |
| $avatar_defaults[$myavatar] = "Default Gravatar"; | |
| return $avatar_defaults; | |
| } |
| function woocommerce_cart_link() { | |
| global $woocommerce; | |
| ?> | |
| <a href="<?php echo esc_url($woocommerce->cart->get_cart_url()); ?>" title="<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> <?php _e('in your shopping cart', 'woothemes'); ?>" class="cart-button "> | |
| <span class="label"><?php esc_html_e('My Basket:', 'woothemes'); ?></span> | |
| <?php echo esc_html($woocommerce->cart->get_cart_total()); ?> | |
| <span class="items"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?></span> | |
| </a> | |
| <?php | |
| } |
| <?php | |
| add_action( 'pre-upload-ui', 'get_the_post_type' ); | |
| function get_the_post_type() { | |
| $post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post'; | |
| set_transient( 'attached_post_type', $post_type ); | |
| } | |
| add_filter( 'intermediate_image_sizes_advanced', 'add_image_size_for_post_type', 10 ); | |
| function add_image_size_for_post_type( $sizes ) { |