Skip to content

Instantly share code, notes, and snippets.

View 1naveengiri's full-sized avatar
🏠
Working from home

Naveen Giri 1naveengiri

🏠
Working from home
View GitHub Profile
@1naveengiri
1naveengiri / s3converter.php
Last active March 9, 2017 05:50
Function to add entry in wp_rtamazon_s3_media table for all attachments.
<?php
/**
* set /?do=now at the end of site your URL to fire this script.
*/
/**
* Function return attachment data needed for s3 table upload.
*
* @return array $attachment_data_array Attachment data array.
*/
@1naveengiri
1naveengiri / s3converter-new.php
Created March 9, 2017 06:54
New S3 converter
<?php
function get_attachments_s3_array() {
global $wpdb;
$table_name = $wpdb->prefix . 'rtamazon_s3_media';
$query = "Select * from ".$table_name." where s3_url IS NULL AND media_id=83";
$attachment_data = $wpdb->get_results($query,OBJECT);
$final_attachment_data = array();
if(!empty($attachment_data)){
foreach ($attachment_data as $key => $value) {
$single_attachment_data['blog_id'] = 1;
@1naveengiri
1naveengiri / s3converter-new.php
Created March 9, 2017 06:54
New S3 converter
<?php
function get_attachments_s3_array() {
global $wpdb;
$table_name = $wpdb->prefix . 'rtamazon_s3_media';
$query = "Select * from ".$table_name." where s3_url IS NULL AND media_id=83";
$attachment_data = $wpdb->get_results($query,OBJECT);
$final_attachment_data = array();
if(!empty($attachment_data)){
foreach ($attachment_data as $key => $value) {
$single_attachment_data['blog_id'] = 1;
@1naveengiri
1naveengiri / function.php
Created March 15, 2017 06:45
Code to add Album menu as Top Level WordPress Profile Menu.
<?php
/**
* Function to add Album menu as main menu in WordPress Profile menu.
*/
if ( ! function_exists( 'rtmedia_add_album_main_menu' ) ) {
function rtmedia_add_album_main_menu() {
// Please change the page_slug if you want from here
$page_slug = 'album';
$page_title = __('Album','buddypress-media' );
// check if RTMEDIA_MEDIA_SLUG is already defined
@1naveengiri
1naveengiri / function.php
Last active March 15, 2017 13:20
Hooked code to disable like feature for user on its own media.
<?php
add_action('init','rtmedia_disable_media_like_init');
/**
* Function to extend like disable check functionality.
*/
function rtmedia_disable_media_like_init(){
if( function_exists( 'rtmedia_disable_own_media_like' ) ) {
add_filter( 'rtmedia_check_enable_disable_like','rtmedia_disable_own_media_like' , 10, 1 );
}
}
@1naveengiri
1naveengiri / exclude-media.php
Last active March 28, 2017 08:14
Exclude rtMedia Uplaoded media form backend media tab
<?php
/**
* Function will exclude all rtMedia uploaded media from backend media tab.
*/
function show_only_allowed_media( $query ) {
global $wpdb, $pagenow;
if ( $query->is_admin ) {
if('upload.php' === $pagenow || ( !empty($_REQUEST['action']) && 'query-attachments' === $_REQUEST['action']) ){
$wp_rt_rtm_media = $wpdb->prefix."rt_rtm_media";
$custom_query = "select media_id from ".$wp_rt_rtm_media;
add_action( 'admin_notices','bp_admin_notices' );
/**
* Add Admin Notice when BuddyPress is not activated.
*/
public function bp_live_admin_notices( ){
if( ! is_plugin_active('buddypress/bp-loader.php') ){ ?>
<div class="notice notice-warning is-dismissible">
<p>
<?php _e( 'BuddyPress Live Notification required BuddyPress to be activated', 'bp_live_notification' ); ?></p>
@1naveengiri
1naveengiri / introrx.md
Created September 1, 2017 12:41 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@1naveengiri
1naveengiri / class-sd-admin-pointer.php
Created January 10, 2018 04:05
Create WordPress Pointer Tutorial For New Users
<?php
/**
* Adds and controls pointers for contextual help/tutorials
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.4.0
*/
@1naveengiri
1naveengiri / convertor.php
Last active January 13, 2019 10:22
Convert ACF Fields Registered by PHP to Importable JSON Format
<?php
/**
* create a file acf-import.json inside your theme main folder
* use this code in themes functions.php or in any custom plugin.
* It is one time code so it will add all fields json entry inside acf-import.json file
*/
add_action('init', 'create_fieldjson_from_fieldphp');
function create_fieldjson_from_fieldphp() {
$groups = acf_get_local_field_groups();
$json = [];