Skip to content

Instantly share code, notes, and snippets.

View azizultex's full-sized avatar
🌍
Working from anywhere 😊

Azizul Haque azizultex

🌍
Working from anywhere 😊
View GitHub Profile
@azizultex
azizultex / install_psql_php.sh
Created June 9, 2016 08:11 — forked from doole/install_psql_php.sh
Install PostgreSQL PHP extensions on Mac OS X
#!/bin/bash
# Check PHP version `php --version`
PHP_VER=$(php -v | head -1 | awk '{ print $2 }')
# Extensions directory (default: empty string)
EXT_DIR=""
# Postgres.app < 9.3.5.0
#PG_APP="/Applications/Postgres.app/Contents/MacOS"
@azizultex
azizultex / Remove an Action from a Plugin Class Method WordPress
Last active November 29, 2023 11:43
Remove a hook, filters from a Plugin Class Method WordPress
/**
* Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :)
* source: https://github.com/herewithme/wp-filters-extras
* More: http://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object
*/
function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0 ) {
global $wp_filter;
// Take only filters on right hook name and priority
if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) )
/* resource: http://www.hypexr.org/linux_scp_help.php */
What is Secure Copy?
scp allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh.
Examples
Copy the file "foobar.txt" from a remote host to the local host
@azizultex
azizultex / Database connection error fix on OS X EL Captian
Last active April 26, 2016 08:12
Database connection error fix on OS X EL Captian
/* wp-config.php
** resource : https://wordpress.org/support/topic/mysqli_real_connect-hy0002002-no-such-file-or-directory?replies=12
*/
/** MySQL hostname */
define('DB_HOST', 'localhost:/tmp/mysql.sock');
@azizultex
azizultex / Change mysql password
Created April 26, 2016 07:23
Change mysql password
sudo mysqld_safe --skip-grant-tables
// open new window and run below commands
mysql -u root;
UPDATE mysql.user SET authentication_string=PASSWORD('root') WHERE User='root';
FLUSH PRIVILEGES;
\q
@azizultex
azizultex / Delete Posts After a Specific Days
Last active September 3, 2023 20:29
Delete Posts After a Specific Days
function delete_posts() {
$args = array (
'post_type' => 'lionfish_locations', // post type
'nopaging' => true
);
$q = new WP_Query ($args);
while ($q->have_posts()) {
$q->the_post();
$id = get_the_ID();
$posted_time = human_time_diff(get_the_time('U'), current_time ('timestamp'));
@azizultex
azizultex / create the next prev posts navigation
Created April 7, 2016 09:49
create the next prev posts navigation
<?php
$global_ids = array(); // create an empty array
objects = new WP_Query( $args );
if($objects->have_posts()) {
while ( $objects->have_posts() ) {
$objects->the_post();
$global_ids[] = $post->ID; // create an array of posts ids to update global_ids option
@azizultex
azizultex / WP REST API oAuth
Created April 7, 2016 05:06
WP REST API oAuth
// cookie authentication
function wp_frontend_rest_scripts() {
/* ajaxify the post submit */
// wp_enqueue_style('jquerymodal', WPFR_PLUGINURL . 'assets/css/jquery.modal.css');
wp_enqueue_script('my-post-submitter', WPFR_PLUGINURL . 'js/rest-ajax.js', array('jquery') );
//localize data for script
wp_localize_script( 'my-post-submitter', 'POST_SUBMITTER', array(
'root' => esc_url_raw( rest_url() ),
@azizultex
azizultex / WordPress Filterable Portfolio Items
Created March 3, 2016 05:40
WordPress Filterable Portfolio Items
function sumer_portfolio_shortcode_func($atts) {
extract(shortcode_atts(array(
), $atts));
$args = array( 'post_type' => 'sumer_portfolio', 'posts_per_page' => -1 );
$l = new WP_Query( $args );
if($l->have_posts()) {
@azizultex
azizultex / WordPress Shortcode with ob_start()
Created March 3, 2016 03:16
WordPress Shortcode with ob_start()
function custom_query_shortcode($atts) {
// EXAMPLE USAGE:
// [loop the_query="showposts=100&post_type=page&post_parent=453"]
// Defaults
extract(shortcode_atts(array(
"the_query" => ''
), $atts));