__( 'Add content recomendations to your site.', 'algorithmia_widget_domain' ), ) ); } // Creating widget front-end. public function widget( $args, $instance ) { // We only display on single post pages, not on the homepage, user pages, etc. if ( is_single() == false ) { return false; } $title = apply_filters( 'widget_title', $instance['title'] ); // Before and after widget arguments are defined by themes. echo $args['before_widget']; if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title']; } // This is the Algorithmia API key. $api_key = $instance['api_key']; // We need the site name to prevent the display of the site name in the links that the Algorithmia API returns. // Algorithmia API expects this as the content value in the meta tag. We pass this below. $site_name = get_bloginfo('name', 'raw'); $name_no_spaces = str_replace(' ', '', $site_name); if ( ! empty( $api_key ) ) { echo '
'; echo $args['after_widget']; } } // Widget form. public function form( $instance ) { $api_key = ''; if ( isset( $instance[ 'title' ] ) ) { $title = $instance[ 'title' ]; } else { $title = __( 'widget_title', 'algorithmia_widget_domain' ); } if ( isset($instance['api_key']) ) { $api_key = $instance['api_key']; } // Widget admin form ?>