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

Commit

Permalink
Merge pull request #612 from sakatam/footer-settings
Browse files Browse the repository at this point in the history
Add an option to set a footer
  • Loading branch information
diegoquinteiro authored Feb 15, 2017
2 parents f610378 + 3d3a4b4 commit bfe3f7b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
36 changes: 26 additions & 10 deletions class-instant-articles-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -678,16 +678,7 @@ public function to_instant_article() {
->addMetaProperty( 'op:generator:application', 'facebook-instant-articles-wp' )
->addMetaProperty( 'op:generator:application:version', IA_PLUGIN_VERSION );

$settings_style = Instant_Articles_Option_Styles::get_option_decoded();
if ( isset( $settings_style['article_style'] ) && ! empty( $settings_style['article_style'] ) ) {
$this->instant_article->withStyle( $settings_style['article_style'] );
} else {
$this->instant_article->withStyle( 'default' );
}

if ( isset( $settings_style['rtl_enabled'] ) ) {
$this->instant_article->enableRTL();
}
$this->set_appearance_from_settings();

$transformer->transformString( $this->instant_article, $this->get_the_content(), get_option( 'blog_charset' ) );

Expand Down Expand Up @@ -863,6 +854,31 @@ public function add_analytics_from_settings() {
}
}

/**
* Apply appearance settings for an InstantArticle.
*
* @since 3.3
*/
public function set_appearance_from_settings() {
$settings = Instant_Articles_Option_Styles::get_option_decoded();

if ( isset( $settings['article_style'] ) && ! empty( $settings['article_style'] ) ) {
$this->instant_article->withStyle( $settings['article_style'] );
} else {
$this->instant_article->withStyle( 'default' );
}

if ( isset( $settings['copyright'] ) && ! empty( $settings['copyright'] ) ) {
$this->instant_article->withFooter(
Footer::create()->withCopyright( $settings['copyright'] )
);
}

if ( isset( $settings['rtl_enabled'] ) ) {
$this->instant_article->enableRTL();
}
}

/**
* Article <head> style.
*
Expand Down
10 changes: 8 additions & 2 deletions wizard/class-instant-articles-option-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@ class Instant_Articles_Option_Styles extends Instant_Articles_Option {
const OPTION_KEY = 'instant-articles-option-styles';

public static $sections = array(
'title' => 'Styles',
'description' => '<p>Assign your Instant Articles a custom style. To begin, customize a template using the Style Editor. Next, input the name of the style below.</p><p><strong>Note:</strong> If this field is left blank, the plugin will enable the “Default” style. Learn more about Instant Articles style options in the <a href="https://developers.facebook.com/docs/instant-articles/guides/design" target="_blank">Design Guide</a>.</p>',
'title' => 'Appearance',
);

public static $fields = array(

'article_style' => array(
'label' => 'Article Style',
'default' => 'default',
'description' => '<p>Assign your Instant Articles a custom style. To begin, customize a template using the Style Editor. Next, input the name of the style below.</p><p><strong>Note:</strong> If this field is left blank, the plugin will enable the “Default” style. Learn more about Instant Articles style options in the <a href="https://developers.facebook.com/docs/instant-articles/guides/design" target="_blank">Design Guide</a>.</p>',
),

'copyright' => array(
'label' => 'Copyright',
'default' => '',
'description' => 'The copyright details for your articles. Note: No markup tags can be used in this field. <a href="https://developers.facebook.com/docs/instant-articles/reference/footer" target="_blank">Learn more about Footer in Instant Articles</a>.',
),

'rtl_enabled' => array(
Expand Down

0 comments on commit bfe3f7b

Please sign in to comment.