Skip to content

Commit

Permalink
Merge pull request #24 from godaddy/help-tab
Browse files Browse the repository at this point in the history
Setup help tab on settings page
  • Loading branch information
frankiejarrett committed Jan 30, 2017
2 parents d101916 + 2819d8f commit 3049a81
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 13 deletions.
Empty file removed .david-dev
Empty file.
11 changes: 2 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,19 @@ language:
php:
- 5.2
- 5.6
- 7.0
- 7.1

env:
- WP_VERSION=3.8 WP_MULTISITE=0
- WP_VERSION=3.8 WP_MULTISITE=1
- WP_VERSION=latest WP_MULTISITE=0
- WP_VERSION=latest WP_MULTISITE=1
- WP_VERSION=trunk WP_MULTISITE=0
- WP_VERSION=trunk WP_MULTISITE=1

matrix:
exclude:
- php: 5.6
env: WP_VERSION=3.8 WP_MULTISITE=0
- php: 5.6
env: WP_VERSION=3.8 WP_MULTISITE=1
- php: 7.0
- php: 7.1
env: WP_VERSION=3.8 WP_MULTISITE=0
- php: 7.0
env: WP_VERSION=3.8 WP_MULTISITE=1

install:
- export DEV_LIB_PATH=dev-lib
Expand Down
9 changes: 9 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,19 @@ div.updated.gem-identity p:first-child {
vertical-align: top;
}

#help iframe {
width: 100%;
min-height: 800px;
margin-top: 20px;
}

@media screen and (min-width: 783px) {
#settings .form-table th {
width: 30%;
}
#help iframe {
margin-top: 10px;
}
}

#setting-errors {
Expand Down
2 changes: 1 addition & 1 deletion css/admin.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion godaddy-email-marketing.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private function requirements() {
* Load translations.
*/
public function i18n() {
load_plugin_textdomain( 'godaddy-email-marketing', false, dirname( self::$basename ) . '/languages' );
load_plugin_textdomain( 'godaddy-email-marketing', false, basename( dirname( self::$basename ) ) . '/languages' );
}

/**
Expand Down
80 changes: 79 additions & 1 deletion includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,25 @@ public function admin_enqueue_scripts() {
wp_localize_script( 'gem-admin', 'GEMAdmin', array(
'copyFailed' => _x( 'Please press Ctrl/Cmd+C to copy.', 'failed copy response', 'godaddy-email-marketing' ),
) );

wp_enqueue_script(
'gem-iframeresizer',
plugins_url( 'js/iframeResizer.min.js', GEM_PLUGIN_BASE ),
array(),
'3.5.1',
false
);

wp_enqueue_script(
'gem-iframeresizer-ie8',
plugins_url( 'js/js/iframeResizer.ie8.polyfils.min.js', GEM_PLUGIN_BASE ),
array(),
'3.5.1',
false
);

function_exists( 'wp_script_add_data' ) ? wp_script_add_data( 'gem-iframeresizer-ie8', 'conditional', 'lte IE 8' ) : $GLOBALS['wp_styles']->add_data( 'gem-iframeresizer-ie8', 'conditional', 'lte IE 8' );

}

/**
Expand Down Expand Up @@ -288,7 +307,7 @@ public function setup_help_tabs() {
__( '<strong>Widget:</strong> Go to Appearance &rarr; widgets and find the widget called “GoDaddy Email Marketing Form” and drag it into the widget area of your choice. You can then add a title and select a form!', 'godaddy-email-marketing' ),
__( '<strong>Shortcode:</strong> You can add a form to any post or page by adding the shortcode (ex. <code>[gem id=80326]</code>) in the page/post editor.', 'godaddy-email-marketing' ),
sprintf(
__( '<strong>Template Tag:</strong> You can add the following template tag into any WordPress file: <code>%s</code>. Ex. <code>%s</code>', 'godaddy-email-marketing' ),
__( '<strong>Template Tag:</strong> You can add the following template tag into any WordPress file: <code>%1$s</code>. Ex. <code>%2$s</code>', 'godaddy-email-marketing' ),
'&lt;?php gem_form( $form_id ); ?&gt;',
'&lt;?php gem_form( 91 ); ?&gt;'
)
Expand Down Expand Up @@ -443,6 +462,7 @@ public function register_settings() {
* @param int $columns The number of columns in each row.
*/
public function do_settings_sections( $page, $columns = 2 ) {

global $wp_settings_sections, $wp_settings_fields;

// @codeCoverageIgnoreStart
Expand Down Expand Up @@ -487,6 +507,56 @@ public function do_settings_sections( $page, $columns = 2 ) {
}
}

/**
* Generate the help tab content
*
* @since NEXT
*
* @return mixed
*/
public function generate_help_tab_content() {

$language = get_locale();
$parts = explode( '_', $language );
$subdomain = ! empty( $parts[1] ) ? strtolower( $parts[1] ) : strtolower( $language );

// Overrides
switch ( $subdomain ) {

case '' :

$subdomain = 'www'; // Default

break;

case 'uk' :

$subdomain = 'ua'; // Ukrainian (Українська)

break;

case 'el' :

$subdomain = 'gr'; // Greek (Ελληνικά)

break;

}

?>
<iframe src="<?php echo esc_url( "https://{$subdomain}.godaddy.com/help/godaddy-email-marketing-1000013" ) ?>" frameborder="0" scrolling="no"></iframe>

<script type="text/javascript">
iFrameResize( {
bodyBackground: 'transparent',
checkOrigin: false,
heightCalculationMethod: 'taggedElement'
} );
</script>
<?php

}

/**
* Displays the settings page.
*
Expand Down Expand Up @@ -539,6 +609,7 @@ public function display_settings_page() {
<a href="#forms" class="nav-tab <?php echo esc_attr( 'forms' === $tab ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Forms', 'godaddy-email-marketing' ); ?></a>
<?php endif; ?>
<a href="#settings" class="nav-tab <?php echo esc_attr( 'settings' === $tab || empty( $tab ) ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Settings', 'godaddy-email-marketing' ); ?></a>
<a href="#help" class="nav-tab <?php echo esc_attr( 'help' === $tab ? 'nav-tab-active' : '' ); ?>"><?php esc_html_e( 'Help', 'godaddy-email-marketing' ); ?></a>
</h2>

<div id="setting-errors"></div>
Expand Down Expand Up @@ -630,6 +701,13 @@ public function display_settings_page() {
</p>
</div>
</form>

<div id="help" class="panel">

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

<br style="clear:both" />
</div>
</div>
<?php
}
Expand Down
4 changes: 4 additions & 0 deletions js/iframeResizer.ie8.polyfils.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3049a81

Please sign in to comment.