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: Remove Slug from Custom Post Type | |
* Description: Remove slug from custom post type URLs. | |
* Version: 0.1.0 | |
* Author: Kellen Mace | |
* Author URI: https://kellenmace.com/ | |
* License: GPLv2 or later | |
* License URI: http://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 | |
/** | |
* Delete all transients from the database whose keys have a specific prefix. | |
* | |
* @param string $prefix The prefix. Example: 'my_cool_transient_'. | |
*/ | |
function delete_transients_with_prefix( $prefix ) { | |
foreach ( get_transient_keys_with_prefix( $prefix ) as $key ) { | |
delete_transient( $key ); |
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
import { formatDistance, parseISO } from 'date-fns'; | |
// Example string date | |
const dateString: string = "2023-05-23"; | |
// Parse the string date into a JavaScript Date object | |
const date: Date = parseISO(dateString); | |
// Get the current date | |
const currentDate: Date = new Date(); |
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: WPGraphQL Previous / Next Pagination | |
* Description: Enables Previous / Next Pagination via WPGraphQL | |
* Version: 0.1.0 | |
* Author: Kellen Mace | |
* Author URI: https://kellenmace.com/ | |
* License: GPLv2 or later | |
* License URI: http://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 | |
/** | |
* Return the post excerpt, if one is set, else generate it using the | |
* post content. If original text exceeds $num_of_words, the text is | |
* trimmed and an ellipsis (…) is added to the end. | |
* | |
* @param int|string|WP_Post $post_id Post ID or object. Default is current post. | |
* @param int $num_words Number of words. Default is 55. | |
* @return string The generated excerpt. |
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 | |
/** | |
* Class for getting a list of Beaver Builder modules. | |
*/ | |
class KM_Beaver_Builder_Module_List { | |
/** | |
* Get the list of Beaver Builder modules. | |
* | |
* @param int $post_id The post ID. Default is the current post being |
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 | |
/** | |
* Set/update the value of a transient. | |
* | |
* Transients set using this function can later be deleted in bulk | |
* based on their prefix using rth_delete_transients(). | |
* | |
* @param string $key Transient key. | |
* @param mixed $value Transient value. |
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 | |
/** | |
* Get the root domain of the site/network. | |
* | |
* @return string|bool The root domain or false on failure. | |
*/ | |
function km_get_root_domain() { | |
$url_parts = parse_url( km_get_main_site_url() ); |
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
const fetch = require("node-fetch"); | |
const xml2js = require("xml2js"); | |
const he = require("he"); | |
const TRANSCRIPTION_CHAR_KEY = "transcription"; | |
// Test | |
(async () => { | |
const videoId = "ht14hTTDklA"; // HWPR Pagination video | |
// const videoId = "rB9ql0L0cUQ"; // Video with manually added captions |
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 | |
/** | |
* Get user's first and last name, else just their first name, else their | |
* display name. Defalts to the current user if $user_id is not provided. | |
* | |
* @param mixed $user_id The user ID or object. Default is current user. | |
* @return string The user's name. | |
*/ | |
function km_get_users_name( $user_id = null ) { |
NewerOlder