Skip to content

Instantly share code, notes, and snippets.

View celticwebdesign's full-sized avatar

Darren Stevens celticwebdesign

View GitHub Profile
@celticwebdesign
celticwebdesign / WordPress - show page link is page is parent or child
Created September 20, 2017 15:59
If the page is a parent then show child page links, if the page does not page child pages, show pages links of parent.
<a class="share_twitter" href="#" data-title="title: URL">T</a>
$('a.share_twitter').click(function(e) {
e.preventDefault();
var $this = $(this);
<a class="share_linkedin" href="#" data-url="https://www.linkedin.com/shareArticle?mini=true&amp;url=Enter URL here&amp;title=enter title here&amp;summary=enter summary here&amp;source=">L</a>
$('a.share_linkedin').click(function(e) {
e.preventDefault();
var $this = $(this);
<a class="share_facebook" href="#" data-url="enter url here">F</a>
$('a.share_facebook').click(function(e) {
e.preventDefault();
var $this = $(this);
@celticwebdesign
celticwebdesign / WordPress Plugin - YouTube Channel Video Counts
Created October 27, 2017 13:57
A WordPress plugin to get all videos from a YouTube Channel, adds up all video view counts.
<?php
/*
Plugin Name: CWD YouTube Channel
Version: 0.1
Plugin URI: http://www.celticwebdesign.net
Description: Render YouTube video count
Author: Darren Stevens
Author URI: http://www.celticwebdesign.net
*/
@celticwebdesign
celticwebdesign / WordPress make category select with links
Created November 22, 2017 22:57
Gets a list of Category terms and make a linkable form select,
@celticwebdesign
celticwebdesign / PHP - select the last child with a specific class name in css
Created January 11, 2018 12:04
PHP - select the last child with a specific class name in css
// https://stackoverflow.com/questions/6401268/how-do-i-select-the-last-child-with-a-specific-class-name-in-css
if ( $( "section.recipe-collections" ).length > 1 ) {
$( "section.recipe-collections" ).last().addClass( "last" );
}
// Allows the selection of the last element with specific class.
@celticwebdesign
celticwebdesign / Visual Composer - separate page
Created May 10, 2018 06:38
Allows display of Visual Composer on different page.
$post_id = get_field('above_footer');
$vcM = Vc_Manager::getInstance();
$vc = $vcM->vc();
$vc->addShortcodesCustomCss( $post_id );
$post = get_post($post_id, OBJECT);
$content = $post->post_content;
$content = apply_filters('wpautop', $content);
// https://wordpress.stackexchange.com/questions/87261/checkboxes-in-registration-form
// REGISTRATION
add_action( 'register_form', 'signup_fields_wpse_87261' );
add_action( 'user_register', 'handle_signup_wpse_87261', 10, 2 );
// PROFILE
add_action( 'show_user_profile', 'user_field_wpse_87261' );
// https://codex.wordpress.org/Plugin_API/Action_Reference/admin_footer
function my_admin_add_js() {
echo '
<script type="text/javascript">
var ajaxurl = "'.admin_url("admin-ajax.php").'";
var user_id = '.get_current_user_id().';
</script>