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 / 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.
@maheshwaghmare
maheshwaghmare / extract-links-from-content.php
Last active June 11, 2020 23:15
Get image & other links from the given content.
<?php
echo "Hello World";
@maheshwaghmare
maheshwaghmare / custom-sortable-columns.php
Created May 22, 2020 09:38
WordPress - Add custom sortable columns for custom post type.
<?php
/**
* Add custom column
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
if( ! function_exists( 'prefix_add_custom_column' ) ) :
function prefix_add_custom_column( $columns = array() ) {
@maheshwaghmare
maheshwaghmare / compatibility-check.php
Created May 22, 2020 04:45
WordPress Theme or Plugin compatibility check with `is_wp_version_compatible()` and `is_wp_version_compatible() functions.
<?php
$compatible_php = is_php_version_compatible( '5.1' );
$compatible_wp = is_wp_version_compatible( '4.4' );
if ( $compatible_php && $compatible_wp ) {
// Compatible PHP & WordPress version.
} else {
// Not Compatible.
}
@maheshwaghmare
maheshwaghmare / add-current-year-tag.php
Last active May 20, 2020 17:34
WordPress SEO - Register current Year custom tag or variable in to the Yoast SEO plugin. We can use the %%current_year%% into the title. Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
<?php
if( ! function_exists( 'prefix_yoast_register_current_year' ) ) :
/**
* Register current Year variable in Yoast SEO plugin.
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_current_year() {
@maheshwaghmare
maheshwaghmare / add-current-month-tag.php
Last active May 20, 2020 17:34
WordPress SEO - Register current Month custom tag or variable in to the Yoast SEO plugin. We can use the %%current_month%% into the title. . Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
<?php
if( ! function_exists( 'prefix_yoast_register_current_month' ) ) :
/**
* Register current Month variable in Yoast SEO plugin.
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_current_month() {
@maheshwaghmare
maheshwaghmare / snippet.php
Created May 20, 2020 10:50
WP Portfolio - Add portfolio categories and title into quick view.
<?php
add_action( 'rest_api_init', 'prefix_add_categories_in_rest_api' );
function prefix_add_categories_in_rest_api() {
register_rest_field(
'astra-portfolio',
'portfolio-categories',
array(
'get_callback' => 'prefix_get_portfolio_categories',
'schema' => null,
@maheshwaghmare
maheshwaghmare / get-post-ids-by-meta-value.php
Last active May 26, 2022 20:04
Get all post IDs which have meta key `location` and meta value `Pune`.
<?php
/**
* Get Post By Meta
*
* Get all post IDs which have meta key `location` and meta value `Pune`
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
@maheshwaghmare
maheshwaghmare / curl-parameters.txt
Created May 13, 2020 06:28
cURL list of all parameters
--anyauth Pick "any" authentication method (H)
-a, --append Append to target file when uploading (F/SFTP)
--basic Use HTTP Basic Authentication (H)
--cacert FILE CA certificate to verify peer against (SSL)
--capath DIR CA directory to verify peer against (SSL)
-E, --cert CERT[:PASSWD] Client certificate file and password (SSL)
--cert-status Verify the status of the server certificate (SSL)
--cert-type TYPE Certificate file type (DER/PEM/ENG) (SSL)
--ciphers LIST SSL ciphers to use (SSL)
--compressed Request compressed response (using deflate or gzip)