This file contains 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 | |
// Register a Book post type | |
$args = array( | |
'labels' => generate_post_type_labels( 'book', 'books' ), | |
'public' => true, | |
'publicly_queryable' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'query_var' => true, |
This file contains 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 | |
/** | |
* A block with an image and text on the side | |
*/ | |
class CoderPad_Text_Image_Block { | |
/** | |
* Get an instance of this class | |
*/ | |
public static function get_instance() { |
This file contains 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 | |
/** | |
* A block with an image and text on the side | |
*/ | |
class CoderPad_Text_Image_Block { | |
/** | |
* Get an instance of this class | |
*/ | |
public static function get_instance() { |
This file contains 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
#!/bin/bash | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
TARGET_BRANCH=staging | |
git fetch origin $TARGET_BRANCH | |
git checkout $TARGET_BRANCH | |
git merge "$CURRENT_BRANCH" -m "Merge branch '$CURRENT_BRANCH' into $TARGET_BRANCH" | |
git push origin $TARGET_BRANCH | |
git checkout "$CURRENT_BRANCH" |
This file contains 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 | |
$key_file_path = __DIR__ . '/service-account-credentials.json'; | |
$google_client = new \Google_Client(); | |
$google_client->setAuthConfig( $key_file_path ); | |
// Set the scopes of whatever you need access to | |
// See https://developers.google.com/identity/protocols/oauth2/scopes | |
$google_client->setScopes( array( 'https://www.googleapis.com/auth/analytics.readonly' ) ); | |
$http_client = $client->authorize(); |
This file contains 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 | |
/** Loads environment specific config files for WordPress. | |
* See https://github.com/studio24/wordpress-multi-env-config and/or http://abandon.ie/notebook/wordpress-configuration-for-multiple-environments | |
* | |
* Environment can be: | |
* 1. Directly loaded via an Environment variable (Name: WP_ENV) | |
* 2. Looks the ServerName attribute | |
* 3. Default to production (if no other one is found) | |
* | |
* ** Usage ** |
This file contains 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 | |
/** | |
* Plugin Name: River Height Levels | |
* Plugin URI: https://gist.github.com/kingkool68/567527d28f82bd3a0107970b624fea0a | |
* Description: Fetch the current river height values and display it as different data visualization. | |
* Version: 0.0.2 | |
* Author: Russell Heimlich | |
* Author URI: https://twitter.com/kingkool68 | |
* License: GPL v2 or later | |
* License URI: https://www.gnu.org/licenses/gpl-2.0.html |
This file contains 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 | |
/** | |
* Load an external CSV file and store it as a transient | |
*/ | |
function get_the_csv_data() { | |
$transient_key = 'the-csv-data'; | |
$data = get_transient( $transient_key ); | |
// If the data already exists then return it. We're done here! | |
if ( false !== $data ) { |
This file contains 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 | |
// Expects a page with the slug (aka post_name) set to `post-type` (the same post-type key as the custom post type) | |
$post = RH_Post_Type_Archives::get_post_type_archive_post(); | |
setup_postdata( $post ); | |
?> | |
<h1><?php the_title(); ?></h1> | |
<?php the_content(); ?> |
This file contains 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 | |
/** | |
* Make WordPress respond to a request for a URL that doesn't actually exist | |
*/ | |
if ( ! function_exists( 'str_starts_with' ) ) { | |
/** | |
* Polyfill for PHP 8's str_starts_with | |
* | |
* @link https://php.watch/versions/8.0/str_starts_with-str_ends_with |