Skip to content

Instantly share code, notes, and snippets.

View Ritesh-patel's full-sized avatar

Ritesh Patel Ritesh-patel

View GitHub Profile
@Ritesh-patel
Ritesh-patel / php-block.js
Created September 16, 2018 06:37 — forked from pento/php-block.js
Converting a shortcode to a block
// License: GPLv2+
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
ServerSideRender = wp.components.ServerSideRender,
TextControl = wp.components.TextControl,
InspectorControls = wp.editor.InspectorControls;
/*
* Here's where we register the block in JavaScript.
@Ritesh-patel
Ritesh-patel / prod-assets-in-local-nginx.conf
Created October 23, 2017 12:55
Use it for local site development and to fetch media files from prod site.
# Proxy uploads from production
location ~* \.(js|css|png|jpg|jpeg|gif|ico|mp3|mov|tif|tiff|swf|txt|html|svg)$ {
expires 24h;
log_not_found off;
try_files $uri $uri/ @production;
}
location @production {
resolver 8.8.8.8;
proxy_pass {prod_url}/$uri;
}
<?php
/**
* Get names from google search
*
* @param array $args
* @param array $assoc_args
*/
public function get_names( $args = array(), $assoc_args = array() ) {
$names_json = '{
@Ritesh-patel
Ritesh-patel / pre-commit
Last active November 7, 2016 14:39
WordPress Plugin pre-commit
#!/bin/bash
# WordPress Plugin pre-commit hook
set -e
message="Checking staged changes..."
git_status_egrep='^[MARC].+'
for i; do
case "$i"
@Ritesh-patel
Ritesh-patel / wp-get-all-attachment-media-paths.php
Last active August 29, 2015 14:27
Code snippet to get all attached media in WordPress and store the file paths into a text file.
// Put this script along with wp-load.php only
$curr_dir = getcwd();
include_once( $curr_dir . '/wp-load.php' );
if( defined( 'ABSPATH' ) ){
remove_all_filters( 'wp_get_attachment_url' );
remove_all_filters( 'get_attached_file' );
@Ritesh-patel
Ritesh-patel / rtmedia-comment-count-in-media-gallery.php
Last active August 29, 2015 14:19
rtMedia comment counts in media gallery
@Ritesh-patel
Ritesh-patel / hook.php
Last active August 29, 2015 14:18 — forked from desaiuditd/hook.php
<?php
// array - repo names and local filesystem path and branch
$repos = array(
'plugin-slug' => array (
'branch' => 'master',
'localpath' => '/var/www/example.com/htdocs/wp-content/plugins/plugin-slug'
),
);
hook_write_log( 'Hello at ' . date( 'D M j G:i:s T Y' ) );
<?php
// array - repo names and local filesystem path and branch
$repos = array(
'bad-plugin' => array (
'branch' => 'master',
'localpath' => '/var/www/example.com/htdocs/wp-content/plugins/bad-plugin'
)
);
rt_write_log("Hello at " . date("D M j G:i:s T Y") );
@Ritesh-patel
Ritesh-patel / rtmedia-roots-lightbox-patch.diff
Last active August 29, 2015 14:08
Roots theme patch for rtMedia lightbox
diff --git a/base.php b/base.php
index 9828b4c..b00b0f3 100644
--- a/base.php
+++ b/base.php
@@ -1,33 +1,42 @@
<?php get_template_part('templates/head'); ?>
-<body <?php body_class(); ?>>
+<?php
+ global $rt_ajax_request;
+ if ( isset( $rt_ajax_request ) && $rt_ajax_request ) {
@Ritesh-patel
Ritesh-patel / rtmedia-razor-theme-patch.diff
Last active August 29, 2015 14:02
rtMedia patch for razor theme
diff --git framework/theme-functions/template-engine.php framework/theme-functions/template-engine.php
index d4a5257..bdc9b73 100644
--- framework/theme-functions/template-engine.php
+++ framework/theme-functions/template-engine.php
@@ -10,6 +10,13 @@ if ( ! function_exists( 'template_context' ) ) :
function template_context($template) {
global $context, $target_wp_template_file, $theme_design_loaded;
+ //** RTMEDIA FIX **//
+ global $rt_ajax_request;