'widget_taboola', 'description' => __( "A taboola widget for your site.") ); parent::__construct( 'taboola', _x( 'Taboola Widget', 'Taboola Widget' ), $widget_ops ); $this->plugin_directory = plugin_dir_path(__FILE__); } function widget( $args, $instance ) { if (trim($instance['widget_id']) == ''){ return; } extract($args); /** This filter is documented in wp-includes/default-widgets.php */ $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $widget_id = ! empty( $instance['widget_id'] ) ? $instance['widget_id'] : ''; $placement = ! empty( $instance['placement'] ) ? $instance['placement'] : ''; echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; //widget content $script2_content = str_replace('{{WIDGET_ID}}', $widget_id, file_get_contents($this->plugin_directory.'js/script2.js')); $script2_content = str_replace('{{CONTAINER}}', $this->id, $script2_content); $script2_content = str_replace('{{PLACEMENT}}', $placement, $script2_content); echo ''; echo $after_widget; } function form( $instance ) { $instance = wp_parse_args( (array) $instance ); $widget_id = esc_attr( $instance['widget_id'] ); $placement = esc_attr( $instance['placement'] ); ?>