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
import queryString from 'query-string'; | |
import { getSpinner } from './components'; | |
/** | |
* Implementation Example at the very bottom. | |
*/ | |
export default function( settings ) { | |
let page = 2; | |
let buttonContent; | |
let headers; |
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 | |
/** | |
* This function will return all the image data (id, url) | |
* @param $post_id int The post id. | |
* @param $name string the name of your custom field you used when creating the field. | |
* | |
* @return mixed | |
*/ | |
function get_custom_upload( $post_id, $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
function divisibleBy3(number) { | |
return number % 3 === 0; | |
} | |
function divisibleBy5(number) { | |
return number % 5 === 0; | |
} | |
function divisibleByBoth(number) { | |
return divisibleBy3(number) && divisibleBy5(number); |
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 nodeListMap(data) { | |
return function(callback) { | |
return [].map.call( data, callback ); | |
} | |
} | |
function nodeListMap(data, callback) { | |
return [].map.call( data, callback ); | |
} |
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 converts the user provided query object into an encoded query string. | |
* @param {Object} argsObj The user provided query object from query method. | |
* @return {String} The query string portion of the endpoint url. | |
*/ | |
const buildQuery = (argsObj) => { | |
let queryString = []; | |
for (var property in argsObj) { | |
if (argsObj.hasOwnProperty(property)) { | |
queryString.push( |
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
<div style="width: 70%; margin: 0 auto;"> | |
<form id="user-post"> | |
<?php wp_nonce_field( basename( __FILE__ ), 'user-submitted-question' ) ?> | |
<input type="text" id="user-name" name="user-name" placeholder="Name" style="margin-bottom: 10px;"> | |
<input type="text" id="user-email" name="user-email" placeholder="Email" style="margin-bottom: 10px;"> | |
<select name="product" id="product" style="margin-bottom: 10px;"> | |
<option value=""></option> | |
<option value="hosting">Hosting</option> | |
<option value="themes">Themes</option> | |
<option value="plugins">Plugins</option> |
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
$( document).ready( function() { | |
var userSubmitButton = document.getElementById( 'user-submit-button' ); | |
var adminAjaxRequest = function( formData, action ) { | |
$.ajax({ | |
type: 'POST', | |
dataType: 'json', | |
url: screenReaderText.adminAjax, | |
data: { | |
action: action, |
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 register_user_question_content_type() { | |
$post_labels = array( | |
'name' => 'User Questions', | |
'singular_name' => 'User Question', | |
'add_new' => 'Add New', | |
'add_new_item' => 'Add New User Question', | |
'edit' => 'Edit', | |
'edit_item' => 'Edit User Question', | |
'new_item' => 'New User Question', |
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(); |
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 ) { |
NewerOlder