Skip to content

Instantly share code, notes, and snippets.

@da1nonly
da1nonly / Twitter like post load
Created March 1, 2012 21:56
Twitter like next post load for Wordpress
<?php
add_action('wp_ajax_and_action', 'add_next_post');
function add_next_post()
{
$query_string = $_POST['query_string'];
$offset = $_POST['paged'] * get_settings('posts_per_page');
$per_page = get_settings('posts_per_page');
query_posts("$query_string&offset=$offset&posts_per_page=$per_page");
@da1nonly
da1nonly / gist:2057532
Created March 17, 2012 10:55
wordpress meta box urls
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function repeatable_meta_box_display() {
global $post;
@da1nonly
da1nonly / gist:2253622
Created March 30, 2012 18:13
wordpress audio and video playlist metabox
<?php
function add_meta_boxes() {
wp_enqueue_style( 'mytabs-css', get_bloginfo( 'stylesheet_directory' ). '/tab/metabox-tabs.css');
wp_enqueue_script( 'mytabs', get_bloginfo( 'stylesheet_directory' ). '/tab/mytabs.js', array( 'jquery-ui-tabs' ) );
add_meta_box(
'repeatable-fields',
'Playlist',
'repeatable_meta_box_display',
'post',
jQuery(document).ready(function($) {
$('.metabox_submit').click(function(e) {
e.preventDefault();
$('#publish').click();
});
$('#add-row').on('click', function() {
var row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset-one tbody>tr:last');
return false;
<?php
function add_meta_boxes() {
wp_enqueue_style( 'mytabs-css', get_bloginfo( 'stylesheet_directory' ). '/tab/metabox-tabs.css');
wp_enqueue_script( 'mytabs', get_bloginfo( 'stylesheet_directory' ). '/tab/mytabs.js', array( 'jquery-ui-tabs' ) );
add_meta_box(
'repeatable-fields',
'Playlist',
'repeatable_meta_box_display',
'post',
jQuery('.repeatable-add').click(function() {
field = jQuery(this).closest('td').find('.custom_repeatable li:last').clone(true);
fieldLocation = jQuery(this).closest('td').find('.custom_repeatable li:last');
jQuery('input', field).val('').attr('name', function(index, name) {
return name.replace(/(\d+)/, function(fullMatch, n) {
return Number(n) + 1;
});
})
field.insertAfter(fieldLocation, jQuery(this).closest('td'))
return false;
@da1nonly
da1nonly / gist:2551561
Created April 29, 2012 16:03
data wordpress
<?php
function add_meta_boxes() {
wp_enqueue_style( 'mytabs-css', get_bloginfo( 'stylesheet_directory' ). '/tab/metabox-tabs.css');
wp_enqueue_script( 'mytabs', get_bloginfo( 'stylesheet_directory' ). '/tab/mytabs.js', array( 'jquery-ui-tabs' ) );
add_meta_box(
'repeatable-fields',
'Playlist',
'repeatable_meta_box_display',
'post',
@da1nonly
da1nonly / wordpress auto backup
Created May 28, 2012 17:52
wordpress auto backup
<?php
/**
Backup the database of a given WordPress site.
using http://www.bin-co.com/blog/2008/10/remote-database-backup-wordpress-plugin/
*/
$site_url = 'http://yoursite.com'; //The URL of the online wordpress site
$username = 'admin'; // Admin username
$password = 'not_my_password'; // Admin password
<?php
/**
* WordPress Export Administration API
*
* @package WordPress
* @subpackage Administration
*/
/**
* Version number for the export format.
@da1nonly
da1nonly / gist:6668055
Created September 23, 2013 08:51
youtube import wordpress
if($type == 'youtube'){
$playlist_id = $_POST['convert'];
if($old !== 'Data'){
$url = "https://gdata.youtube.com/feeds/api/playlists/".$playlist_id."?v=2&alt=json&max-results=50";
$data = json_decode(file_get_contents($url),true);
$info = $data["feed"];
$video = $info["entry"];
for($i=0;$i<count($video);$i++){
if($video[$i]['link'][0]['href'] != ""){
$text_title = str_replace("'", '', $video[$i]['title']['$t']);