Skip to content

Instantly share code, notes, and snippets.

View murshed's full-sized avatar

Fahim Murshed murshed

View GitHub Profile
@murshed
murshed / astra-sync.php
Created March 2, 2022 15:30
Forcefully import Astra Starter Templates
<?php
/**
* Plugin Name: Astra Sites Always Sync
* Description: Always sync the library without checking the checksums.
*/
// Avoid gutenberg templates checksusms.
add_filter( 'ast_block_templates_checksums_status', function() {
return 'yes';
});
{
"themes": [
"astra",
"kadence",
"blocksy",
"wp-bootstrap-starter"
],
"plugins": [
"elementor",
"happy-elementor-addons",
@murshed
murshed / allow-origin.php
Last active March 2, 2022 15:31
Cross-Origin Resource Sharing
// Ref https://wordpress.stackexchange.com/questions/342767/allowed-http-origins-only-works-in-theme-functions-php
add_action( 'send_headers', 'add_cors_http_header' );
function add_cors_http_header()
{
header("Access-Control-Allow-Origin: *");
@murshed
murshed / gist:0dfe3719bc8f2f43071d8bc7719ea156
Created December 15, 2020 12:10
Random Post Functions for Astra theme
function homepage_posts($query)
{
if ($query->is_home() && $query->is_main_query())
{
$query->set( 'orderby', 'rand' );
}
}
add_action('pre_get_posts', 'homepage_posts');
@murshed
murshed / phone-only-login.php
Created November 10, 2020 20:57
A simple wordpress plugin to login with only phone number
<?php
/**
* Plugin Name: Phone Only Login
*/
function generateRandomString($length = 10)
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
@murshed
murshed / login-failes.php
Created October 24, 2019 11:32
Add this code to theme function.php
<?php
add_action( 'wp_login_failed', 'themeum_login_fail' );
function themeum_login_fail( $username ) {
$referrer = $_SERVER['HTTP_REFERER'];
if ( !empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin') ) {
wp_redirect( $referrer . '?login=failed' );
exit;
}
}
<?php
//save theme active time
function my_theme_activation_init() {
// Check if already saved the activation date & time
// to prevent over-writing if user deactive & active theme
// multiple time
if(!get_option('mytheme_activation_time', false)){
@murshed
murshed / init.php
Created August 20, 2019 07:46
WP Crowdfunding Plugin init (20-08-2019)
<?php
defined('ABSPATH') || exit;
if ( !class_exists('WPCF_Wallet') ) {
class WPCF_Wallet {
/**
* @var null
* $_instance
*/
@murshed
murshed / themeum-social-button.php
Created July 10, 2019 05:52
Soccer is a modern and premium sports WordPress theme dedicated to team sports fans. It includes all the features (dedicated plugins) you need to share your sports passion as List of Players, League Table, Point Table, Player profile, Fixtures & Results etc. In this theme, it has no Youtube Icon option. I have added the Youtube icon. Go to repla…
<?php
add_shortcode( 'themeum_social_button', function($atts, $content = null) {
extract(shortcode_atts(array(
'title' => '',
'facebook' => '',
'facebook_text' => '',
'twitter' => '',
'twitter_text' => '',
'youtube' => '',
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->