This file contains 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: WP Gears & Heartbeat | |
Version: 0.0.6 | |
Description: Testing WP Gears and the Heartbeat API | |
Author: Per Soderlind | |
Author URI: https://soderlind.no | |
Plugin URI: https://gist.github.com/soderlind/94629e4ae933407d823c | |
License: GPL | |
*/ |
This file contains 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 | |
/* | |
* solves the problem at http://stackoverflow.com/questions/31002690/how-to-use-similar-text-php-code-in-arabic, not that I know Arabic, but Norwegian also has multibyte charachters: æøåÆØÅ | |
*/ | |
//from http://www.phperz.com/article/14/1029/31806.html | |
function mb_split_str($str) { | |
preg_match_all("/./u", $str, $arr); | |
return $arr[0]; | |
} |
This file contains 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
// dropzoneWordpressForm is the configuration for the element that has an id attribute | |
// with the value dropzone-wordpress-form (or dropzoneWordpressForm) | |
Dropzone.options.dropzoneWordpressForm = { | |
//acceptedFiles: "image/*", // all image mime types | |
acceptedFiles: ".jpg", // only .jpg files | |
maxFiles: 1, | |
uploadMultiple: false, | |
maxFilesize: 5, // 5 MB | |
//addRemoveLinks: true, | |
//dictRemoveFile: 'X (remove)', |
This file contains 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
/* | |
Uploading images is a two step process (from https://github.com/WP-API/WP-API/issues/1768#issuecomment-160540932): | |
POST the data to /wp/v2/media - this can either be as the request body, or in multipart format. This will upload the file, and give you a 201 Created response with a Location header. This header points to the post object for the attachment that has just been created. | |
PUT the post data to the endpoint returned in the Location header (which will look something like /wp/v2/media/{id}). | |
I do step 2 (PUT), if POST is a success, in myDropzone.on("success", function(file, response){} | |
*/ | |
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute |
This file contains 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
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute | |
// with the value dropzone-wordpress-rest-api-form (or dropzoneWordpressRestApiForm) | |
Dropzone.options.dropzoneWordpressRestApiForm = { | |
//acceptedFiles: "image/*", // all image mime types | |
acceptedFiles: ".jpg", // only .jpg files | |
maxFiles: 1, | |
uploadMultiple: false, | |
maxFilesize: 5, // 5 MB | |
init: function() { | |
console.group('dropzonejs-wp-rest-api:'); |
This file contains 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
jQuery(document).ready(function($){ | |
if (wp.media) { | |
wp.media.view.Modal.prototype.on('open', function() { | |
console.log('media modal open'); | |
}); | |
} | |
}); |
This file contains 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
# #!/bin/bash | |
# # | |
# # provision-post.sh (save the file in VVV/provision) | |
# # | |
# # Adding Gearman to VVV | |
# # | |
# # This file is specified in Vagrantfile and is loaded by Vagrant _after_ the primary | |
# # provisioning script whenever the commands `vagrant up`, `vagrant provision`, | |
# # or `vagrant reload` are used. |
This file contains 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 | |
function load_divi_fix() { | |
global $wp_scripts; | |
wp_enqueue_script( 'jquery-ui-core' ); | |
// get registered script object for jquery-ui | |
$ui = $wp_scripts->query( 'jquery-ui-core' ); | |
// dequeue old style and scripts loaded by the Divi theme | |
wp_dequeue_style( 'et_pb_admin_date_css' ); |
This file contains 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 | |
class First_Page_Image { | |
private static $instance; | |
private static $post_ID = 0; | |
public static function instance() { | |
if ( self::$instance ) { | |
return self::$instance; | |
} |
This file contains 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: On save/update, convert nbsp to space | |
* | |
* From http://wordpress.stackexchange.com/a/168358, modified by me | |
* | |
* @package 'dss_convert_nbsp_wp_insert_post_data' | |
*/ | |
add_filter( 'wp_insert_post_data', 'dss_convert_nbsp_wp_insert_post_data', '99', 2 ); |