Skip to content

Instantly share code, notes, and snippets.

@bacoords
bacoords / wp-tinymce-fontsize.md
Last active June 9, 2016 17:03
Snippet to change TINYMCE fontsize to EMs

functions.php snippet to change TINYMCE fontsize to EMs

Source: wpexplorer.com

// Customize mce editor font sizes
if ( ! function_exists( 'wpex_mce_text_sizes' ) ) {
	function wpex_mce_text_sizes( $initArray ){
		$initArray['fontsize_formats'] = "0.25em 0.5em 0.75em 1em 1.25em 1.5em 1.75em 2em 2.25em 2.5em 2.75em 3em 3.25em 3.5em 3.75em 4em 4.25em 4.5em 4.75em 5em 5.25em 5.5em 5.75em 6em";
 return $initArray;
add_action( 'init', prefix_book_posttype' );
function prefix_book_posttype() {
$labels = array(
'name' => _x( 'Books', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Book', 'post type singular name', 'your-plugin-textdomain' ),
'menu_name' => _x( 'Books', 'admin menu', 'your-plugin-textdomain' ),
'name_admin_bar' => _x( 'Book', 'add new on admin bar', 'your-plugin-textdomain' ),
'add_new' => _x( 'Add New', 'book', 'your-plugin-textdomain' ),
'add_new_item' => __( 'Add New Book', 'your-plugin-textdomain' ),
'new_item' => __( 'New Book', 'your-plugin-textdomain' ),
@bacoords
bacoords / page-insert-from-google-sheets.php
Last active December 8, 2016 22:27
Page template to insert Google Sheets JSON feed into WordPress
<?php
//Template Name: Insert Json from Google Sheets
//Testing Mode First
$test = true;
//Google Sheet JSON Feed Url
$url = 'https://spreadsheets.google.com/feeds/list/{{UNIQUE-ID}}/od6/public/values?alt=json';
//Convert our JSON into a PHP Array
@bacoords
bacoords / page-insert-from-json-file.php
Last active March 15, 2020 08:20
Page template ton insert via json file
<?php
//Template Name: Insert Json File
//Testing Mode First
$test = true;
//If we've uploaded our JSON file with our theme
$url = get_template_directory_uri() . 'json/my-new-posts.json';
//Convert our JSON into a PHP Array
@bacoords
bacoords / at_a_glance_CPT.css
Last active April 20, 2016 15:29
Change icon for "At a Glance" on WP Dashboard
/* Change icon for "At a Glance" on WP Dashboard */
#dashboard_right_now .{custom-post-type}-count a:before, #dashboard_right_now .{custom-post-type}-count span:before{
content: "{glyphicon}";
}
/*Example*/
#dashboard_right_now .invoice-count a:before, #dashboard_right_now .invoice-count span:before{
content: "\f529";
}
@bacoords
bacoords / example-functions.php
Last active June 7, 2016 15:39
CMB2 Example Functions
// Source: CMB2 Wiki
// https://github.com/WebDevStudios/CMB2/blob/master/example-functions.php
// https://github.com/WebDevStudios/CMB2/wiki/Basic-Usage
add_action( 'cmb2_admin_init', 'prefix_register_demo_metabox' );
function prefix_register_demo_metabox() {
$prefix = '_prefix_'
/**
* Retrieve custom meta for use in the REST API
*
* @param array $object Details of current post.
* @param string $field_name Name of field.
* @param WP_REST_Request $request Current request
*
* @return mixed
*/
function prefix_get_custom_meta( $object, $field_name, $request ) {
//Register Meta with Rest API
add_action( 'rest_api_init', 'prefix_register_custom_meta' );
function prefix_register_custom_meta() {
register_rest_field(
'post',
'_prefix_url',
array(
'get_callback' => 'prefix_get_custom_meta',
'update_callback' => null,
'schema' => null,
if (_typeface_js && _typeface_js.loadFace) _typeface_js.loadFace({"glyphs":{"0":{"ha":656,"x_min":0,"x_max":0,"o":"m 328 -17 b 586 447 494 -17 586 153 b 328 906 586 742 494 906 b 69 447 161 906 69 742 b 328 -17 69 153 161 -17 z m 328 22 b 114 447 197 22 114 172 b 328 867 114 722 197 867 b 542 447 458 867 542 722 b 328 22 542 172 458 22 z "},"1":{"ha":656,"x_min":0,"x_max":0,"o":"m 119 0 l 569 0 l 569 39 l 372 39 l 372 889 l 336 889 b 172 836 297 867 242 847 l 172 806 l 331 806 l 331 39 l 119 39 z "},"2":{"ha":656,"x_min":0,"x_max":0,"o":"m 58 0 l 592 0 l 592 39 l 272 39 b 122 33 222 39 172 36 b 547 661 383 310 547 481 b 303 906 547 808 458 906 b 56 775 197 906 119 847 l 86 747 b 300 867 142 817 217 867 b 503 661 442 867 503 775 b 58 28 503 503 358 336 z "},"3":{"ha":656,"x_min":0,"x_max":0,"o":"m 319 -17 b 583 233 469 -17 583 81 b 378 467 583 361 489 444 l 378 472 b 550 694 475 504 550 575 b 317 906 550 828 447 906 b 81 797 214 906 139 856 l 108 767 b 317 867 158 822 233 867 b 506 692 431 867 506 797 b 219 48
//Access the global settings when setting up a custom module.
public function global_settings_method()
{
$settings = FLBuilderModel::get_global_settings();
return $settings->responsive_breakpoint;
}