Skip to content

Instantly share code, notes, and snippets.

@rdswd
rdswd / page.php
Created May 4, 2020 16:42
Trying to query RCP posts by level doesn't work
/* Current user level ids */
$int_rcp_current_user_levels = array_unique( rcp_get_customer_membership_level_ids() );
/* Iterate through levels */
foreach ( $int_rcp_current_user_levels as $level_id ){
$details = rcp_get_subscription_details( $level_id );
/* Title */
echo '<h3>' . $details->name . ' ' . $level_id . '</h3>';
$level_args = array(
@rdswd
rdswd / theme.js
Created April 1, 2020 03:49
ScrollMagic - inline styles for transformations
//cont
var buttonAnimate = new ScrollMagic.Scene({triggerElement: ".wp-block-button__link"} )
.offset(-100)
.on("enter", function (evt) {
buttonAnimate.triggerElement().style.backgroundColor = 'red';
buttonAnimate.triggerElement().style.fontSize = '125%';
})
.on("leave", function () {
// reset style
buttonAnimate.triggerElement().style.backgroundColor = '';
@rdswd
rdswd / somethemefile.scss
Created April 1, 2020 02:48
ScrollMagic - Related CSS to ScrollMagic example
.wp-block-media-text{
> figure{
> img{
opacity: 0;
transition: .3s opacity ease-in;
&.active{
opacity: 1;
}
}
}
@rdswd
rdswd / theme.js
Last active June 1, 2023 10:58
ScrollMagic - our theme.js file where you use some ScrollMagic examples
<script>
( function(){
// init controller
var controller = new ScrollMagic.Controller();
//Example of adding to all class names
var pullQuotes = document.getElementsByClassName( 'wp-block-pullquote' );
for (var i = 0; i < pullQuotes.length; i++){
var elHeight = pullQuotes[i].offsetHeight;
var quoteTransform = new ScrollMagic.Scene({triggerElement: pullQuotes[i], duration: elHeight })
.setClassToggle(".wp-block-pullquote p", "has-amber-color" ) // add class toggle, and add class color from your theme
@rdswd
rdswd / functions.php
Created April 1, 2020 02:40
ScrollMagic - enqueueing a theme javascript file to use ScrollMagic
<?php
//Add to your script function in functions.php
wp_enqueue_script( 'int-theme-js', get_template_directory_uri() . '/js/theme.js', array( 'int-scrollmagic-js', 'int-scrollmagic-indicators-js' ), '20200101', true );
@rdswd
rdswd / functions.php
Last active April 1, 2020 02:36
ScrollMagic - Our theme's scripts function in functions.php.
<?php
function int_design_31_scripts() {
//Leave your other enqueues for fonts, stylesheets, etc.
//ScrollMagic - https://scrollmagic.io/
wp_enqueue_script( 'int-scrollmagic-js', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/ScrollMagic.min.js', array(), '20200101', true );
//For development and debugging
wp_enqueue_script( 'int-scrollmagic-indicators-js', '//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.7/plugins/debug.addIndicators.min.js', array(), '20200101', true );
}
@rdswd
rdswd / icons-sprite.svg.php
Created March 25, 2020 18:41
Put this svg in a new svg folder in your theme's directory.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" display="none">
<defs>
<style>
</style>
<clipPath id="clip-path">
<rect class="cls-1" width="50" height="50"/>
</clipPath>
<clipPath id="clip-path-2">
<rect class="cls-1" x="352.42" y="1.92" width="44.65" height="46.08"/>
</clipPath>
@rdswd
rdswd / functions.php
Last active March 25, 2020 18:40
Enqueueing Javascript
wp_enqueue_script( 'awd2-social-media-js', get_template_directory_uri() . '/js/theme.js', array(), '20151215', true );
@rdswd
rdswd / gist:c6748fa71257c2f49131ba3b7c20f781
Created March 25, 2020 17:56
Social media menu javascript
( function (){
/* Uses the menu id of your social media menu */
int_wl_social_menu("social-menu");
/** Uses loaded-in-header svg sprite to create svg icons for menus */
function int_wl_social_menu(id, altIcons ) {
var menu, menuLis;
/* Social menu ID */
menu = document.getElementById(id);
if ( ! menu ){
return;
@rdswd
rdswd / template-functions_partial.php
Created March 2, 2020 21:27
Excerpt customization functions in template-functions.php
/**
* Changes excerpt length
* @param integer $length the number of characters to show
* @return integer the number of characters to show
*/
function int_31_excerpt_length($length) {
return 25;
}
add_filter( 'excerpt_length', 'int_31_excerpt_length' );