= '3.3' ) { require_once ( 'jigoshop-admin-help.php' ); } function jigoshop_admin_init () { require_once ( 'jigoshop-admin-settings-options.php' ); add_action('wp_dashboard_setup', 'jigoshop_setup_dashboard_widgets' ); } add_action('admin_init', 'jigoshop_admin_init'); function jigoshop_get_plugin_data( $key = 'Version' ) { $data = get_plugin_data( jigoshop::plugin_path().'/jigoshop.php' ); return $data[$key]; } add_action('admin_notices', 'jigoshop_update'); function jigoshop_update() { // Run database upgrade if required if ( is_admin() && get_site_option('jigoshop_db_version') < JIGOSHOP_VERSION ) { if ( isset($_GET['jigoshop_update_db']) && (bool) $_GET['jigoshop_update_db'] ) { require_once( jigoshop::plugin_path().'/jigoshop_upgrade.php' ); $response = jigoshop_upgrade(); // If we successfull inform the user if ( $response ) { echo '

'.__('Your database has been successfully updated. Your shop is now automatically better than the rest, oh happy day!', 'jigoshop').'!

'; } } else { echo '

' . __('Uh oh! Looks like your Jigoshop database needs updating, just to be safe please backup your database before clicking this button!', 'jigoshop') . '

' . __('I\'ve backed up, now update me!', 'jigoshop') . '

'; } } } /** * Admin Menus * * Sets up the admin menus in wordpress. * * @since 1.0 */ function jigoshop_admin_menu() { global $menu; $menu[] = array( '', 'read', 'separator-jigoshop', '', 'wp-menu-separator jigoshop' ); add_menu_page(__('Jigoshop'), __('Jigoshop'), 'manage_options', 'jigoshop' , 'jigoshop_dashboard', jigoshop::assets_url() . '/assets/images/icons/menu_icons.png', 55); add_submenu_page('jigoshop', __('Dashboard', 'jigoshop'), __('Dashboard', 'jigoshop'), 'manage_options', 'jigoshop', 'jigoshop_dashboard'); add_submenu_page('jigoshop', __('General Settings', 'jigoshop'), __('Settings', 'jigoshop') , 'manage_options', 'jigoshop_settings', 'jigoshop_settings'); add_submenu_page('jigoshop', __('System Info','jigoshop'), __('System Info','jigoshop'), 'manage_options', 'jigoshop_sysinfo', 'jigoshop_system_info'); $id = add_submenu_page('edit.php?post_type=product', __('Attributes','jigoshop'), __('Attributes','jigoshop'), 'manage_options', 'jigoshop_attributes', 'jigoshop_attributes'); } function jigoshop_admin_menu_order( $menu_order ) { // Initialize our custom order array $jigoshop_menu_order = array(); // Get the index of our custom separator $jigoshop_separator = array_search( 'separator-jigoshop', $menu_order ); $jigoshop_product = array_search( 'edit.php?post_type=product', $menu_order ); $jigoshop_order = array_search( 'edit.php?post_type=shop_order', $menu_order ); // Loop through menu order and do some rearranging foreach ( $menu_order as $index => $item ) : if ( 'jigoshop' == $item ) : $jigoshop_menu_order[] = 'separator-jigoshop'; $jigoshop_menu_order[] = $item; $jigoshop_menu_order[] = 'edit.php?post_type=product'; $jigoshop_menu_order[] = 'edit.php?post_type=shop_order'; unset( $menu_order[$jigoshop_separator] ); unset( $menu_order[$jigoshop_product] ); unset( $menu_order[$jigoshop_order] ); elseif ( !in_array( $item, array( 'separator-jigoshop' ) ) ) : $jigoshop_menu_order[] = $item; endif; endforeach; // Return order return $jigoshop_menu_order; } function jigoshop_admin_custom_menu_order() { return current_user_can( 'manage_options' ); } add_action('admin_menu', 'jigoshop_admin_menu'); add_action('menu_order', 'jigoshop_admin_menu_order'); add_action('custom_menu_order', 'jigoshop_admin_custom_menu_order'); /** * Admin Head * * Outputs some styles in the admin to show icons on the jigoshop admin pages * * @since 1.0 */ function jigoshop_admin_head() { ?>

Use the information below when submitting technical support requests via Jigoshop Support.

 
 
 
' . __('Your server supports fsockopen.', 'jigoshop'). ''; else echo '' . __('Your server does not support fsockopen.', 'jigoshop'). ''; ?>
post_type !== 'product') die; $product = new jigoshop_product($post->ID); update_post_meta( $post->ID, 'featured', ! $product->is_featured() ); $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); wp_safe_redirect( $sendback ); } add_action('wp_ajax_jigoshop-feature-product', 'jigoshop_feature_product'); /** * Returns proper post_type */ function jigoshop_get_current_post_type() { global $post, $typenow, $current_screen; if( $current_screen && @$current_screen->post_type ) return $current_screen->post_type; if( $typenow ) return $typenow; if( !empty($_REQUEST['post_type']) ) return sanitize_key( $_REQUEST['post_type'] ); if ( !empty($post) && !empty($post->post_type) ) return $post->post_type; if( ! empty($_REQUEST['post']) && (int)$_REQUEST['post'] ) { $p = get_post( $_REQUEST['post'] ); return $p ? $p->post_type : ''; } return ''; } /** * Categories ordering */ /** * Load needed scripts to order categories */ function jigoshop_categories_scripts () { if( !isset($_GET['taxonomy']) || $_GET['taxonomy'] !== 'product_cat') return; wp_register_script('jigoshop-categories-ordering', jigoshop::assets_url() . '/assets/js/categories-ordering.js', array('jquery-ui-sortable')); wp_print_scripts('jigoshop-categories-ordering'); } add_action('admin_footer-edit-tags.php', 'jigoshop_categories_scripts'); /** * Ajax request handling for categories ordering */ function jigoshop_categories_ordering () { global $wpdb; $id = (int)$_POST['id']; $next_id = isset($_POST['nextid']) && (int) $_POST['nextid'] ? (int) $_POST['nextid'] : null; if( ! $id || ! $term = get_term_by('id', $id, 'product_cat') ) die(0); jigoshop_order_categories ( $term, $next_id); $children = get_terms('product_cat', "child_of=$id&menu_order=ASC&hide_empty=0"); if( $term && sizeof($children) ) { echo 'children'; die; } } add_action('wp_ajax_jigoshop-categories-ordering', 'jigoshop_categories_ordering'); if (!function_exists('boolval')) { /** * Helper function to get the boolean value of a variable. If not strict, this function will return true * if the variable is not false and not empty. If strict, the value of the variable must exactly match a * value in the true test array to evaluate to true * * @param $in The input variable * @param bool $strict * @return bool|null|string */ function boolval($in, $strict = false) { if (is_bool($in)){ return $in; } $in = strtolower($in); $out = null; if (in_array($in, array('false', 'no', 'n', 'off', '0', 0, null), true)) { $out = false; } else if ($strict) { if (in_array($in, array('true', 'yes', 'y', 'on', '1', 1), true)) { $out = true; } } else { $out = ($in ? true : false); } return $out; } } /** * Replaces Recent Comments Dashboard widget with shop message filtered ver * * The only difference between the two is the query now takes into account * shop order messages. Unfortunately WordPress hasn't made this very easy * to achieve due to the query being hard coded so a complete * replacement was necessary :( * * Sourced from dashboard.php */ function jigoshop_setup_dashboard_widgets() { remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' ); wp_add_dashboard_widget('jigoshop_recent_comments', 'Recent Comments', 'jigoshop_dashboard_recent_comments', 'jigoshop_dashboard_recent_comments_control'); } function jigoshop_dashboard_recent_comments() { global $wpdb; if ( current_user_can('edit_posts') ) $allowed_states = array('0', '1'); else $allowed_states = array('1'); // Select all comment types and filter out spam later for better query performance. $comments = array(); $start = 0; $widgets = get_option( 'dashboard_widget_options' ); $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] ) ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5; while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' AND c.comment_type != 'jigoshop' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) { foreach ( $possible as $comment ) { if ( count( $comments ) >= $total_items ) break; if ( in_array( $comment->comment_approved, $allowed_states ) && current_user_can( 'read_post', $comment->comment_post_ID ) ) $comments[] = $comment; } $start = $start + 50; } if ( $comments ) : ?>
views(); ?>

'; echo '

'; }