Skip to content

Instantly share code, notes, and snippets.

View azizultex's full-sized avatar
🌍
Working from anywhere 😊

Azizul Haque azizultex

🌍
Working from anywhere 😊
View GitHub Profile
@azizultex
azizultex / WordPress Shortcode with ob_start()
Created March 3, 2016 03:16
WordPress Shortcode with ob_start()
function custom_query_shortcode($atts) {
// EXAMPLE USAGE:
// [loop the_query="showposts=100&post_type=page&post_parent=453"]
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
), $atts));
@azizultex
azizultex / Remove an Action from a Plugin Class Method WordPress
Last active November 29, 2023 11:43
Remove a hook, filters from a Plugin Class Method WordPress
/**
* Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :)
* source: https://github.com/herewithme/wp-filters-extras
* More: http://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object
*/
function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0 ) {
global $wp_filter;
// Take only filters on right hook name and priority
if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) )
@azizultex
azizultex / Override a plugin shortcode in WordPress
Last active September 3, 2023 20:29
Override a plugin shortcode in WordPress
Best way to override a plugin function is to use mu-plugins (Must Use Plugins)
https://gregrickaby.com/2013/10/create-mu-plugin-for-wordpress/#comment-14420
Aleternatively, follow below :
1. Copy the plugin shortcode function and put it anywhere in Child Theme and rename it like custom_cs_user_login_shortcode.
2. use 'wp_head' action to remove the plugin shortcode and register the new shortcode again with the new function name like custom_cs_user_login_shortcode.
/*********************************************
@azizultex
azizultex / Delete Posts After a Specific Days
Last active September 3, 2023 20:29
Delete Posts After a Specific Days
function delete_posts() {
$args = array (
'post_type' => 'lionfish_locations', // post type
'nopaging' => true
);
$q = new WP_Query ($args);
while ($q->have_posts()) {
$q->the_post();
$id = get_the_ID();
$posted_time = human_time_diff(get_the_time('U'), current_time ('timestamp'));
// Shortcode
// source : https://wpbakery.atlassian.net/wiki/pages/viewpage.action?pageId=524362
if(!function_exists('carousel_content')){
function carousel_content( $atts, $content = null ) {
return '<div class="owl-carousel content-carousel content-slider">'.do_shortcode($content).'</div>';
}
add_shortcode('carousel_content', 'carousel_content');
}
@azizultex
azizultex / Ajax loading image gallery WordPress
Last active July 7, 2023 03:06
Ajax loading image gallery WordPress ( coded for oliveorange.com )
@azizultex
azizultex / Ajax FrontEnd File Upload WordPress With Preview
Created January 12, 2017 17:17
Ajax FrontEnd File Upload WordPress With Preview
/****************************************************************
Project: MySavingWallet
Resource: http://www.ibenic.com/wordpress-file-upload-with-ajax/
HTML FORM
*****************************************************************/
<dt><?php esc_html_e( 'Support Doc', 'listify_child' ); ?></dt>
<dd>
<section>
@azizultex
azizultex / generate_video_embed_url.php
Created April 24, 2017 17:21
Generate Youtube and Vimeo Video Embed URL dynamically
/**
* get youtube video ID from URL
* http://stackoverflow.com/questions/6556559/youtube-api-extract-video-id
* @param string $url
* @return string Youtube video id or FALSE if none found.
*/
function youtube_id_from_url($url) {
$pattern =
'%^# Match any youtube URL
(?:https?://)? # Optional scheme. Either http or https
@azizultex
azizultex / Custom Class to Slick Carousel Next Prev Items and animation
Last active May 10, 2023 05:07
Custom Class to Slick Carousel Next Prev Items and animation
@azizultex
azizultex / Change slug ( add_rewrite_rule ) of already registered taxonomy or custom post type
Last active January 4, 2022 14:09
Change slug ( add_rewrite_rule ) of already registered taxonomy or custom post type
/***************************************************
USING add_rewrite_rule
****************************************************/
/* azizultex
1. https://www.ait-themes.club/knowledge-base/how-can-i-change-items-slug-and-slug-of-other-custom-post-types/
2. http://wordpress.stackexchange.com/questions/41988/redeclare-change-slug-of-a-plugins-custom-post-type
3. http://wordpress.stackexchange.com/questions/134322/rewrite-rule-for-custom-taxonomy
*/