Skip to content

Instantly share code, notes, and snippets.

View esoileme's full-sized avatar

Elissavet Soileme esoileme

View GitHub Profile
// Add term page
function custom_url_taxonomy_add_new_meta_field() {
// this will add the custom meta field to the add new term page
?>
<div class="form-field">
<label for="term_meta[custom_term_meta]"><?php _e( 'Custom url category', 'custom_url_category' ); ?></label>
<input type="text" name="term_meta[custom_term_meta]" id="term_meta[custom_term_meta]" value="">
<p class="description"><?php _e( 'Inserisci un custom url prodotto per la categoria','custom_url_category' ); ?></p>
</div>
<?php
@esoileme
esoileme / gravity_forms_fill_product_dropdowns
Created May 23, 2018 11:06
Gravity Forms - Fill dropdown with custom fields
/*Get the Page id as parameter from the link and fill dropdowns with the custom fields that you need from this page
We use gravity forms, and field Product (type dropdown).
In this example in pages there are parameters as date1, date2 etc and prices like price (default price) price1, price2 etc.
The form with id 3 will be filled with the above parameters and corresponding prices, if there is no corresponding price default price will be filled in.
*/
add_filter( 'gform_pre_render_3', 'populate_dates' );
@esoileme
esoileme / gravityforms-checkbox-checkall.js
Created May 23, 2018 10:40 — forked from carlitoescobar/gravityforms-checkbox-checkall.js
Gravity Forms check all function (jQuery)
// Needed this for a client project, thanks! I improved upon it to make it more generic so you don't have to look up individual IDs on elements:
jQuery(document).ready(function(){
// Check all in Gravity Forms
jQuery('.checkall li:first-child input').click(function() {
jQuery(this).parent('li').parent('ul').find(':checkbox').attr('checked', this.checked);
});
});
// Just add a class "checkall" to your checkbox form item in Gravity Forms, it assumes the first item in the list will be the "All" option.
@esoileme
esoileme / display_country_code_wpml.php
Created March 23, 2018 11:10
Display the country code on specific menu location with wpml
// Filter wp_nav_menu() to add additional links and other output
function new_nav_menu_items($items,$args) {
if ($args->theme_location == 'primary-menu') {
if (function_exists('icl_get_languages')) {
$languages = icl_get_languages('skip_missing=0');
if(1 < count($languages)){
foreach($languages as $l){
if(!$l['active']){
$items = $items.'<li class="menu-item menu-item-type-custom menu-item-object-custom current-menu-item current_page_item menu-item-00000"><a href="'.$l['url'].'">'.$l['language_code'].'</a></li>';
}
@esoileme
esoileme / shortcode-custom-post-with-pagination.php
Created March 21, 2018 08:15 — forked from ozamancse/shortcode-custom-post-with-pagination.php
Shortcode custom post loop with pagination in
<?php
function portfolios_shortcode($atts){
extract( shortcode_atts( array(
'expand' => '',
), $atts) );
global $paged;
$posts_per_page = 6;
$settings = array(
@esoileme
esoileme / primary_category.php
Created March 19, 2018 08:00 — forked from jawinn/primary_category.php
Display Primary Category (Yoast's WordPress SEO)
<?php
// SHOW YOAST PRIMARY CATEGORY, OR FIRST CATEGORY
$category = get_the_category();
$useCatLink = true;
// If post has a category assigned.
if ($category){
$category_display = '';
$category_link = '';
if ( class_exists('WPSEO_Primary_Term') )
@esoileme
esoileme / function.php
Created January 25, 2018 14:24
Custom membership-login page for logged users
<?php
function replace_swpm_login_form_shortcode_function(){
global $wpdb;
$cur_prefix = $wpdb->prefix;
$current_user = wp_get_current_user();
$user_login_get = $current_user->user_login;