This file contains hidden or 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 | |
| /** | |
| * Update an objects term order in the term relationships table | |
| * @param int $term_order | |
| * @param int $object_id post_od | |
| * @param int $tt_id term_taxonomy_id | |
| * | |
| * @return int | |
| */ | |
| function set_taxonomy_term_term_order( $term_order, $object_id, $tt_id ) { |
This file contains hidden or 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
| function maybe(fn) { | |
| return function() { | |
| var i; | |
| if ( arguments.length === 0 ) { | |
| return; | |
| } else { | |
| for(i = 0; i < arguments.length; i++) { | |
| if (arguments[i] == null) return; | |
| } | |
| return fn.apply(this, arguments); |
This file contains hidden or 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
| //Once | |
| function once(fn) { | |
| var done = false; | |
| return function() { | |
| return done ? void 0 : ((done = true), fn.apply(this, arguments)); | |
| }; | |
| } | |
| var askedOnBlindDate = once(function () { |
This file contains hidden or 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
| var events = { | |
| events: {}, | |
| subscribe: function (eventName, fn) { | |
| this.events[eventName] = this.events[eventName] || []; | |
| this.events[eventName].push(fn); | |
| }, | |
| unsubscribe: function(eventName, fn) { | |
| if (this.events[eventName]) { | |
| this.events[ eventName ] = this.events[ eventName ].filter( function( eventFn ) { | |
| return eventFn !== fn; |
This file contains hidden or 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 | |
| //Closure Example | |
| $add = function($x) { | |
| return function($y) use ($x) { | |
| return $x + $y; | |
| }; | |
| }; | |
| $addTen = $add(10); |
This file contains hidden or 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
| var typeOf = function( type ) { | |
| return function( value ) { | |
| if ( typeof value !== type ) { | |
| throw new TypeError( 'Expected a ' + type + '!' ); | |
| } else { | |
| return value; | |
| } | |
| }; | |
| }; |
This file contains hidden or 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 | |
| $users = array( 'John', "Bobby", 'Alex' ); | |
| function filter( $fn ) { | |
| return function( $arr ) use ( $fn ) { | |
| return array_filter( $arr, $fn ); | |
| }; | |
| } | |
| function get( $value ) { |
This file contains hidden or 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 | |
| <label class="layout-label"> | |
| <input type="radio" | |
| name="package_template_layout" | |
| class="layout-input" | |
| value="three-column-layout" | |
| <?php checked( $layout, "three-column-layout" ); ?>/> | |
| <img class="layout-image" src="<?php echo get_template_directory_uri() . '/images/package-layouts/InvestorPlace_Layout_1.png'; ?>" width="1182" height="1294" > | |
| </label> |
This file contains hidden or 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 read_project_svg_assets( $directory ) { | |
| $files = []; | |
| $path = get_template_directory() . '/library/assets/*.svg'; | |
| foreach ( glob( $path ) as $filename ) { | |
| $path_parts = pathinfo( $filename ); | |
| $files[] = $path_parts['filename']; | |
| } | |
| $svgs = []; | |
| foreach ( $files as $svg_name ) { |
This file contains hidden or 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 wp_code_context() { | |
| $theme = strpos( __DIR__, 'themes' ); | |
| return ( $theme ) ? 'theme' : 'plugin'; | |
| } | |
| function get_directory_by_context() { | |
| $context = wp_code_context(); | |
| switch( $context ) { | |
| case 'theme': | |
| $local_dir = get_template_directory(); |