Skip to content

Commit

Permalink
Merge pull request #18 from superwebshare/option-to-change-fallback-p…
Browse files Browse the repository at this point in the history
…opup-title

Option to change the title of fallback pop-up's settings renderer
  • Loading branch information
josevarghese authored Nov 30, 2022
2 parents 736146d + 3b2ff98 commit 7ddfbc1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
10 changes: 10 additions & 0 deletions admin/class-super-web-share-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,15 @@ function superwebshare_register_settings_fallback(){
'superwebshare_fallback_settings_section', // Page slug
'superwebshare_fallback_settings_section' // Settings Section ID
);

// Option to change the fallback popup title - Since 2.4
add_settings_field(
'superwebshare_fallback_title', // ID
__('Show fallback title', 'super-web-share'), // Title
'superwebshare_fallback_title_cb', // CB
'superwebshare_fallback_settings_section', // Page slug
'superwebshare_fallback_settings_section' // Settings Section ID
);

//Since 2.1 for fallback modal color
add_settings_field(
Expand Down Expand Up @@ -835,6 +844,7 @@ function superwebshare_settings_default( $name ){
),
"fallback" => array(
'superwebshare_fallback_enable' => 'enable', // default value - 2.0
'fallback_title' => 'Share', // default value - Share for the popup title
'fallback_modal_background' => '#BD3854', // default color for fallback modal - 2.1
'fallback_layout' => '1', // fallback layout color - 2.1
'fallback_twitter_via' => '', // default value none
Expand Down
13 changes: 13 additions & 0 deletions admin/partials/super-web-share-admin-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ function superwebshare_fallback_enable_cb() {
superwebshare_input_toggle( 'superwebshare_fallback_settings[superwebshare_fallback_enable]', 'enable', $saved );
}

/**
* Option to change the title of Fallback Pop-up
*
* @since 2.4
*/
function superwebshare_fallback_title_cb() {
$settings_fallback = superwebshare_get_settings_fallback();
$value = isset( $settings_fallback[ 'fallback_title' ] ) ? esc_html( $settings_fallback[ 'fallback_title' ] ) : "Share";
?>
<input type="text" name="superwebshare_fallback_settings[fallback_title]" id="superwebshare_floating_settings[fallback_title]" placeholder="Title Of fallback dialog box" value="<?php echo $value ?>" >
<?php
}

/**
* Fallback background color
*
Expand Down
9 changes: 5 additions & 4 deletions public/class-super-web-share-public.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ function superwebshare_frontend_inline_styles( $content ) {
'layout' => $layout,
'bg' => $bg,
'twitter_via' => $twitter_via,
'text_color' => $settings_fallback['fallback_text_color']

'text_color' => $settings_fallback['fallback_text_color'],
'title' => empty( $settings_fallback[ 'fallback_title' ] ) ? "Share" : $settings_fallback[ 'fallback_title' ],
) );

}
Expand All @@ -304,7 +304,8 @@ function superwebshare_fallback_modal( $args, $echo = true ){
'layout' => 1,
'bg' => '#BD3854',
'twitter_via' => "",
'text_color' => '#fff'
'text_color' => '#fff',
"title" => ''
) );

$args[ 'twitter_via' ] = empty( $args[ 'twitter_via' ] ) ? "" : "&via=" . $args[ 'twitter_via' ];
Expand All @@ -317,7 +318,7 @@ function superwebshare_fallback_modal( $args, $echo = true ){
<div class="sws-modal-bg sws-layout-<?= $args[ 'layout' ] ?>">
<div class="modal-container" style="background-color: <?= $args[ 'bg' ] ?>;color:<?= $args[ 'text_color' ] ?>" >
<div class="modal-title">
<?= _e( 'Share', 'super-web-share' ) ?>
<?= $args[ "title" ] ?>
</div>

<div class="sws-modal-content">
Expand Down

0 comments on commit 7ddfbc1

Please sign in to comment.