Skip to content

Commit

Permalink
Merge pull request #185 from katzwebservices/development/refactor-data
Browse files Browse the repository at this point in the history
1.1!
  • Loading branch information
zackkatz committed Jul 24, 2014
2 parents d391fe4 + 9a02666 commit 9bf6183
Show file tree
Hide file tree
Showing 97 changed files with 3,034 additions and 24,725 deletions.
28 changes: 7 additions & 21 deletions gravityview.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* Plugin Name: GravityView
* Plugin URI: http://gravityview.co
* Description: Create directories based on a Gravity Forms form, insert them using a shortcode, and modify how they output.
* Version: 1.0.9-beta
* Version: 1.1
* Author: Katz Web Services, Inc.
* Author URI: http://www.katzwebservices.com
* Text Domain: gravity-view
Expand Down Expand Up @@ -64,7 +64,7 @@
*/
final class GravityView_Plugin {

const version = '1.0.9-beta';
const version = '1.1';

public static $theInstance;

Expand Down Expand Up @@ -106,14 +106,15 @@ public function __construct() {
require_once( GRAVITYVIEW_DIR . 'includes/class-ajax.php' );
require_once( GRAVITYVIEW_DIR . 'includes/class-settings.php');
include_once( GRAVITYVIEW_DIR .'includes/class-frontend-views.php' );
include_once( GRAVITYVIEW_DIR .'includes/class-data.php' );


// Load Extensions
// TODO: Convert to a scan of the directory or a method where this all lives
include_once( GRAVITYVIEW_DIR . 'includes/extensions/datatables/ext-datatables.php');
// @todo: Convert to a scan of the directory or a method where this all lives
include_once( GRAVITYVIEW_DIR .'includes/extensions/edit-entry/class-edit-entry.php' );

// Load plugin text domain
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
add_action( 'init', array( $this, 'load_plugin_textdomain' ), 1 );

if( ! is_admin() ) {
add_action( 'init', array( $this, 'frontend_actions' ), 20 );
Expand Down Expand Up @@ -182,22 +183,7 @@ public static function deactivate( $network_wide ) {
* @return void
*/
public function load_plugin_textdomain() {
load_plugin_textdomain( 'gravity-view', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}


/**
* Modify plugin action links at plugins screen
*
* @access public
* @static
* @param mixed $links
* @return void
*/
public static function plugin_action_links( $links ) {
$support_link = 'https://katzwebservices.zendesk.com/hc/en-us/categories/200136096';
$action = array( '<a href="' . $support_link . '">'. esc_html__( 'Support', 'gravity-view' ) .'</a>' );
return array_merge( $action, $links );
load_plugin_textdomain( 'gravity-view', false, dirname( plugin_basename( GRAVITYVIEW_FILE ) ) . '/languages/' );
}

/**
Expand Down
7 changes: 3 additions & 4 deletions includes/admin/metaboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ function render_select_form_metabox( $post ) {
/**
* Render html for 'select template' metabox
*
* @todo Re-enable the Preview link
* @group Beta
* @access public
* @param object $post
* @return void
Expand Down Expand Up @@ -141,11 +139,12 @@ function render_select_template_metabox( $post ) {
<p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button-primary button-buy-now"><?php esc_html_e( 'Buy Now', 'gravity-view'); ?></a></p>
<?php else: ?>
<p><a href="#gv_select_template" class="button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravity-view'); ?></a></p>
<!-- // TODO: Take screenshots. <p><a href="#gv_preview_template" class="button-secondary"><?php esc_html_e( 'Preview', 'gravity-view'); ?></a></p> -->
<?php if( !empty( $template['preview'] ) ) : ?>
<p><a href="<?php echo esc_url( $template['preview'] ); ?>" class="button-secondary" rel="external"><?php esc_html_e( 'Preview', 'gravity-view'); ?></a></p>
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<div class="gv-template-preview" title="<?php esc_html_e( 'Preview', 'gravity-view'); ?>: <?php echo esc_attr( $template['label'] ); ?>"><img src="<?php echo esc_url( $template['preview'] ); ?>" ></div>
<div class="gv-view-types-normal">
<img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>">
<h5><?php echo esc_attr( $template['label'] ); ?></h5>
Expand Down
2 changes: 1 addition & 1 deletion includes/class-admin-views.php
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static function add_scripts_and_styles( $hook ) {
$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';

//enqueue scripts
wp_enqueue_script( 'gravityview_views_scripts', plugins_url('includes/js/admin-views'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie' ), GravityView_Plugin::version);
wp_enqueue_script( 'gravityview_views_scripts', plugins_url('includes/js/admin-views'.$script_debug.'.js', GRAVITYVIEW_FILE), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie' ), GravityView_Plugin::version );

wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
'cookiepath' => COOKIEPATH,
Expand Down
90 changes: 8 additions & 82 deletions includes/class-admin-welcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function __construct() {
* Register the Dashboard Pages which are later hidden but these pages
* are used to render the Welcome pages.
*
* @group Beta
* @access public
* @since 1.0
* @return void
Expand All @@ -54,23 +53,13 @@ public function admin_menus() {
// Add help page to GravityView menu
add_submenu_page(
'edit.php?post_type=gravityview',
__('GravityView Beta: Getting Started', 'gravity-view'),
__('GravityView: Getting Started', 'gravity-view'),
__('Getting Started', 'gravity-view'),
$this->minimum_capability,
'gv-getting-started',
array( $this, 'getting_started_screen' )
);

// About Page
add_submenu_page(
'edit.php?post_type=gravityview',
__( 'Welcome to GravityView', 'gravity-view' ),
__( 'Welcome to GravityView', 'gravity-view' ),
$this->minimum_capability,
'gv-beta-testing',
array( $this, 'beta_testing_screen' )
);

// Credits Page
add_submenu_page(
'edit.php?post_type=gravityview',
Expand All @@ -93,7 +82,7 @@ public function is_dashboard_page($is_page = false, $hook = NULL) {

if($is_page) { return $is_page; }

return in_array($plugin_page, array('gv-about', 'gv-beta-testing', 'gv-credits', 'gv-getting-started'));
return in_array( $plugin_page, array( 'gv-about', 'gv-credits', 'gv-getting-started' ) );
}

/**
Expand All @@ -106,7 +95,6 @@ public function is_dashboard_page($is_page = false, $hook = NULL) {
public function admin_head() {
global $plugin_page;

remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-beta-testing' );
remove_submenu_page( 'edit.php?post_type=gravityview', 'gv-credits' );

if( !$this->is_dashboard_page() ) { return; }
Expand Down Expand Up @@ -152,9 +140,6 @@ public function tabs() {
<a class="nav-tab <?php echo $selected == 'gv-getting-started' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-getting-started', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>">
<?php _e( "Getting Started", 'gravity-view' ); ?>
</a>
<a class="nav-tab <?php echo $selected == 'gv-beta-testing' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-beta-testing', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>">
<?php _e( 'Beta Testing', 'gravity-view' ); ?>
</a>
<a class="nav-tab <?php echo $selected == 'gv-credits' ? 'nav-tab-active' : ''; ?>" href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'gv-credits', 'post_type' => 'gravityview'), 'edit.php' ) ) ); ?>">
<?php _e( 'Credits', 'gravity-view' ); ?>
</a>
Expand All @@ -165,7 +150,6 @@ public function tabs() {
/**
* Render About Screen
*
* @group Beta
* @access public
* @since 1.0
* @return void
Expand Down Expand Up @@ -344,69 +328,11 @@ public function credits_screen() { ?>
<?php
}

/**
* Render Getting Started Screen
*
* @todo Add a tab!
* @access public
* @since 1.0
* @return void
*/
public function beta_testing_screen() {
list( $display_version ) = explode( '-', GravityView_Plugin::version );
?>
<div class="wrap about-wrap">

<?php $this->tabs(); ?>

<div class="feature-section col two-col">

<h3>Thank you for taking part in the GravityView beta</h3>

<div>
<h2>How to report issues</h2>
<h4 style="font-weight:normal;">If you find a bug, it is most helpful if you <a href="https://gravityview.co/report-an-issue/">submit a report on the website</a>.</h4>
<p><img src="<?php echo plugins_url( 'images/screenshots/report-bug.png', GRAVITYVIEW_FILE ); ?>" class="screenshot" style="max-width:50%;" height="271" width="231" alt="Reporting bugs" />If you find an issue, you can <a href="https://gravityview.co/report-an-issue/">report it on the website</a>, or at the bottom of every GravityView page is a report widget (pictured).</p>
<p>Click the "question mark" button and be as <strong>descriptive as possible</strong>.</p>
<p><strong>Check the "Include a screenshot..." checkbox</strong> - this will help us fix your issue.</p>

<h4>Request Github access</h4>

<p>If you want to contribute to the code, you can <a href="mailto:[email protected]?subject=Github%20Access">request access to the Github repository</a>.</p>
</div>

<div class="last-feature">
<h2 class="clear">Thank you for your help.</h2>

<h4 style="font-weight:normal;" class="clear">By helping discover bugs, suggest enhancements, and provide feedback:</h4>

<ul>
<li><strong>50% off a GravityView license</strong> - everyone with Beta access will receive a discount</li>
<li><strong>The top 10 promoters of GravityView during the private Beta will receive a free license.</strong></li>
<li>You&rsquo;ll get a free license if you <strong>report an issue or contribute to the code</strong></li>
<li><strong>If you contribute to the code</strong>, you&rsquo;ll receive a thank-you on the plugin&rsquo;s "Credits" page</li>
</ul>
</div>
</div>

<hr class="clear" />

<div class="feature-section">
<h2>Feature Requests</h2>

<p>You can share your ideas for feature requests on the <a href="http://gravityview.uservoice.com/forums/238941-gravity-forms-directory">Ideas Forum</a>.</p>
</div>

</div>
<?php
}


/**
* Sends user to the Welcome page on first activation of GravityView as well as each
* time GravityView is upgraded to a new version
*
* @group Beta
* @access public
* @since 1.0
* @return void
Expand All @@ -428,12 +354,12 @@ public function welcome() {

$upgrade = get_option( 'gv_version_upgraded_from' );

// After Beta
if( ! $upgrade ) { // First time install
wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-beta-testing' ) ); exit;
} else { // Update
wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit;
}
// // After Beta
// if( ! $upgrade ) { // First time install
// wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-beta-testing' ) ); exit;
// } else { // Update
wp_safe_redirect( admin_url( 'edit.php?post_type=gravityview&page=gv-getting-started' ) ); exit;
// }
}
}
new GravityView_Welcome;
17 changes: 16 additions & 1 deletion includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function __construct() {
add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ) );
add_filter( 'bulk_post_updated_messages', array( $this, 'post_updated_messages' ) );

add_filter( 'plugin_action_links_'. plugin_basename( __FILE__) , array( $this, 'plugin_action_links' ) );
add_filter( 'plugin_action_links_'. plugin_basename( GRAVITYVIEW_FILE ) , array( $this, 'plugin_action_links' ) );

add_action( 'plugins_loaded', array( $this, 'backend_actions' ) );

Expand Down Expand Up @@ -56,6 +56,7 @@ public function backend_actions() {
include_once( GRAVITYVIEW_DIR .'includes/fields/entry-link.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/created-by.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/date.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/website.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/time.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/entry-date.php' );
include_once( GRAVITYVIEW_DIR .'includes/fields/fileupload.php' );
Expand All @@ -69,6 +70,20 @@ public function backend_actions() {
do_action('gravityview_include_backend_actions');
}

/**
* Modify plugin action links at plugins screen
*
* @access public
* @static
* @param mixed $links
* @return void
*/
public static function plugin_action_links( $links ) {
$support_link = 'https://katzwebservices.zendesk.com/hc/en-us/categories/200136096';
$action = array( '<a href="' . $support_link . '">'. esc_html__( 'Support', 'gravity-view' ) .'</a>' );
return array_merge( $action, $links );
}

/**
* Filter Admin messages
*
Expand Down
56 changes: 51 additions & 5 deletions includes/class-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ public static function replace_variables($text, $form, $entry ) {
return $text;
}

// Check for fields
preg_match_all('/{[^{]*?:(\d+(\.\d+)?)(:(.*?))?}/mi', $text, $matches, PREG_SET_ORDER);

if( empty( $matches ) ) {
return $text;

// Check for form variables
if( !preg_match( '/{(pricing_fields|form_title|entry_url|post_id|admin_email|post_edit_url|form_id|entry_id)}/ism', $text ) ) {
return $text;
}
}

return GFCommon::replace_variables( $text, $form, $entry, false, false, false, "html");
Expand Down Expand Up @@ -138,10 +142,12 @@ public static function field_value( $entry, $field_settings, $format = 'html') {
$output = '';

$form = $gravityview_view->form;

$field = gravityview_get_field( $form, $field_id );

$field_type = RGFormsModel::get_input_type($field);

if( $field_type = RGFormsModel::get_input_type($field) ) {
if( $field_type ) {
$field_type = $field['type'];
$value = RGFormsModel::get_lead_field_value($entry, $field);
} else {
Expand Down Expand Up @@ -261,7 +267,7 @@ public static function entry_link( $entry, $field ) {

if( defined('DOING_AJAX') && DOING_AJAX ) {
global $gravityview_view;
$post_id = $gravityview_view->post_id;
$post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : '';
} else {
global $post;
$post_id = isset( $post->ID ) ? $post->ID : null;
Expand Down Expand Up @@ -469,13 +475,53 @@ function gravityview_get_the_term_list( $post_id, $link = true, $taxonomy = 'pos

}

if( !function_exists( 'gravityview_format_link' ) ) {

/**
* Convert a whole link into a shorter link for display
* @param [type] $value [description]
* @return [type] [description]
*/
function gravityview_format_link($value = null) {

if(apply_filters('gravityview_anchor_text_striphttp', true)) {
$value = str_replace('http://', '', $value);
$value = str_replace('https://', '', $value);
}

if(apply_filters('gravityview_anchor_text_stripwww', true)) {
$value = str_replace('www.', '', $value);
}
if(apply_filters('gravityview_anchor_text_rootonly', true)) {
$value = preg_replace('/(.*?)\/(.+)/ism', '$1', $value);
}
if(apply_filters('gravityview_anchor_text_nosubdomain', true)) {
$value = preg_replace('/((.*?)\.)+(.*?)\.(.*?)/ism', '$3.$4', $value);
}
if(apply_filters('gravityview_anchor_text_noquerystring', true)) {
$ary = explode("?", $value);
$value = $ary[0];
}
return $value;
}

}


function gravityview_get_current_views() {
return GravityView_frontend::getInstance()->gv_output_data->get_views();
}

function gravityview_get_current_view_data( $view_id ) {
return GravityView_frontend::getInstance()->gv_output_data->get_view( $view_id );
}

// Templates' hooks
function gravityview_before() {
do_action( 'gravityview_before', gravityview_get_view_id() );
}

function gravityview_header() {

do_action( 'gravityview_header', gravityview_get_view_id() );
}

Expand Down
Loading

0 comments on commit 9bf6183

Please sign in to comment.