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
/* | |
This page demonstrates how to save WordPress settings through the Settings API from React. | |
It won't function on its own due to dependencies; it is an excerpt from a soon-to-be-published | |
plugin. It simply serves as an example. | |
Lines 62-76 demonstrate how to retrieve options. | |
Lines 133-169, in combination with state, demonstrate how to update options. | |
Inspired by: | |
https://www.codeinwp.com/blog/plugin-options-page-gutenberg/ |
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 | |
function bsd_tup_plugin_options_page() { | |
?> | |
<div class='wrap'> | |
<h1><?php _e('BSD Team and User Profiles', 'bsd-team-user-profiles' ); ?></h1> | |
<div id='poststuff'> | |
<div id='post-body' class='metabox-holder columns-2'> | |
<!-- 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 | |
/** | |
* WordPress pagination with consecutive page numbers, arrows, and an ellipses | |
* Style rules tested with Elementor on the Twenty-Twenty theme. YMMV. | |
* Example: | |
* « Previous 1 2 3 4 … 436 Next » | |
* | |
* PHP Code Source: https://wordpress.stackexchange.com/a/327711 | |
*/ | |
?> |
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
/* | |
* Use Case: A taxonomy named "Specialty" assigned to a post has several terms. | |
* The user needs to receive them back like this: "landlord representation, real estate, tenant representation". | |
* | |
* Call it like this: | |
* $term_list = bsd_get_taxonomy_terms_as_string( 'bsd-specialty', 1035 ); | |
* Where bsd-specialty is the taxonomy slug and 1035 is the post ID. | |
*/ | |
public function bsd_get_taxonomy_terms_as_string( $taxonomy_name, $object_id ) { |
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
/* | |
* Display a map (saved from Advanced Custom Fields) in Quick View Pro modal | |
* Documentation: https://battlestardigital.com/adding-advanced-custom-fields-google-maps-to-woocommerce-quick-view-pro/ | |
* HTML Source: https://www.advancedcustomfields.com/resources/google-map/ | |
*/ | |
private function bsd_qvp_display_map( $map) { | |
if ( $map ) { | |
?> | |
<div id="map" class="acf-map"> | |
<div class="marker" data-lat="<?php echo esc_attr($map['lat']); ?>" data-lng="<?php echo esc_attr($map['lng']); ?>"></div> |
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 ACF fields to WordPress API | |
* Tutorial: https://battlestardigital.com/wp-admin/post.php?post=2838&action=edit | |
*/ | |
add_action( 'rest_api_init', 'bsd_register_acf_with_api' ); | |
function bsd_register_acf_with_api() { | |
if (!function_exists('get_fields')) return; |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>How to Return Two Values to a Function in ES6</title> | |
</head> | |
<body> | |
<div class='container'> | |
<form action='#' onsubmit='funFunction();return false'> | |
<select name='vehicle-selector' id='vehicle-selector' required /> | |
<option value='BaseStar'>BaseStar</option> |
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 | |
/** | |
* Extend WC_Stripe_Webhook_Handler and override the check_for_webhook function | |
* | |
*/ | |
if (!class_exists('My_Stripe_Webhook_Handler')) : | |
class My_Stripe_Webhook_Handler extends WC_Stripe_Webhook_Handler { |
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
document.addEventListener('DOMContentLoaded', function() { | |
const currentUrl = window.location.pathname; | |
let parentCategory = false; | |
let productName = currentUrl.substr(18, (currentUrl.length - 18)); | |
let slashCount = productName.match(/\//g); | |
// Count the number of slashes. If 1, this is a parent category | |
slashCount = slashCount ? slashCount.length : 0; |
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 | |
/** | |
* Displays a table in the WC Settings page | |
* | |
* @link https://paulmiller3000.com | |
* @since 1.0.0 | |
* | |
* @package P3k_Galactica | |
* @subpackage P3k_Galactica/admin | |
* |
NewerOlder