| @@ -47,10 +47,10 @@ | ||
| 47 | 47 | $widget_num = $tmp_id[1]; |
| 48 | 48 | |
| 49 | 49 | $widget_id = ! empty( $instance['widget_id'] ) ? $instance['widget_id'] : ''; |
| 50 | 50 | |
| 51 | - // use the widget container name as the placement, suffix the widget_num to make it unique | |
| 52 | - $placement=$args["id"]."-".$widget_num; | |
| 51 | + // Prefix each placement with "WP Right Rail". Grab the ID of the container (i.e. the sidebar) and append 'widget_num' to make it unique. | |
| 52 | + $placement = "WP Right Rail (". $args["id"]."-".$widget_num.")"; | |
| 53 | 53 | |
| 54 | 54 | echo $before_widget; |
| 55 | 55 | |
| 56 | 56 | if ( $title ){ |
| @@ -65,22 +65,25 @@ | ||
| 65 | 65 | echo '<div id="'.$container.'"></div>'; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | //widget content |
| 69 | - $script2_content = str_replace('{{WIDGET_ID}}', $widget_id, file_get_contents($this->plugin_directory.'js/script2.js')); | |
| 70 | - $script2_content = str_replace('{{CONTAINER}}', $container, $script2_content); | |
| 71 | - $script2_content = str_replace('{{PLACEMENT}}', $placement, $script2_content); | |
| 72 | - echo '<script type="text/javascript">'.$script2_content.'</script>'; | |
| 69 | + $stringParams = array( | |
| 70 | + "{{WIDGET_ID}}" => $widget_id, | |
| 71 | + "{{CONTAINER}}" => $container, | |
| 72 | + "{{PLACEMENT}}" => $placement | |
| 73 | + ); | |
| 74 | + $widgetInjectionScript_content = str_replace(array_keys($stringParams), array_values($stringParams), file_get_contents($this->plugin_directory.'js/widgetInjectionScript.js')); | |
| 75 | + echo '<script type="text/javascript">'.$widgetInjectionScript_content.'</script>'; | |
| 73 | 76 | |
| 74 | 77 | echo $after_widget; |
| 75 | 78 | } |
| 76 | 79 | |
| 77 | - function form( $instance ) { | |
| 80 | + function form( $instance ) { | |
| 78 | 81 | $instance = wp_parse_args( (array) $instance ); |
| 79 | 82 | $widget_id = esc_attr( $instance['widget_id'] ); |
| 80 | 83 | ?> |
| 81 | 84 | <p> |
| 82 | - <label for="<?php echo $this->get_field_id('widget_id'); ?>"><?php _e('Widget ID:'); ?> | |
| 85 | + <label for="<?php echo $this->get_field_id('widget_id'); ?>"><?php _e('Mode (Widget ID):'); ?> | |
| 83 | 86 | <input class="widefat" id="<?php echo $this->get_field_id('widget_id'); ?>" name="<?php echo $this->get_field_name('widget_id'); ?>" type="text" value="<?php echo esc_attr($widget_id); ?>" /> |
| 84 | 87 | </label> |
| 85 | 88 | </p> |
| 86 | 89 | <?php |