Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dtformat widget fixed #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
3 changes: 2 additions & 1 deletion classes/client.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public static function shortcode( $atts, $content = null ) {
'font_color' => '#000000',
'inverse_header' => '',
'inverse_body' => '',
'language' => 'en'
'language' => 'en',
'dtformat' => 'eu',
), $atts ) );

// Check if the required param is set
Expand Down
6 changes: 4 additions & 2 deletions classes/widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function widget( $args, $instance ) {
$inverse_body = empty( $instance['inverse_body'] ) ? 'false' : esc_attr( $instance['inverse_body'] );
$default_view = empty( $instance['default_view'] ) ? 'list' : esc_attr( $instance['default_view'] );
$language = empty( $instance['language'] ) ? 'en' : esc_attr( $instance['language'] );
$dtformat = empty( $instance['dtformat'] ) ? 'eu' : esc_attr( $instance['dtformat'] );


echo $before_widget;
Expand All @@ -47,7 +48,7 @@ public function widget( $args, $instance ) {
echo $before_title . esc_attr( $title ) . $after_title;
}

echo do_shortcode( '[hoppening user_id="' . $user_id . '" widget_type="' . $widget_type . '" width="' . $width . '" height="'. $height . '" bgcolor="' . esc_attr( $bg_color ) . '" font_color="' . esc_attr( $font_color ) . '" default_view="' . esc_attr( $default_view ) . '" inverse_header="' . esc_attr( $inverse_header ) . '" inverse_body="' . esc_attr( $inverse_body ) . '" language="' . $language .'"]' );
echo do_shortcode( '[hoppening user_id="' . $user_id . '" widget_type="' . $widget_type . '" width="' . $width . '" height="'. $height . '" bgcolor="' . esc_attr( $bg_color ) . '" font_color="' . esc_attr( $font_color ) . '" default_view="' . esc_attr( $default_view ) . '" inverse_header="' . esc_attr( $inverse_header ) . '" inverse_body="' . esc_attr( $inverse_body ) . '" language="' . $language .'"'.'" dtformat="' . $dtformat .'"'.']' );

echo $after_widget;
}
Expand All @@ -59,7 +60,7 @@ public function widget( $args, $instance ) {
*/
public function form( $instance ) {
//Defaults
$instance = wp_parse_args( (array) $instance, array( 'title' => false, 'widget_type' => 'artist', 'user_id' => false, 'width' => 250, 'height' => 300, 'bg_color' => '#ffffff', 'font_color' => '#000000', 'inverse_header' => false, 'inverse_body' => false, 'default_view' => 'list', 'language' => 'en' ));
$instance = wp_parse_args( (array) $instance, array( 'title' => false, 'widget_type' => 'artist', 'user_id' => false, 'width' => 250, 'height' => 300, 'bg_color' => '#ffffff', 'font_color' => '#000000', 'inverse_header' => false, 'inverse_body' => false, 'default_view' => 'list', 'language' => 'en', 'dtformat' => 'eu' ));
$title = esc_attr( $instance['title'] );

$tpl = Hoppening_Client::get_template( 'admin/widget' );
Expand Down Expand Up @@ -91,6 +92,7 @@ public function update( $new_instance, $old_instance ) {
$instance['inverse_body'] = strip_tags( $new_instance['inverse_body'] );

$instance['language'] = strip_tags( $new_instance['language'] );
$instance['dtformat'] = strip_tags( $new_instance['dtformat'] );

return $instance;
}
Expand Down
15 changes: 15 additions & 0 deletions views/admin/popin.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@
<option value="yo">Yoruba</option>
<option value="za">Zhuang, Chuang</option>
</select>

</td>
<tr valign="top" class="field" id="hoppening_dtformat">
<th class="label" scope="row"><label for="hoppening_dtformat"><span class="alignleft"><?php _e('Date Time Format', 'hoppening'); ?></span></label></th>
<td>
<select id="hoppening_dtformat" name="hoppening_dtformat">
<option value="eu">24 hours</option>
<option value="us">12 hours</option>
</select>

</td>
</tr>

Expand All @@ -269,3 +279,8 @@
</div>

</form>
<style type="text/css">
#TB_ajaxContent {
height: 440px !important;
}
</style>
9 changes: 9 additions & 0 deletions views/admin/widget.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,18 @@
<option value="za">Zhuang, Chuang</option>
</select>

<p>
<label for="<?php echo $this->get_field_id('dtformat'); ?>"><?php _e( 'Date Time Format' , 'hoppening'); ?></label>
</p>
<select style=" margin-bottom: 10px;" id="<?php echo $this->get_field_id('dtformat'); ?>" name="<?php echo $this->get_field_name('dtformat'); ?>" class="widefat">
<option value="eu">24 hours</option>
<option value="us">12 hours</option>
</select>
<br>
<script type="text/javascript">
jQuery(document).ready(function(){
document.getElementById("<?php echo $this->get_field_id('language'); ?>").value = "<?php echo $instance['language']; ?>"
document.getElementById("<?php echo $this->get_field_id('dtformat'); ?>").value = "<?php echo $instance['dtformat']; ?>"
document.getElementById("<?php echo $this->get_field_id('widget_type'); ?>").value = "<?php echo $instance['widget_type']; ?>"
jQuery("#<?php echo $this->get_field_id('widget_type'); ?>").on("change", function() {
if (jQuery(this).val() == "artist") {
Expand Down
2 changes: 1 addition & 1 deletion views/shortcode.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
var conf_wwidth = '<?php echo $width; ?>';
var inverse_header = '<?php echo $inverse_header; ?>';
var language = '<?php echo $language; ?>';
var params={'headerDark': '<?php echo ($inverse_header == 'true') ? 'true' : 'false' ?>','bodyDark':'<?php echo ($inverse_body == 'true') ? 'true' : 'false' ?>','actionColor':'<?php echo $font_color; ?>','backColor':'<?php echo $bg_color; ?>','locale':'<?php echo $language; ?>', 'v': '2'}
var params={'headerDark': '<?php echo ($inverse_header == 'true') ? 'true' : 'false' ?>','bodyDark':'<?php echo ($inverse_body == 'true') ? 'true' : 'false' ?>','actionColor':'<?php echo $font_color; ?>','backColor':'<?php echo $bg_color; ?>','locale':'<?php echo $language; ?>','dtformat':'<?php echo $dtformat; ?>', 'v': '2'}
var widgets = Hoppening.widget.init('<?php echo $widget_id;?>','<?php echo $widget_type; ?>','<?php echo $user_id ?>','https://w.gigtime.co/#/');
var default_view = '<?php echo ($default_view === "map") ? "map" : "list" ?>';
widgets.show(default_view,(conf_wwidth === "") ? '100%' : conf_wwidth, conf_wheight,params);
Expand Down