Skip to content

Instantly share code, notes, and snippets.

View shamimmoeen's full-sized avatar
🏠
Working from home

Mainul Hassan Main shamimmoeen

🏠
Working from home
View GitHub Profile
@shamimmoeen
shamimmoeen / register-theme-directory.php
Created September 24, 2024 17:46
Register theme directory using mu-plugins
<?php
/**
* Plugin Name: Register Theme Directory
* Plugin URI:
* Description: Autoload acp.edu theme.
* Version: 1.0
* Author: WPMU DEV
* Author URI: https://wpmudev.com
*/
@shamimmoeen
shamimmoeen / clauses.php
Created April 1, 2021 18:58 — forked from igorbenic/clauses.php
Extending WP_Query with Custom Queries and Tables | https://www.ibenic.com/extending-wp-query-custom-queries-tables
<?php
add_filter( 'posts_clauses', 'filter_clauses', 10, 2 );
/**
* Filtering everything.
*
* @param array $clauses Array with all parts of the query.
* @param WP_Query $wp_query Object.
* @return string
@shamimmoeen
shamimmoeen / modify_query.php
Created April 1, 2021 17:47 — forked from cyberwani/modify_query.php
Modify WordPress Query query
<?php
// With dual parameters
function modify_query_one( $clauses, $query ) {
global $wpdb;
if ( isset( $query->query['orderby'] ) && 'color' == $query->query['orderby'] ) {
$clauses['join'] .= <<<SQL
LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id)
LEFT OUTER JOIN {$wpdb->terms} USING (term_id)
@shamimmoeen
shamimmoeen / Form.php
Created September 30, 2020 17:17
How to hide the comment form for a specific user instead of user role?
<?php
namespace wpdFormAttr;
use wpdFormAttr\FormConst\wpdFormConst;
use wpdFormAttr\Field\DefaultField\Captcha;
class Form {
public $wpdOptions;
@shamimmoeen
shamimmoeen / gist:391baf2fed118c7f9479afa8c1535d06
Created April 14, 2020 18:39 — forked from discordier/gist:ed4b9cba14652e7212f5
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
@shamimmoeen
shamimmoeen / MyEditorComponent.js
Last active February 25, 2020 06:19
Integrate gutenberg editor in wordpress plugin's settings page
import {
BlockEditorKeyboardShortcuts,
BlockEditorProvider,
BlockInspector,
BlockList,
ObserveTyping,
SETTINGS_DEFAULTS,
WritingFlow,
} from '@wordpress/block-editor';
import { registerCoreBlocks } from '@wordpress/block-library';
@shamimmoeen
shamimmoeen / replace-parent-element-value-from-child-arrays.php
Created September 21, 2018 18:13
In multidimensional array replace parent element value from child arrays
<?php
/**
* Stackoverflow link https://stackoverflow.com/questions/52388607/in-multidimensional-array-replace-parent-element-value-from-child-arrays
*/
$tree = array(
'16' => array(
'id' => '16',
'name' => 'Clothing',
@shamimmoeen
shamimmoeen / custom-file-upload-form-in-wordpress.php
Last active October 31, 2023 10:42
Create custom file upload form in WordPress
<?php
if ( ! function_exists( 'wpcfu_output_file_upload_form' ) ) {
/**
* Output the form.
*
* @param array $atts User defined attributes in shortcode tag
*/
function wpcfu_output_file_upload_form( $atts ) {
@shamimmoeen
shamimmoeen / load-wpjm-templates-via-hook.php
Last active June 20, 2018 03:46
Load WP Job Manager templates from theme/plugin using hook
<?php
add_action( 'job_manager_locate_template', 'my_theme_include_job_manager_templates', 10, 3 );
if (!function_exists('my_theme_include_job_manager_templates')) {
/**
* Include modified job manager templates.
*
* @param mixed $template The template
* @param string $template_name The template name