Create an empty git repo or reinitialize an existing one
$ git init
Create an empty git repo or reinitialize an existing one
$ git init
<?php | |
function example_ajax_enqueue() { | |
// Enqueue javascript on the frontend. | |
wp_enqueue_script( | |
'example-ajax-script', | |
get_template_directory_uri() . '/js/simple-ajax-example.js', | |
array( 'jquery' ) | |
); |
console.log(1); | |
(_ => console.log(2))(); | |
eval('console.log(3);'); | |
console.log.call(null, 4); | |
console.log.apply(null, [5]); | |
new Function('console.log(6)')(); | |
Reflect.apply(console.log, null, [7]) | |
Reflect.construct(function(){console.log(8)}, []); | |
Function.prototype.apply.call(console.log, null, [9]); | |
Function.prototype.call.call(console.log, null, 10); |
<?php | |
// Standard API query arguments | |
$args = array( | |
'orderby' => 'title', | |
'per_page' => 3 | |
); | |
// Put into the `add_query_arg();` to build a URL for use | |
// Just an alternative to manually typing the query string | |
$url = add_query_arg( $args, rest_url('wp/v2/posts') ); |
<?php | |
function tomjn_rest_test() { | |
return "moomins"; | |
} | |
add_action( 'rest_api_init', function () { | |
register_rest_route( 'tomjn/v1', '/test/', array( | |
'methods' => 'GET', | |
'callback' => 'tomjn_rest_test' |
<?php | |
/** | |
* Enqueue scripts and styles. | |
* | |
* @since 1.0.0 | |
*/ | |
function ja_global_enqueues() { | |
wp_enqueue_style( | |
'jquery-auto-complete', |
Ajax Media Upload with jQuery and WP-API http://www.roysivan.com/ajax-media-upload-jquery-wp-api/
Ajax callback tests https://gist.github.com/franz-josef-kaiser/8804885
Ajax in WordPress, a Class based example https://gist.github.com/franz-josef-kaiser/6902888
Example showing how to use AJAX in WordPress
// Get Youtube URL | |
$yturl = 'https://www.youtube.com/watch?v=HhAKNSsb4t4'; | |
preg_match("/^(?:http(?:s)?:\/\/)?(?:www\.)?(?:m\.)?(?:youtu\.be\/|youtube\.com\/(?:(?:watch)?\?(?:.*&)?v(?:i)?=|(?:embed|v|vi|user)\/))([^\?&\"'>]+)/", $yturl, $matches); | |
$video_id = $matches[1]; | |
// Get Thumbnail | |
$file_headers = get_headers( 'http://img.youtube.com/vi/' . $video_id . '/maxresdefault.jpg' ); | |
$is_404 = $file_headers[0] == 'HTTP/1.0 404 Not Found' || false !== strpos( $file_headers[0], '404 Not Found' ); | |
$video_thumbnail_url = $is_404 ? 'http://img.youtube.com/vi/' . $youtube_id . '/maxresdefault.jpg' : 'http://img.youtube.com/vi/' . $video_id . '/hqdefault.jpg'; |
<?php | |
// change the number of products per row | |
add_filter( 'loop_shop_columns', 'patricks_loop_columns', 20 ); | |
function patricks_loop_columns() { | |
return 5; // the number of products per row | |
} | |
// you still need to add CSS to make it look right. In Storefront you can add this to your style.css file. | |
// @media (min-width:768px){ | |
// .products .product { |
<!-- add to head of your theme.liquid after moving the files into the assets folder | https://www.woothemes.com/flexslider/ --> | |
<!-- add only if you theme is not already including Jquery--> | |
{{ '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js' | script_tag }} | |
<!-- FLEX Slider css and .js --> | |
{{ 'flexslider.css' | asset_url | stylesheet_tag }} | |
{{ 'jquery.flexslider.js' | asset_url | script_tag }} | |
<!-- | |
add to schema json |