Skip to content

Instantly share code, notes, and snippets.

View AbmSourav's full-sized avatar
💥
Growing

Keramot UL Islam AbmSourav

💥
Growing
View GitHub Profile
@AbmSourav
AbmSourav / content.php
Created May 30, 2018 08:08
password form is not showing
<?php
$alpha_title_text = 'card-title';
$alpha_content_text = 'card-text';
$alpha_meta_wrap = 'card-footer text-muted';
if ( !is_active_sidebar( 'sidebar-1' ) ) {
$alpha_title_text = 'text-center';
$alpha_content_text = 'text-center';
$alpha_meta_wrap = 'text-center';
@AbmSourav
AbmSourav / comments.php
Created June 20, 2018 12:29
WordPress Comments Fields with Bootstrap classes
<div class="row">
<div class="col-md-8 comment-form">
<?php
$fields = array(
'author' =>
'<div class="form-group"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> <span class="required">*</span> <input id="author" name="author" type="text" class="form-control" value="' . esc_attr( $commenter['comment_author'] ) . '" required="required" /></div>',
'email' =>
'<div class="form-group"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> <span class="required">*</span><input id="email" name="email" class="form-control" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" required="required" /></div>',
// function.php wp_enqueue_scripts
wp_localize_script( 'main-js', 'rootUrl', array(
'siteUrl' => get_site_url()
) );
// main.js
var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', rootUrl.siteUrl + '/wp-json/wp/v2/posts');
ourRequest.onload = function() {
@AbmSourav
AbmSourav / autoload
Created November 17, 2019 17:40
PHP Class autoload
<?php
// classes/greatings.php
namespace Classes;
class Greatings {
function hello() {
return "Successfully called Greatings";
}
@AbmSourav
AbmSourav / SSH Key
Last active March 18, 2020 12:55
SSH key detail
Create SSH key: ssh-keygen -t rsa -C "your_email@example.com"
Ubuntu Copy SSH: xclip -sel clip < ~/.ssh/id_rs.pub
Windows Copy SSH: clip < ~/.ssh/id_rsa.pub
@AbmSourav
AbmSourav / facebook_feed.php
Last active March 30, 2020 15:13
using Facebook Rest API create Facebook Page Feed in WordPress websites.
<?php
$facebook_feed = get_transient( '_facebook_cash' );
$url_queries = 'fields=status_type,created_time,from,message,story,full_picture,permalink_url,attachments.limit(1){type,media_type,title,description,unshimmed_url},comments.summary(total_count),reactions.summary(total_count)';
$page_id = 'your facebook page id';
$token = 'your access token';
$url = 'https://graph.facebook.com/v4.0/' . $page_id . '/posts?' . $url_queries . '&access_token=' . $token;
if ( false === $facebook_feed ) {
$fb_posts = wp_remote_get( $url );
@AbmSourav
AbmSourav / gatsby-node.js
Created September 10, 2020 05:11
Dynamic pages with GatsbyJS
exports.createPages = async ({ graphql, actions }) => {
const { createPage } = actions
const wpData = await graphql(`
{
allWordpressPost {
nodes {
wordpress_id
slug
title
@AbmSourav
AbmSourav / facade.php
Last active August 31, 2021 08:15
A simplified way of Laravel's Facade...
<?php
abstract class Facade {
abstract protected static function getInstance();
public static function __callStatic($method, $arguments) {
$instance = static::getInstance();
@AbmSourav
AbmSourav / deploy.yml
Last active October 5, 2021 07:19
GitHub action for WordPress plugin deployment
name: Deploy to WordPress.org
on:
push:
tags:
- "*"
jobs:
tag:
name: New tag
runs-on: ubuntu-latest
@AbmSourav
AbmSourav / script.js
Last active February 1, 2023 09:13
WordPress ajax call with Fetch API
// php file
function enqueue_scripts() {
wp_enqueue_script( 'public-js', plugin_dir_url( __FILE__ ) . 'js/script.js', array(), '1.0', true );
wp_localize_script( 'public-js', 'localizeObj',
[
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'prefix_public_nonce' ),
]
);
}