. ****/ define ('ARCWV', '1.0.5'); // current version of the plugin define ('ARCW_DEBUG', false); // enable or disable debug (for dev instead of echo or print_r use debug() function) $themes = array( 'calendrier' => 'Calendrier', 'pastel' => 'Pastel', 'classiclight' => 'Classic', 'classicdark' => 'Classic Dark', 'twentytwelve' => 'Twenty Twelve', 'twentythirteen' => 'Twenty Thirteen', 'twentyfourteen' => 'Twenty Fourteen', 'twentyfourteenlight' => 'Twenty Fourteen Light', ); // ACTIVATION require('arw-install.php'); require('arw-settings.php'); require('arw-widget.php'); register_activation_hook(__FILE__, 'archivesCalendar_activation'); register_uninstall_hook(__FILE__, 'archivesCalendar_uninstall'); add_action( 'wpmu_new_blog', 'archivesCalendar_new_blog', 10, 6); // in case of creation of a new site in WPMU // LOCALISATION add_action('init', 'archivesCalendar_init'); // ADD setting action link add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'arcw_plugin_action_links' ); // Register and enqueue Archives Calendar Widjet jQuery plugin add_action( 'wp_enqueue_scripts', 'archivesCalendar_jquery_plugin' ); // Scripts to be included on Widget configuration page add_action( 'admin_print_scripts-widgets.php', 'arcw_admin_widgets_scripts' ); if($archivesCalendar_options['css'] == 1) // Archives Calendar Widget Themes CSS add_action('wp_enqueue_scripts', 'archives_calendar_styles'); if($archivesCalendar_options['js'] == 1) // Archives calendar Javascript (placed in ) add_action('wp_head', 'archivesCalendar_js'); // WIDGET INITIALISATION add_action( 'widgets_init', create_function( '', 'register_widget( "Archives_Calendar" );' ) ); /**** INIT/ENQUEUE FUNCTIONS ****/ function archivesCalendar_init() { load_plugin_textdomain('arwloc', false, dirname(plugin_basename(__FILE__)).'/languages'); } function arcw_plugin_action_links( $links ) { $links[] = ''.__('Settings').''; return $links; } function archivesCalendar_jquery_plugin() { wp_register_script( 'archivesCW', plugins_url('/admin/js/jquery.archivesCW.min.js', __FILE__), array("jquery"), ARCWV ); wp_enqueue_script( 'archivesCW'); } function archivesCalendar_js() { global $archivesCalendar_options; echo ''; } function archives_calendar_styles() { $archivesCalendar_options = get_option('archivesCalendar'); wp_register_style( 'archives-cal-'.$archivesCalendar_options['theme'], plugins_url('themes/'.$archivesCalendar_options['theme'].'.css', __FILE__), array(), ARCWV ); wp_enqueue_style('archives-cal-'.$archivesCalendar_options['theme'] ); } function arcw_admin_widgets_scripts() { wp_register_script( 'arcwpWidgetsPage', plugins_url('/admin/js/widgets-page.min.js', __FILE__), array(), ARCWV ); wp_enqueue_script( 'arcwpWidgetsPage' ); } /***** CHECK MULTISITE NETWORK *****/ if (!function_exists('isMU')) { function isMU() { if (function_exists('is_multisite') && is_multisite()) return true; return false; } } function make_arcw_link($type = null, $cats = null){ global $archivesCalendar_options; if($archivesCalendar_options['filter'] == 0) return ''; $attrs = ''; if(!empty($type) && count($type)){ if($type == 'post') $attrs = ''; else $attrs .= '?p='.$type; } if(!empty($cats)){ if($attrs == '') $attrs .= '?c='.$cats; else $attrs .= '&c='.$cats; $attrs = str_replace(' ', '', $attrs); } return $attrs; } // Activate filter in archives page if(isset($archivesCalendar_options['filter']) && $archivesCalendar_options['filter'] == 1) add_action( 'pre_get_posts', 'arcw_filter' ); function arcw_filter( $query ) { if ( ! is_archive() || is_admin() ) { return; } if ( isset( $_GET ) ) { if ( isset( $_GET['c'] ) && $_GET['c'] != '' ) { $cats = $_GET['c']; $query->set( 'cat', $cats ); } if ( isset( $_GET['p'] ) && $_GET['p'] != '' ) { $post_types = explode( ',', $_GET['p'] ); $query->set( 'post_type', $post_types ); if(isset($cats)){ $query->set( 'tax_query', array( 'relation' => 'AND', array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => explode(',', $cats), 'operator' => 'IN', ), ) ); } } } } /** DEBUG FUNCTION **/ if (!function_exists('debug')){ function debug($context = "") { if(ARCW_DEBUG === true) print_r($context); } }