Skip to content

Instantly share code, notes, and snippets.

View maheshwaghmare's full-sized avatar
🎯
Focusing

Mahesh Waghmare maheshwaghmare

🎯
Focusing
View GitHub Profile
@maheshwaghmare
maheshwaghmare / add-current-post-updated-year.php
Created July 6, 2020 13:39
WordPress SEO - Register current post updated year as a custom tag or variable in to the Yoast SEO plugin. We can use the %%post_updated_year%% into the title. Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
<?php
if( ! function_exists( 'prefix_yoast_register_post_updated_year' ) ) :
/**
* Register Current Post Publish Year
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_post_updated_year() {
@maheshwaghmare
maheshwaghmare / add-current-post-publish-year.php
Created July 6, 2020 13:36
WordPress SEO - Register current post publish year as a custom tag or variable in to the Yoast SEO plugin. We can use the %%post_publish_year%% into the title. Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
<?php
if( ! function_exists( 'prefix_yoast_register_post_publish_year' ) ) :
/**
* Register Current Post Publish Year
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_post_publish_year() {
@maheshwaghmare
maheshwaghmare / wordpress-npm-packages.md
Created June 20, 2020 14:00
List of all WordPress NPM packages which are used in Gutenberg plugin.
npm install @wordpress/a11y --save
npm install @wordpress/annotations --save
npm install @wordpress/api-fetch --save
npm install @wordpress/autop --save
npm install @wordpress/babel-plugin-import-jsx-pragma
npm install @wordpress/babel-plugin-makepot --save-dev
npm install @wordpress/babel-preset-default --save-dev
npm install @wordpress/base-styles --save-dev
npm install @wordpress/blob --save
@maheshwaghmare
maheshwaghmare / get-heavy-options.php
Created June 8, 2020 11:00
Get autoload heavy options from the WordPress `wp_options` ($wpdb->options) table.
<?php
/**
* Get autoload heavy options from options table
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_get_heavy_autoload_options' ) ) :
function prefix_get_heavy_autoload_options() {
@maheshwaghmare
maheshwaghmare / get-autoload-options-size.php
Created June 8, 2020 10:44
Get the size of all options which are set as `autoload_size` in the WordPress `wp_options` ($wpdb->options) table.
<?php
/**
* Get Autoload Options Size
*
* Get the size of all options which are set as `autoload_size` in the WordPress `wp_options` ($wpdb->options) table.
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
<?php
/**
* Task to perform
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @return void
*/
@maheshwaghmare
maheshwaghmare / add-schedule-event.php
Created June 2, 2020 14:44
Add schedule event OR Cron event with wp_schedule_event(). See https://maheshwaghmare.com/doc/wordpress-cron/
<?php
/**
* Add schedule event or Cron event with wp_schedule_event()
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @return void
*/
@maheshwaghmare
maheshwaghmare / add-cron-schedules.php
Created June 2, 2020 14:40
Add custom cron schedules with filter `cron_schedules`. See https://maheshwaghmare.com/doc/wordpress-cron/
<?php
/**
* Add Cron Schedules
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @param array() $schedules Existing schedules.
* @return array
@maheshwaghmare
maheshwaghmare / get-schedules.php
Created June 2, 2020 14:32
Use function wp_get_schedules() to see all scheduled events. See https://maheshwaghmare.com/doc/wordpress-cron/
<?php
print_r( wp_get_schedules() );
// Array
// (
// [hourly] => Array
// (
// [interval] => 3600
// [display] => Once Hourly
// )
@maheshwaghmare
maheshwaghmare / convert-array-to-object.php
Created May 27, 2020 10:58
Recursively convert a simple or multidimensional array into object.
<?php
if( ! function_exists( 'prefix_convert_array_to_object' ) ) :
/**
* Convert Array to Object
*
* Recursively convert a simple or multidimensional array into object.
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @param array $data A simple or multidimentional array.