Skip to content

Instantly share code, notes, and snippets.

@alwerner
alwerner / Pushing a new branch for the first time
Created January 30, 2014 21:48
Pushing a new branch for the first time
// Makes sure the branch gets tracked upstream
git push -u origin my_branch
@alwerner
alwerner / update wordpress submodule
Created April 9, 2014 17:35
update wordpress submodule
cd wordpress
git fetch --tags
git checkout 3.5.1
// array starts with 0, so adding 1 will equal the count
<?php if( ($wp_query->current_post + 1) == ($wp_query->post_count)) : ?>foo<?php endif; ?>
@alwerner
alwerner / mysql database dump from remote server to desktop
Last active August 29, 2015 14:03
hostname represents the ssh config host name
$ ssh hostname
$ mysql -u root
$ show databases;
// copy desired DB_NAME
$ exit // exit mysql console
$ exit // exit ssh connection
// In functions.php. Creates accessible array of bloginfo parameters
// http://codex.wordpress.org/Template_Tags/bloginfo
function bloginfo_shortcode( $atts ) {
extract(shortcode_atts(array(
'key' => '',
), $atts));
return get_bloginfo($key);
}
add_shortcode('bloginfo', 'bloginfo_shortcode');
<?php
if ( ! current_user_can( 'manage_options' ) ) {
add_action( 'admin_menu', 'admin_menu_example' );
}
function admin_menu_example() {
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
<?php $page_id = get_page_by_title($page->page_title);
$page_data = get_page($page_id); ?>
<p><?php echo $page_data->post_content; ?></p>
add_action("publish_post", "eg_create_sitemap");
add_action("publish_page", "eg_create_sitemap");
function eg_create_sitemap() {
$postsForSitemap = get_posts(array(
'numberposts' => -1,
'orderby' => 'modified',
'post_type' => array('post','page'),
'order' => 'DESC'
));
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
// where dist is the desired folder
git subtree push --prefix dist heroku master