Within the edit function of block.js var el = wp.element.createElement, Fragment = wp.element.Fragment, registerBlockType = wp.blocks.registerBlockType, InspectorControls = wp.editor.InspectorControls, RadioControl = wp.components.RadioControl, ColorPicker = wp.components.ColorPicker;//this this el(‘div’, {}, ‘Menu Background’), el(ColorPicker, { type: ‘color’, color: menu_bg, onChangeComplete: function(newValue) { props.setAttributes({ menu_bg: newValue.hex }); }, disableAlpha: true }),
Add Arguments to WordPress Hooks
function jma_gbs_template_redirect() { $body = true; add_action( ‘genesis_before_sidebar_widget_area’, function () use ($body) { jma_gbs_open_div($body); } ); add_action( ‘genesis_before_loop’, function () use ($body) { jma_gbs_open_div($body); } ); add_action( ‘genesis_after_sidebar_widget_area’, function () use ($body) { jma_gbs_close_div($body); } ); add_action( ‘genesis_after_loop’, function () use ($body) { jma_gbs_close_div($body); } ); } add_action(‘template_redirect’, ‘jma_gbs_template_redirect’);
Debug
define(‘WP_DEBUG’, true); define(‘WP_DEBUG_LOG’, true); define(‘WP_DEBUG_DISPLAY’, false);
Add simple meta box(s)
/* * When the post is saved, saves our custom data. * * @param int $post_id The ID of the post being saved. */ /* * Adds a box to the main column on the Post and Page edit screens. */ function jma_add_linkedin_input_box() { $screens = array(‘volunteer’); foreach ($screens as $screen) { add_meta_box( ‘jma_linkedin_input_section’, __(‘Linkedin […]
Title Filtering
What ever you do is going to end up within the h1 tag, but this will keep it out of the menu etc. function personnel_filter($x) { $value = get_field(‘position’); $x = ‘<div class=”person-sub”>’ . $value . ‘</div><!–person-sub–>’ . $x; return $x; } function jma_person_title_cond($query) { global $wp_query; if ($query === $wp_query) { add_filter(‘the_title’, ‘personnel_filter’, 10, […]
Soliloquy Slider for Testimonials
Install and populate woo testimonials plugin: Extract and import this .json file into slider (the .jma-testimonials class isincluded in this import): soliloquy-73-05-11-2018.json.tar /* testimonial slider */ .jma-testimonials { max-height: inherit !important; } .jma-testimonials .soliloquy-caption { position: static !important; display: block !important } .jma-testimonials .soliloquy-caption-inside { position: absolute !important; top: 0 !important; width: 100% !important; height: […]
Options Page for Plugin
Original code: https://gist.github.com/hlashbrooke/9267467 First the Files (2) The Class: <?php if ( ! defined( ‘ABSPATH’ ) ) exit; class JMAYtSettings { private $dir; private $file; private $assets_url; private $settings_base; private $settings; private $db_option; private $page_title; private $text_domain; public function __construct($base = ‘jma_plugin’, $title = ‘Cool Plugin’, $settings = array(), $text_domain = ”) { $this->file = […]
Detect Shortcode
if(!function_exists(‘jma_yt_detect_shortcode’)){ function jma_yt_detect_shortcode( $needle = ”, $post_item = 0 ){ if($post_item){ if(is_object($post_item)) $post = $post_item; else $post = get_post($post_item); }else{ global $post; } if(is_array($needle)) $pattern = get_shortcode_regex($needle); elseif(is_string($needle)) $pattern = get_shortcode_regex(array($needle)); else $pattern = get_shortcode_regex(); preg_match_all( ‘/’. $pattern .’/s’, $post->post_content, $matches ); if(//if shortcode(s) to be searched for were passed and not found $return false […]
Solve HTTP Error in Media Library
Add to functions.php function change_graphic_lib($array) { return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ ); } add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ );