Skip to content
This repository has been archived by the owner on Aug 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #144 from semperfiwebdesign/development
Browse files Browse the repository at this point in the history
Base to master for v2.4.11
  • Loading branch information
wpsmort authored Jan 23, 2017
2 parents 0d133a4 + 854bdcd commit a2bd387
Show file tree
Hide file tree
Showing 15 changed files with 425 additions and 707 deletions.
66 changes: 32 additions & 34 deletions classes/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,46 @@ class SM_Admin {
* Init the admin menu and pages.
*/
public function __construct() {
add_action( 'admin_menu', array( &$this, 'menu_shuffle' ), 20 );
add_action( 'admin_head', array( &$this, 'load_admin_scripts' ) );
add_action( 'admin_menu', array( &$this, 'add_addl_menus' ), 20 );
}

public function menu_shuffle() {
// Remove Menu added by WordPress UI and add my own as a subpage.
global $menu, $simple_map, $sm_options, $sm_help, $sm_import_export;
/**
* Add's our submenus to the CPT top level menu.
*/
public function add_addl_menus(){
global $simple_map, $sm_options, $sm_help, $sm_import_export;

// Get options.
$options = $simple_map->get_options();

// Loop through menu and find the one we need to disable.
foreach ( $menu as $key => $value ) {
if ( in_array( 'edit.php?post_type=sm-location', $value, true ) ) {
unset( $menu[ $key ] );
}
}
add_menu_page( __( 'SimpleMap Options', 'SimpleMap' ), 'SimpleMap', apply_filters( 'sm-admin-permissions-sm-options', 'publish_posts' ), 'simplemap', array(
&$sm_options,
'print_page',
), SIMPLEMAP_URL . '/inc/images/icon.png' );
add_submenu_page( 'simplemap', __( 'SimpleMap: General Options', 'SimpleMap' ), __( 'General Options', 'SimpleMap' ), apply_filters( 'sm-admin-permissions-sm-options', 'manage_options' ), 'simplemap', array(
&$sm_options,
'print_page',
) );
add_submenu_page( 'simplemap', __( 'SimpleMap: Add Location', 'SimpleMap' ), __( 'Add Location', 'SimpleMap' ), apply_filters( 'sm-admin-permissions-sm-add-locations', 'publish_posts' ), 'post-new.php?post_type=sm-location' );
add_submenu_page( 'simplemap', __( 'SimpleMap: Edit Locations', 'SimpleMap' ), __( 'Edit Locations', 'SimpleMap' ), apply_filters( 'sm-admin-permissions-sm-edit-locations', 'publish_posts' ), 'edit.php?post_type=sm-location' );

foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) {
add_submenu_page( 'simplemap', __( 'SimpleMap: Location ' . $tax_info['plural'], 'SimpleMap' ), __( 'Location ' . $tax_info['plural'], 'SimpleMap' ), 'publish_posts', 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=sm-location' );
}

add_submenu_page( 'simplemap', __( 'SimpleMap: Import / Export CSV', 'SimpleMap' ), __( 'Import / Export CSV', 'SimpleMap' ), 'publish_posts', 'simplemap-import-export', array(
&$sm_import_export,
'print_page',
) );
add_submenu_page( 'simplemap', __( 'SimpleMap: Premium Support', 'SimpleMap' ), __( 'Premium Support', 'SimpleMap' ), 'publish_posts', 'simplemap-help', array(
&$sm_help,
'print_page',
) );
}
add_submenu_page( 'edit.php?post_type=sm-location',
__( 'SimpleMap: General Options', 'simplemap' ),
__( 'General Options', 'simplemap' ),
apply_filters( 'sm-admin-permissions-sm-options',
'manage_options' ), 'simplemap', array(
&$sm_options,
'print_page',
) );
add_submenu_page( 'edit.php?post_type=sm-location',
__( 'SimpleMap: Import / Export CSV', 'simplemap' ),
__( 'Import / Export CSV', 'simplemap' ), 'publish_posts',
'simplemap-import-export', array(
&$sm_import_export,
'print_page',
) );
add_submenu_page( 'edit.php?post_type=sm-location',
__( 'SimpleMap: Premium Support', 'simplemap' ),
__( 'Premium Support', 'simplemap' ), 'publish_posts',
'simplemap-help', array(
&$sm_help,
'print_page',
) );
}

/**
* TODO: Currently this loads on toplevel_page_simplemap... but that could change once we redo the menus.
*/
public function load_admin_scripts() {
// Print admin scripts.
global $current_screen;
Expand Down
2 changes: 1 addition & 1 deletion classes/ft-ps-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function init_premium_support() {

// We have a premium support license for this domain / product combination. Set the transient and property
set_transient( $status_key, $response->support_status, 60 * 60 * 24 );
//set_transient( $status_key, $response->support_status, 60 );
//set_transient( $status_key, $response->support_status, 60 );
$this->ps_status = $response->support_status;

// Did we get a user sso back as well? Set the property if we did
Expand Down
91 changes: 45 additions & 46 deletions classes/help.php

Large diffs are not rendered by default.

35 changes: 27 additions & 8 deletions classes/import-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ public function import_csv() {
// Include CSV library.
require_once( SIMPLEMAP_PATH . '/classes/parsecsv.lib.php' );

$file_location = WP_PLUGIN_DIR . '/sm-temp-csv-' . $blog_id . '.csv';
$file_location = $this->get_import_path( $blog_id . '.csv' );

if ( file_exists( $file_location ) && $csv = new smParseCSV() ) {
$csv->auto( $file_location );
Expand Down Expand Up @@ -476,11 +476,12 @@ public function import_csv() {
$term_id = $term_array['term_id'];
}

// This is just a failsafe. It also gives us access to vars the WP API created rather than from the CSV.
if ( ! is_wp_error( $term_id ) && $term = get_term( (int) $term_id, $taxonomy ) && ! is_wp_error( $term ) ) {
// Associate (last var appends term to rather than replaces existing terms).
wp_set_object_terms( $id, $term->name, $taxonomy, true );
unset( $term );
// This is just a failsafe. It also gives us access to vars the WP API created rather than from the CSV
if ( ! is_wp_error( $term_id ) && ( $term = get_term( (int) $term_id, $taxonomy ) ) && ! is_wp_error( $term ) ) {
// Associate (last var appends term to rather than replaces existing terms)
wp_set_object_terms( $id, $term->name, $taxonomy, true );
unset( $term );

}
}
}
Expand Down Expand Up @@ -513,6 +514,24 @@ public function import_csv() {
}
}

/**
* Gets import path.
*
* @param $file
*
* @return string
*/
function get_import_path( $file ) {
$upload_dir = wp_upload_dir();

// fallback to original path...?
if ( isset( $upload_dir['error'] ) && ! empty( $upload_dir['error'] ) ) {
return WP_PLUGIN_DIR . '/sm-temp-csv-' . $file;
}

return $upload_dir['path'] . '/sm-temp-csv-' . $file;
}

/**
* CSV Preview.
*
Expand Down Expand Up @@ -555,7 +574,7 @@ public function do_csv_preview() {

echo '</h3>
<div class="inside" style="padding: 0 10px 10px 10px;">
<div class="inside sm-scroll" style="padding: 0 10px 10px 10px;">
<p class="howto">';

Expand All @@ -568,7 +587,7 @@ public function do_csv_preview() {
// Include CSV library.
include_once( SIMPLEMAP_PATH . '/classes/parsecsv.lib.php' );

$file_location = WP_PLUGIN_DIR . '/sm-temp-csv-' . $blog_id . '.csv';
$file_location = $this->get_import_path( $blog_id . '.csv' );
if ( move_uploaded_file( $_FILES['simplemap-csv-upload']['tmp_name'], $file_location ) ) {
if ( $csv = new smParseCSV( $file_location ) ) {
echo '
Expand Down
Loading

0 comments on commit a2bd387

Please sign in to comment.