Skip to content

Instantly share code, notes, and snippets.

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

MM Aurangajeb mmarj

🏠
Working from home
View GitHub Profile
@mmarj
mmarj / settings.json
Created December 4, 2022 16:27 — forked from HeyMehedi/settings.json
Basic WordPress Settings for VSCode
{
"code-runner.saveFileBeforeRun": true,
"workbench.colorTheme": "One Dark Pro",
"editor.fontSize": 16,
"phpfmt.psr2": false,
"phpfmt.passes": [
"PSR2KeywordsLowerCase",
"PSR2LnAfterNamespace",
"PSR2ModifierVisibilityStaticOrder",
"ReindentSwitchBlocks",
@mmarj
mmarj / yoast_seo_opengraph_change_image_size.php
Created August 19, 2022 17:48 — forked from amboutwe/yoast_seo_opengraph_change_image_size.php
Code snippet to change or remove OpenGraph output in Yoast SEO. There are multiple snippets in this code.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Change size for Yoast SEO OpenGraph image for all content
* Credit: Yoast Development team
* Last Tested: May 19 2020 using Yoast SEO 14.1 on WordPress 5.4.1
* Accepts WordPress reserved image size names: 'thumb', 'thumbnail', 'medium', 'large', 'post-thumbnail'
* Accepts custom image size names: https://developer.wordpress.org/reference/functions/add_image_size/
*/
@mmarj
mmarj / set_default_post_type_order_in_admin_area.php
Created August 16, 2022 19:57
Set the order of the pages/posts in the admin section according to the last modified/editing date
//* @ Method 1
// Set the order of the pages/posts in the admin section descending according to the editing date [for all post/page type]
function orderby_modified_posts( $query ) {
if( is_admin() ) {
$query->set( 'orderby', 'modified' );
$query->set( 'order', 'desc' );
}
}
add_action( 'pre_get_posts', 'orderby_modified_posts' );
@mmarj
mmarj / functions.pnp
Created August 12, 2022 17:54 — forked from gmmedia/functions.php
Add featured image column to WP admin panel - posts AND pages
/**
* Add featured image column to WP admin panel - posts AND pages
* See: https://bloggerpilot.com/featured-image-admin/
*/
// Set thumbnail size
add_image_size( 'j0e_admin-featured-image', 60, 60, false );
// Add the posts and pages columns filter. Same function for both.
add_filter('manage_posts_columns', 'j0e_add_thumbnail_column', 2);
@mmarj
mmarj / add-css-style-if-value-is-greater-than-3-using-jquery.js
Created June 13, 2022 17:10
Add a border to any Facebook post which has more than 3 likes. It will apply to only this specific feed.
/*
@ Usecase: Add a border to any Facebook post which has more than 3 likes. It will apply to only this specific feed.
@ Required plugin: https://wordpress.org/plugins/custom-facebook-feed/
@ Install [this plugin](https://wordpress.org/plugins/custom-css-js/) to inject custom CSS/JS code snippets into a WordPress site.
*/
jQuery(document).ready(function($) {
$(".cff-likes .cff-count").each(function() {
var el = $(this);
var value = parseFloat(el.text());
@mmarj
mmarj / hide_happy_addons_pro_category_widgets_from_elementor_editor.php
Created May 24, 2022 09:23
Hide HappyAddons Pro Elementor widgets from the editor left sidebar
/* Hide HA Pro Elementor widgets from the editor left sidebar */
function hide_happy_addons_pro_category_widgets_from_editor() {
echo '<style>
#elementor-panel-category-happy_addons_pro_category{
display: none !important;
}
</style>';
}
add_action('admin_init', 'hide_happy_addons_pro_category_widgets_from_editor');
@mmarj
mmarj / url_upload.php
Created May 14, 2022 15:54 — forked from joviczarko/url_upload.php
Upload file from URL
<!DOCTYPE html>
<html>
<head>
<title>Upload file from URL</title>
<!-- From: https://stackoverflow.com/questions/22823204/is-there-any-way-to-upload-file-directly-from-url-in-filemanager-of-cpanel -->
</head>
<body>
<?php
$BASE_URL = strtok($_SERVER['REQUEST_URI'],'?');
@mmarj
mmarj / redirect-admin.php
Created May 14, 2022 15:54 — forked from devinsays/redirect-admin.php
Redirects subscribers back to the home page if they attempt to access the dashboard.
<?php
/**
* Redirects subscribers back to the home page if they attempt to access the dashboard.
*/
function prefix_redirect_admin() {
if ( ! current_user_can( 'edit_posts' ) && ! defined( 'DOING_AJAX' ) ) {
wp_safe_redirect( home_url() );
exit;
}
}
@mmarj
mmarj / wc-memberships-remove-my-memberships.php
Created February 5, 2022 21:52 — forked from bekarice/wc-memberships-remove-my-memberships.php
Remove "My Memberships" table on My Account with WooCommerce Memberships
<?php // Only copy this line if needed
/**
* Removes the "My Memberships" table from my account area
*/
function sv_remove_my_memberships_table() {
if ( function_exists( 'wc_memberships' ) && ! is_admin() ) {
remove_action( 'woocommerce_before_my_account', array( wc_memberships()->get_frontend_instance()->get_members_area_instance(), 'my_account_memberships' ) );
}
}
@mmarj
mmarj / terminal-cheat-sheet.txt
Created February 2, 2022 09:52 — forked from cferdinandi/terminal-cheat-sheet.txt
Terminal Cheat Sheet
# Terminal Cheat Sheet
pwd # print working directory
ls # list files in directory
cd # change directory
~ # home directory
.. # up one directory
- # previous working directory
help # get help
-h # get help