Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Register and load the widget
- add_action( 'widgets_init', 'wpb_load_widget' );
- function wpb_load_widget() {
- register_widget( 'featured_product_widget' );
- }
- // Creating the widget
- class featured_product_widget extends WP_Widget {
- function __construct() {
- parent::__construct(
- // Base ID of your widget
- 'featured_product_widget',
- // Widget name will appear in UI
- __('Uitgelichte product', 'mediasoep'),
- // Widget description
- array( 'description' => __( 'Kies hier een product die je wilt tonen.', 'mediasoep' ), )
- );
- }
- /**
- * Outputs the content of the widget
- *
- * @param array $args
- * @param array $instance
- */
- public function widget( $args, $instance ) {
- // Outputs the content of the widget
- if ( ! isset( $args['widget_id'] ) ) {
- $args['widget_id'] = $this->id;
- }
- // Widget ID with prefix for use in ACF API functions
- $widget_id = 'widget_' . $args['widget_id'];
- $product = get_field( 'product', $widget_id );
- echo $args['before_widget'];
- echo '<pre>';
- echo var_dump( $product );
- echo '</pre>';
- echo $args['after_widget'];
- }
- /**
- * Outputs the options form on admin
- *
- * @param array $instance The widget options
- */
- public function form( $instance ) {
- // Outputs the options form on admin
- }
- /**
- * Processing widget options on save
- *
- * @param array $new_instance The new options
- * @param array $old_instance The previous options
- *
- * @return array
- */
- public function update( $new_instance, $old_instance ) {
- // Processes widget options to be saved
- }
- } // Class featured_product_widget ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement