Skip to content

Instantly share code, notes, and snippets.

View alinademi's full-sized avatar

Ali Demi alinademi

  • Vancouver
View GitHub Profile
@alinademi
alinademi / wp-site-redirect.php
Created January 29, 2021 01:39 — forked from wpscholar/wp-site-redirect.php
Sample plugin for redirecting a WordPress site to a specific URL.
<?php
/*
* Plugin Name:
* Plugin URI:
* Description:
* Version: 1.0
* Author:
* Author URI:
* License: GPL2
@alinademi
alinademi / wp-list-find.php
Created January 29, 2021 01:40 — forked from wpscholar/wp-list-find.php
Created a function that will return the first found match from a list of items.
<?php
/**
* Find a single item in a list based on specific criteria.
*
* @uses wp_list_filter()
*
* @param array $list
* @param array $args
* @param string $operator
@alinademi
alinademi / schema-api.php
Created January 29, 2021 01:41 — forked from wpscholar/schema-api.php
Plugin for creating a post type with a custom API that reflects Schema.org data structures
<?php
/*
* Plugin Name: Schema API
* Plugin URI:
* Description:
* Version: 0.1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@alinademi
alinademi / rss-to-json.php
Created January 29, 2021 01:41 — forked from wpscholar/rss-to-json.php
A simple must-use plugin for WordPress that will provide a `/feed/json` endpoint for converting RSS feeds to JSON.
<?php
/**
* A simple must-use plugin for WordPress that will provide a `/feed/json` endpoint for converting RSS feeds to JSON.
* In the absence of any URL parameters, it will convert the main feed to JSON. If a URL is set, it will convert the
* feed from that URL into JSON. If a callback is set, a JSONP implementation will be returned.
*
* Note: Be sure to flush rewrite rules manually by visiting the 'General'->'Permalinks' page in the WordPress admin. If
* you are using this in a plugin, be sure to flush the rewrite rules on activation using the 'flush_rewrite_rules()' function.
*
@alinademi
alinademi / defer-async-scripts.php
Created January 29, 2021 01:46 — forked from wpscholar/defer-async-scripts.php
Class that allows you to async and defer scripts in WordPress by adding data.
<?php
class WP_Scholar_Defer_Scripts {
public static function initialize() {
add_filter( 'script_loader_tag', array( __CLASS__, 'defer_scripts' ), 10, 2 );
add_filter( 'script_loader_tag', array( __CLASS__, 'async_scripts' ), 10, 2 );
}
public static function defer_scripts( $tag, $handle ) {
@alinademi
alinademi / theme-helper.php
Created January 30, 2021 02:57 — forked from josanua/theme-helper.php
Theme Dev Helper
<?php
// General info
https://codex.wordpress.org/Theme_Development
// Theme Handbook
https://developer.wordpress.org/themes/
// Demo content an theme unit testing
https://codex.wordpress.org/Theme_Unit_Test
@alinademi
alinademi / wp-remove-dashboard.php
Created January 30, 2021 03:00 — forked from josanua/wp-remove-dashboard.php
Remove all the default WordPress dashboard widgets.
<?php
/*
Plugin Name: Remove Dashboard Meta Boxes
Plugin URI: http://pmg.co/category/wordpress
Description: Removes the default dashboard widgets from the WordPress admin.
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: GPL2
*/
<?php
https://wp-cli.org/
https://make.wordpress.org/cli/handbook/
https://make.wordpress.org/cli/handbook/quick-start/
https://developer.wordpress.org/cli/commands/
WP-CLI Commands A-N
wp admin – Open /wp-admin/ in a browser.
@alinademi
alinademi / wp-db.php
Created January 30, 2021 03:04 — forked from josanua/wp-db.php
wp db
<?php
/************ Work with Database ************/
//interesting facts about DB
https://code.tutsplus.com/tutorials/understanding-and-working-with-data-in-wordpress--cms-20567
https://developer.wordpress.org/reference/classes/wpdb/
// * - for external file to include WP environment (tested) - require( '../sitename-base/wp-load.php' );
@alinademi
alinademi / send_smtp_with_wpmail.php
Created January 30, 2021 03:05 — forked from josanua/send_smtp_with_wpmail.php
Wordpress: Add SMTP settings to wp_mail()
// Action for change default system settings, it work's!
add_action('phpmailer_init','send_smtp_email');
function send_smtp_email( $phpmailer )
{
// Define that we are sending with SMTP
$phpmailer->isSMTP();
// The hostname of the mail server