/** Display widget */
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     $title = apply_filters('widget_title', $instance['title']);
     if (!$instance['campaign_id']) {
         $query = new WP_Query(array('post_type' => Leyka_Campaign_Management::$post_type, 'posts_per_page' => 1));
         if (!$query->have_posts()) {
             return;
         }
         $campaign_id = $query->posts[0]->ID;
     } elseif ((int) $instance['campaign_id'] === 0) {
         $campaign_id = null;
     } else {
         $campaign_id = (int) $instance['campaign_id'];
     }
     $args = array('show_title' => !!$instance['show_title'], 'show_thumb' => !!$instance['show_thumb'], 'show_excerpt' => !!$instance['show_excerpt'], 'show_scale' => !!$instance['show_scale'], 'show_button' => !!$instance['show_button']);
     $css_id = 'leyka_campaign_card_widget-' . uniqid();
     $html = leyka_get_campaign_card($campaign_id, $args);
     if (!$html) {
         return;
     }
     $campaign = new Leyka_Campaign($campaign_id);
     if (!leyka_form_is_screening(false)) {
         // Don't increase campaign views counter if we're on a page with this campaign's donation form
         $campaign->increase_views_counter();
     }
     /** @var $before_widget */
     echo $before_widget;
     if ($title) {
         /**
          * @var $before_title
          * @var $after_title
          */
         echo $before_title . $title . $after_title;
     }
     echo '<div id="' . esc_attr($css_id) . '">' . $html . "</div>";
     /** @var $after_widget */
     echo $after_widget;
 }
function leyka_enqueue_scripts_cp()
{
    if (Leyka_CP_Card::get_instance()->active && leyka_form_is_screening()) {
        wp_enqueue_script('leyka-cp-widget', 'https://widget.cloudpayments.ru/bundles/cloudpayments');
        wp_enqueue_script('leyka-cp', LEYKA_PLUGIN_BASE_URL . 'gateways/' . Leyka_CP_Gateway::get_instance()->id . '/js/leyka.cp.js', array('jquery', 'leyka-cp-widget', 'leyka-public'), LEYKA_VERSION, true);
    }
}
 /** Register and enqueues public-facing JavaScript files. */
 public function enqueue_scripts()
 {
     if (!leyka_form_is_screening()) {
         return;
     }
     wp_enqueue_script($this->_plugin_slug . '-modal', LEYKA_PLUGIN_BASE_URL . 'js/jquery.leanModal.min.js', array('jquery'), LEYKA_VERSION, true);
     wp_enqueue_script($this->_plugin_slug . '-public', LEYKA_PLUGIN_BASE_URL . 'js/public.js', array('jquery', $this->_plugin_slug . '-modal'), LEYKA_VERSION, true);
     $js_data = apply_filters('leyka_js_localized_strings', array('ajaxurl' => admin_url('admin-ajax.php'), 'correct_donation_amount_required' => __('Donation amount must be specified to submit the form', 'leyka'), 'donation_amount_too_great' => __('Donation amount you entered is too great (maximum %s allowed)', 'leyka'), 'donation_amount_too_small' => __('Donation amount you entered is too small (minimum %s allowed)', 'leyka'), 'checkbox_check_required' => __('This checkbox must be checked to submit the form', 'leyka'), 'amount_incorrect' => __('The amount must be filled with non-zero, non-negative number', 'leyka'), 'text_required' => __('This field must be filled to submit the form', 'leyka'), 'email_required' => __('Email must be filled to submit the form', 'leyka'), 'email_invalid' => __('You have entered an invalid email', 'leyka')));
     wp_localize_script($this->_plugin_slug . '-public', 'leyka', $js_data);
     do_action('leyka_enqueue_scripts');
     // Allow the gateways to add their own scripts
 }