Skip to content

Instantly share code, notes, and snippets.

View gagimilicevic's full-sized avatar

Milicevic Dragan gagimilicevic

View GitHub Profile
@gagimilicevic
gagimilicevic / content-page-faq.php
Created November 8, 2016 09:09
List all custom taxonomy categories (parent and child) and their content
<?php
$categories = get_categories(array(
'orderby' => 'name',
'parent' => 0,
'taxonomy' => 'faqs_category'
));
?>
<?php
@gagimilicevic
gagimilicevic / functions.php
Created November 10, 2016 15:08
Custom Post Type Filter Admin By Custom Taxonomy
add_action('restrict_manage_posts', 'dm_filter_post_type_by_taxonomy');
function dm_filter_post_type_by_taxonomy() {
global $typenow;
$post_type = 'faq'; // change to your post type
$taxonomy = 'faqs_category'; // change to your taxonomy
if ($typenow == $post_type) {
$selected = isset($_GET[$taxonomy]) ? $_GET[$taxonomy] : '';
$info_taxonomy = get_taxonomy($taxonomy);
wp_dropdown_categories(array(
'show_option_all' => __("Show All {$info_taxonomy->label}"),
@gagimilicevic
gagimilicevic / functions.php
Created November 10, 2016 15:10
Create CPT and Custom Taxonomy for CPT
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'faq',
array(
'labels' => array(
'name' => __( 'FAQ' ),
'singular_name' => __( 'FAQ' )
),
'public' => true,
#!/bin/bash
# Installation script for the latest WordPress on Ubuntu
#
# Author: Dewploy Dev Team
# Created: November 11, 2016
# Last Upate: November 11, 2016
##### Functions
@gagimilicevic
gagimilicevic / custom.js
Created November 11, 2016 08:31
Find active element and activate its parent bootstrap tab
$(document).ready(function () {
$( all_items ).each( function( index ) {
if( $( this ).attr( 'class' ) == 'active' ) {
var active_atr = $(this).closest('.tab-pane').attr('id');
$('a[href="#' + active_atr + '"]').tab('show');
}
});
});
@gagimilicevic
gagimilicevic / custom.js
Last active November 11, 2016 08:34
Scroll to element with specific class - jQuery
$(document).ready(function () {
$( all_items ).each( function( index ) {
if( $( this ).attr( 'class' ) == 'active' ) {
$('html, body').animate({
scrollTop: $( this ).offset().top - 120
}, 500);
}
});
});
@gagimilicevic
gagimilicevic / content-page-home.php
Created November 11, 2016 19:06
Get featured image url and show it to page
<?php if (has_post_thumbnail( $post->ID ) ): ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<div class="entry-header entry-header-background search-page-header" style="background-image: url('<?php echo $image[0]; ?>')">
<div class="container">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</div>
</div>
<?php endif; ?>
@gagimilicevic
gagimilicevic / CF7 Integration with Agile CRM
Created March 8, 2017 15:39
CF7 Integration with Agile CRM using AgileCRM PHP API
function CF7_to_Agile_send( $cf7 )
{
$submission = WPCF7_Submission::get_instance();
$posted_data = $submission->get_posted_data();
$email = $posted_data['your-email'];
$first_name = $posted_data['your-name'];
$contact_json = array(
@gagimilicevic
gagimilicevic / cerne-woocommerce.php
Created April 7, 2017 13:30
Unregister Woocommerce price widget and register custom widget
//Unregister Woocommerce widget and register custom widget for price filter
function override_woocommerce_widgets() {
if ( class_exists( 'WC_Widget_Price_Filter' ) ) {
unregister_widget( 'WC_Widget_Price_Filter' );
include get_template_directory() . '/inc/custom-widgets/dewploy-class-wc-widget-price-filter.php';
register_widget( 'Dewploy_WC_Widget_Price_Filter' );
}
}
add_action( 'widgets_init', 'override_woocommerce_widgets', 15 );
@gagimilicevic
gagimilicevic / functions.php
Created April 7, 2017 13:32
Integrate CF7 with MailPoet custom function on submit
function CF7_to_MailPoet_integration(){
$submission = WPCF7_Submission::get_instance();
$posted_data = $submission->get_posted_data();
$email = $posted_data['your-email'];
$my_list_id = 3;
$user_data = array(
'email' => $email,
);