Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bug fixes, removed readmes

  • Loading branch information...
commit 7b67990b6a20b389ced8d45fea4e5da9f97b4670 1 parent b1d073a
@benbalter authored
View
6 css/readme.md
@@ -1,6 +0,0 @@
-CSS
-===
-
-Your plugin's stylesheet files should go in the `front-end` and `admin` folders.
-
-Any .css file in the folder will be included automatically. Inclusion can be filter (e.g., to only include on certain pages) via filter.
View
4 img/readme.md
@@ -1,4 +0,0 @@
-Images
-======
-
-Place images in this folder
View
74 includes/admin.php
@@ -24,6 +24,8 @@ function __construct( &$instance ) {
add_action( 'wp_resume_organization_add_form', array( &$this, 'org_helptext' ) );
add_action( 'admin_init', array( &$this, 'enqueue_scripts' ) );
add_filter( 'option_page_capability_wp_resume_options', array( &$this, 'cap_filter' ), 10, 1 );
+ add_filter( 'wp_resume_enqueue_js', array( &$this, 'maybe_enqueue' ), 10, 3 );
+ add_filter( 'wp_resume_enqueue_css', array( &$this, 'maybe_enqueue_css' ), 10, 3 );
//ajax callbacks
add_action('wp_ajax_add_wp_resume_section', array( &$this, 'ajax_add') );
@@ -128,7 +130,7 @@ function ajax_add() {
* @param obj $post the post object
*/
function order_box($post) {
- self::$parent->template->order_box();
+ self::$parent->template->order_box( compact( 'post' ) );
}
/**
@@ -152,7 +154,7 @@ function taxonomy_box( $post, $type ) {
//garb the current selected term where applicable so we can select it
$current = wp_get_object_terms( $post->ID, $type );
- self::$parent->template->taxonomy_box( compact( $taxonomy, $type, $terms, $current ) );
+ self::$parent->template->taxonomy_box( compact( 'taxonomy', 'type', 'terms', 'current' ) );
}
@@ -167,7 +169,7 @@ function date_box( $post ) {
$from = get_post_meta( $post->ID, 'wp_resume_from', true );
$to = get_post_meta( $post->ID, 'wp_resume_to', true );
- self::$parent->template->date_box( compact( $from, $to ) );
+ self::$parent->template->date_box( compact( 'from', 'to' ) );
}
@@ -412,7 +414,7 @@ function options() {
$user_options = self::$parent->options->get_user_options( (int) $current_author );
- self::$parent->template->options( compact( $user_options, $authors, $current_author, $options ) );
+ self::$parent->template->options( compact( 'user_options', 'authors', 'current_author', 'options' ) );
}
@@ -435,7 +437,7 @@ function order_dragdrop( $current_author ) {
?>
<ul id="sections">
<?php //loop through the user's non-empty section
- foreach ( $this->get_sections( true, $current_author ) as $section )
+ foreach ( self::$parent->get_sections( true, $current_author ) as $section )
$this->dragdrop_section ( $current_author, $section );
?>
</ul><!-- #sections -->
@@ -538,15 +540,14 @@ function org_helptext() {
*/
function link_field( $term, $taxonomy = '' ) {
- $options = $this->get_options( );
$tax = get_taxonomy( $taxonomy );
$edit = ( $taxonomy != '' );
$value = '';
- if ( $edit && $this->get_org_link( $term->term_id ) )
- $value = $this->get_org_link( $term->term_id );
+ if ( $edit && self::$parent->get_org_link( $term->term_id ) )
+ $value = self::$parent->get_org_link( $term->term_id );
- self::$parent->template->link_field( compact( $edit, $value, $taxonomy ) );
+ self::$parent->template->link_field( compact( 'edit', 'value', 'taxonomy' ) );
}
/**
@@ -561,7 +562,7 @@ function save_link_field( $termID ) {
if ( !current_user_can( $tax->cap->edit_terms ) )
return;
- $this->set_org_link( $termID, $_REQUEST['org_link'] );
+ self::$parent->set_org_link( $termID, $_REQUEST['org_link'] );
}
@@ -592,20 +593,13 @@ function enqueue_scripts() {
$suffix = ( WP_DEBUG ) ? 'dev.' : '';
- $post = false;
- if ( !empty( $_GET['post'] ) )
- $post = get_post( $_GET['post'] );
-
//load javascript with libraries on options page
if ( !empty ( $_GET['page'] ) && $_GET['page'] == 'wp_resume_options' ) {
- wp_enqueue_script( 'wp_resume', plugins_url('/js/wp_resume.' . $suffix . 'js', __FILE__), array("jquery", "jquery-ui-core", "jquery-ui-sortable", "wp-lists", "jquery-ui-sortable"), $this->version );
- //if on the org, section, or edit page, load the script without all the libraries
- } else if ( ( !empty( $_GET['post_type'] ) && $_GET['post_type'] == 'wp_resume_position' ) ||
- ( !empty( $_GET['post'] ) && $post && $post->post_type == 'wp_resume_position' ) ) {
- wp_enqueue_script( 'wp_resume', plugins_url('/js/wp_resume.' . $suffix . 'js', __FILE__), array("jquery"), $this->version );
- }
+ foreach ( array("jquery", "jquery-ui-core", "jquery-ui-sortable", "wp-lists", "jquery-ui-sortable" ) as $script )
+ wp_enqueue_script( $script );
+ }
- $data = array(
+ self::$parent->enqueue->admin_data = array(
'more' => __('More', 'wp-resume'),
'less' => __('less', 'wp-resume'),
'yes' => __('Yes!', 'wp-resume'),
@@ -616,9 +610,43 @@ function enqueue_scripts() {
'orgLoc' => __('Traditionally the location of the organization (optional)', 'wp-resume'),
'missingTaxMsg' => __( 'Please make sure that the position is associated with a section before saving', 'wp-resume'),
);
- wp_localize_script( 'wp_resume', 'wp_resume', $data );
+
+ }
+ /**
+ * Helper function to load contact_info_row template
+ * @since 3.0
+ */
+ function contact_info_row( $value, $field_id ) {
+ self::$parent->template->contact_info_row( compact( 'field_id', 'value' ) );
+ }
+
+ /**
+ * Only load javscript on resume pages
+ * @since 3.0
+ */
+ function maybe_enqueue( $default, $file, $name ) {
+
+ $screen = get_current_screen();
+
+ if ( $screen->post_type == 'wp_resume_position' )
+ return true;
+
+ return $default;
+ }
+
+ /**
+ * Only load css on resume pages and always on front end
+ * @since 3.0
+ */
+ function maybe_enqueue_css( $default, $file, $name ) {
+
+ //only filter admin
+ if ( $name != 'admin' )
+ return $default;
+
+ return $this->maybe_enqueue( $default, $file, $name );
+
}
-
}
View
2  includes/boilerplate-classes/api.php
@@ -92,7 +92,7 @@ function api( $type, $name ) {
array_shift( $args );
$prefix = self::$parent->prefix;
$args[0] = $prefix . $name;
-
+
return call_user_func_array( $function, $args );
}
View
10 includes/boilerplate-classes/enqueue.php
@@ -22,10 +22,10 @@ function __construct( $instance ) {
else
self::$parent = &$instance;
- add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_js' ) );
- add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_css' ) );
- add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_front_end_css' ) );
- add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_front_end_js' ) );
+ add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_js' ), 50 );
+ add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_admin_css' ), 50 );
+ add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_front_end_css' ), 50 );
+ add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_front_end_js' ), 50 );
}
@@ -75,7 +75,7 @@ function enqueue_js( $name ) {
}
- $data = $name . '_data';
+ $data = str_replace( '-', '_', $name . '_data' );
$this->$data = apply_filters( 'localize_script', $this->$data, $name );
if ( empty( $this->$data ) )
View
2  includes/boilerplate-classes/options.php
@@ -125,7 +125,7 @@ function set_user_options( $options, $user = null, $global = false, $merge = tru
* @return array the options
*/
function get_options( ) {
-
+
if ( !$options = self::$parent->cache->get( 'options' ) ) {
$options = (array) get_option( self::$parent->slug_ );
$options = wp_parse_args( $options, $this->defaults );
View
35 includes/boilerplate-classes/template.php
@@ -22,7 +22,11 @@ function __construct( $instance ) {
/**
* Allow templates to be loaded in the form of $object->templates->{template_name}();
*/
- function __call( $template, $args = null ) {
+ function __call( $template, $args = array() ) {
+
+ if ( !empty( $args ) )
+ $args = $args[0];
+
return $this->load( $template, $args );
}
@@ -33,32 +37,35 @@ function __call( $template, $args = null ) {
*
* To pass arguments to the template, pass an array or compact
*
+ * Variables in this function are prefixed to avoid collision
+ *
*/
- function load( $template, $args = null ) {
+ function load( $_pb_template, $args = null ) {
if ( is_array( $args ) )
- extract( $args );
-
- $template = self::$parent->api->apply_filters( 'template', $template );
+ extract( $args );
+
+ $_pb_template = self::$parent->api->apply_filters( 'template', $_pb_template );
- $file = false;
+ $_pb_file = false;
//if in overrides or set by filter look in child then parent folder for the file
//before looking in plugin's template folder
//note: by default, this functionality is disabled
- if ( in_array( $template, $this->overrides ) ||
- self::$parent->api->apply_filters( 'allow_template_override', false, $template ) )
- $file = locate_template( $template );
+ if ( in_array( $_pb_template, $this->overrides ) ||
+ self::$parent->api->apply_filters( 'allow_template_override', false, $_pb_template ) )
+ $_pb_file = locate_template( $_pb_template );
- if ( !$file )
- $file = self::$parent->directory . $this->path . $template . '.php';
+ if ( !$_pb_file )
+ $_pb_file = self::$parent->directory . $this->path . $_pb_template . '.php';
- if ( !file_exists( $file ) ) {
- trigger_error( "{self::$parent->name} -- cannot locate template $file" );
+ if ( !file_exists( $_pb_file ) ) {
+ $backtrace = debug_backtrace();
+ trigger_error( self::$parent->name . " -- cannot locate template $_pb_file called on line {$backtrace[1]['line']} of {$backtrace[1]['file']}" );
return false;
}
- include( $file );
+ include( $_pb_file );
return true;
View
16 includes/readme.md
@@ -1,16 +0,0 @@
-Includes
-========
-
-Additional classes you want auto-included should go in this folder.
-
-Naming
-------
-
-* Each file should contain a single class.
-* The class should be in the format of {Parent_Class}_{Class_Name}.
-* The file should be {class-name}.php.
-
-Example
--------
-
-If the parent class is `Hello_Dolly2`, and the file should be `sample-lyrics.php` and the class within the file should be `Hello_Dolly2_Sample_Lyrics`.
View
10 js/readme.md
@@ -1,10 +0,0 @@
-Javascript
-==========
-
-Your plugin's javascript files should go in the `front-end` and `admin` folders.
-
-Any .js file in the folder will be included automatically. Inclusion can be filter (e.g., to only include on certain pages) via filter.
-
-Files ending in `.dev.js` will be preferred if using `WP_DEBUG` or `SCRIPT_DEBUG`.
-
-If set, any i18n data will be stored as the plugin slug.
View
14 languages/readme.md
@@ -1,14 +0,0 @@
-Languages
-=========
-
-`.pot` and language files should go in this folder.
-
-Text Domain
------------
-
-Use the plugin's admin page on WordPress.org to add a text-domain to all files. Text domain should match `$slug` in the main class.
-
-Naming
-------
-
-Files should be named {slug}-{Language}, e.g., `wp-document-revisions-fr_FR`.
View
4 templates/contact_info_row.php
@@ -1,10 +1,10 @@
<li id="contact_info_row[]" class="contact_info_row">
<select name="wp_resume_options[contact_info_field][]" id="contact_info_field[]">
<option></option>
- <?php foreach ( $this->contact_fields() as $id => $field) { ?>
+ <?php foreach ( self::$parent->contact_fields() as $id => $field) { ?>
<?php if ( is_array($field) ) {
foreach ($field as $subid => $subfield) { ?>
- <option value="<?php echo $id . '|' . $subid; ?>" <?php selected($field_id, $subid);?>>
+ <option value="<?php echo $id . '|' . $subid; ?>" <?php selected( $field_id, $subid);?>>
<?php echo $subfield; ?>
</option>
<?php } ?>
View
6 templates/options.php
@@ -51,11 +51,11 @@
<th scope="row"><?php _e('Contact Information', 'wp-resume'); ?></th>
<td>
<ul class="contact_info_blank" style="display:none;">
- <?php self::$parent->template->contact_info_row(); ?>
+ <?php self::$parent->template->contact_info_row( array( 'field_id' => '', 'value' => '' ) ); ?>
</ul>
<ul id="contact_info">
<?php if ( isset($user_options['contact_info'] ) && is_array( $user_options['contact_info'] ) )
- array_walk_recursive($user_options['contact_info'], array( &$this, 'contact_info_row' ) ); ?>
+ array_walk_recursive($user_options['contact_info'], array( &self::$parent->admin, 'contact_info_row' ) ); ?>
</ul>
<a href="#" id="add_contact_field">+ <?php _e('Add Field', 'wp-resume'); ?></a><br />
<span class="description"><?php _e('(optional) Add any contact info you would like included in your resume', 'wp-resume'); ?>.</span>
@@ -73,7 +73,7 @@
<tr valign="top">
<th scope="row"><?php _e('Resume Order', 'wp-resume'); ?></th>
<td>
- <?php $this->order_dragdrop( (int) $current_author ); ?>
+ <?php self::$parent->admin->order_dragdrop( (int) $current_author ); ?>
<span class="description"><?php _e('New positions are automatically displayed in reverse chronological order, but you can fine tune that order by rearranging the elements in the list above', 'wp-resume'); ?>.</span>
</td>
</tr>
View
21 templates/readme.md
@@ -1,21 +0,0 @@
-Templates
-=========
-
-Template files should go in this folder.
-
-Naming
-------
-
-Template files should be named `{template-name}.php`.
-
-Usage
------
-
-Called via `$base_class->template->load( 'template-name', $args )`.
-
-Variables
----------
-
-Files are included within function scope in the plugin's template path. Object properties and methods are available via `self::$parent->property` or `self::$parent->method()`. Arguments can optionally be passed as an array and will be run through `extract()` prior to inclusion.
-
-
View
17 wp-resume.php
@@ -25,8 +25,8 @@ class WP_Resume extends Plugin_Boilerplate {
public $name = 'WP Resume';
public $slug = 'wp-resume';
public $slug_ = 'wp_resume';
- public $prefix = 'wp_resume';
- public $version = '2.2.3';
+ public $prefix = 'wp_resume_';
+ public $version = '3.0';
static $instance;
public $author = '';
@@ -57,17 +57,26 @@ function __construct() {
//i18n
add_filter( 'list_terms_exclusions', array( &$this, 'exclude_the_terms' ) );
+ add_action( 'plugins_loaded', array( &$this, 'init' ) );
+
+ }
+
+ function init() {
+
//default fields and values
$this->options->defaults = array( 'fix_ie' => true,
'rewrite' => false,
'hide-title' => false
);
+
$this->options->user_defaults = array( 'name'=> '',
'summary' => '',
'contact_info'=> array(),
'order'=>array(),
'hide-donate' => false
);
+ //user overridable templates
+ $this->template->overrides = array( 'resume', 'resume-text', 'resume-json' );
}
@@ -102,13 +111,13 @@ function register_cpt_and_t() {
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
- 'menu_icon' => plugins_url( '/menu-icon.png', __FILE__ ),
+ 'menu_icon' => plugins_url( '/img/menu-icon.png', __FILE__ ),
'query_var' => true,
'rewrite' => ( isset( $options['rewrite'] ) && $options['rewrite'] ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
- 'register_meta_box_cb' => array( &$this, 'meta_callback' ),
+ 'register_meta_box_cb' => array( &$this->admin, 'meta_callback' ),
'supports' => array( 'title', 'editor', 'revisions', 'custom-fields', 'page-attributes', 'author'),
'taxonomies' => array('wp_resume_section', 'wp_resume_organization'),
);
Please sign in to comment.
Something went wrong with that request. Please try again.