View replace-textdomain.sh
#!/bin/bash | |
#get the textdomain from the package.json file. | |
#export TEXTDOMAIN | |
TEXTDOMAIN=$(node -pe "require('./package.json').textdomain") | |
# if there is a textdomain, apply to the vendor folder. | |
if [ "$TEXTDOMAIN" != "undefined" ]; then | |
find "vendor" -type f -name "**.php" -exec sed -i "s/, 'textdomain' )/, '$TEXTDOMAIN' )/g" {} + | |
fi; |
View wp_disable_jquery_warnings.php
<?php | |
function disable_jquerymigrate_warning( $scripts ) { | |
if ( ! empty( $scripts->registered['jquery'] ) ) { | |
$scripts->registered['jquery']->deps = array_diff( $scripts->registered['jquery']->deps, array( 'jquery-migrate' ) ); | |
} | |
} | |
add_action( 'wp_default_scripts', 'disable_jquerymigrate_warning' ); |
View customify_conditional_fields.php
<?php | |
/** | |
* This shows how the field visibility can be changed conditionally between fields values | |
**/ | |
function example_add_customify_fold_example_options( $options ) { | |
$folding_examples_section = array( | |
'folding_section' => array( | |
'title' => esc_html__( 'Folding', 'example' ), | |
'options' => array( |
View gridable_editable_attributes.php
<?php | |
add_filter( 'gridable_row_options', function ( $options ) { | |
$options['bg_color'] = array( | |
'type' => 'color', | |
'label' => 'Row Background Color', | |
'default' => 'transparent' | |
); |
View fix_featured_listings_meta.php
<?php | |
/** | |
* Delete all the duplicated `_featured` meta data | |
**/ | |
function clear_listings(){ | |
global $post; | |
$q_args = array( | |
'post_type' => 'job_listing', |
View pixcare-auto-installer.php
<?php | |
/** | |
* A WordPress theme script which redirects the admin user, after the first theme activation, on a page where | |
* it forces a plugin installation, in this case, the Pixelgrade Care plugin. | |
* | |
* Inspired from | |
* WooCommerce - https://github.com/woocommerce/woocommerce | |
* Envato WordPress Theme Setup Wizard - https://github.com/dtbaker/envato-wp-theme-setup-wizard | |
* Shiny Updates V3 - https://make.wordpress.org/core/2016/07/06/shiny-updates-in-4-6/ | |
* |
View WordPress Paginated API results
<?php | |
/** | |
* Let's imagine that we need the issues number from an github organization | |
* The issues API results are limited to 100 per page so we need to call this recursively | |
* $offset (int) = the number of pages to skip for the current request | |
*/ | |
function request_issues_number( $offset = 0 ) { | |
$page = 1; | |
if ( ! empty( $offset ) ) { |
View tinymce.plugin.example.js
(function () { | |
/** | |
* A TinyMCE plugin example and some events handlings. | |
*/ | |
tinymce.PluginManager.add('gridable', function ( editor, url ) { | |
// if your plugin needs a toolbar, save it for a larger scope | |
var toolbar; | |
/** |
View How to send a POST request from WordPress admin Dashboard – JS
(function(){ | |
var request = wp.ajax.post('custom_action', {param1: 'uppercase this string pls'}); | |
// on success | |
request.done( function ( res ) { | |
console.log( res ); | |
}); | |
// on fail |