Skip to content

Instantly share code, notes, and snippets.

View AlphaAlec's full-sized avatar

Alec AlphaAlec

  • Vancouver
View GitHub Profile
/* partially complete conditional logic functions, submitted to Gravity Forms for help, as once the new select element is switched to, it cannot be switched away from */
function set_conditional( $form ) {
?>
<script type="text/javascript">
gform.addFilter( 'gform_conditional_logic_fields', 'set_conditional_field' );
function set_conditional_field( options, form, selectedFieldId ){
options.push({
label: 'User Role',
value: 'user-role'
/* this allows the font size to adjust automatically as the browser width changes */
font-size: calc(1.5vw + 0px);
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
/* IE10+ specific styles go here */
}
<?php
$args = array(
'post_type' => 'post',
'category_name' => array(7),
'nopaging' => true,
'suppress_filters' => true,
'fields' => 'ids'
);
$posts = new WP_Query($args);
<?php $this_term = $wp_query->get_queried_object(); ?>
@AlphaAlec
AlphaAlec / menu-transitions.php
Last active November 24, 2015 05:14
WP Menu Item Count for Mobile Menu Transitions
<?php
// you can get the menu by name, ID, slug or location
$menu_count = wp_get_nav_menu_object( 'Main Menu' ); // here we're grabbing it by name
$menu_count = $menu_count->count
?>
<style type="text/css">
<?php for($i = 1; $i <= $menu_count; $i++) { ?>
@AlphaAlec
AlphaAlec / wp-capabilities
Created March 12, 2014 20:04
Restricting Capabilities in the WP Back End
function change_role_name() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
//You can list all currently available roles like this...
//$roles = $wp_roles->get_names();
//print_r($roles);