/i', get_post_field( 'post_content', get_the_ID() ), $matches ); if ( array_key_exists( 0, $matches[1] ) ) { return $matches[1][0]; } else { return ''; } }; }; // Check if we need the frontend or the backend part. if ( isset( $frontend ) && 1 === $frontend ) { // Service URL. $service_url = esc_url( 'https://www.pinterest.com/pin/create/link/' ); // Get an image for pinterest (attribute -> featured image -> first image -> default image -> shariff hint). if ( array_key_exists( 'services', $atts ) ) { if ( strstr( $atts['services'], 'pinterest' ) ) { if ( array_key_exists( 'media', $atts ) ) { $share_media = esc_html( $atts['media'] ); } else { $feat_image = wp_get_attachment_url( get_post_thumbnail_id() ); if ( ! empty( $feat_image ) ) { $share_media = esc_html( $feat_image ); } else { $first_image = shariff3uu_catch_image(); if ( ! empty( $first_image ) ) { $share_media = esc_html( $first_image ); } else { if ( isset( $shariff3uu['default_pinterest'] ) ) { $share_media = $shariff3uu['default_pinterest']; } else { $share_media = plugins_url( '/images/defaultHint.png', dirname( __FILE__ ) ); } } } } } } // Build button URL. $button_url = $service_url . '?url=' . $share_url . '&media=' . rawurlencode( $share_media ) . '&description=' . $share_title; // Colors. $main_color = '#cb2027'; $secondary_color = '#e70f18'; $wcag_color = '#AE1920'; // SVG icon. $svg_icon = ''; // Backend available? $backend_available = 1; // Button text label. $button_text_array = array( 'de' => 'merken', 'en' => 'save', 'es' => 'ahorrar', 'fr' => 'enregistrer', 'it' => 'salva', ); // Button alt label. $button_title_array = array( 'bg' => 'Сподели в Pinterest', 'cs' => 'Přidat na Pinterest', 'da' => 'Del på Pinterest', 'de' => 'Bei Pinterest pinnen', 'en' => 'Pin it on Pinterest', 'es' => 'Ahorrar en Pinterest', 'fi' => 'Jaa Pinterestissä', 'fr' => 'Partager sur Pinterest', 'hr' => 'Podijelite na Pinterest', 'hu' => 'Megosztás Pinteresten', 'it' => 'Condividi su Pinterest', 'ja' => 'Pinterest上で共有', 'ko' => 'Pinterest에서 공유하기', 'nl' => 'Delen op Pinterest', 'no' => 'Del på Pinterest', 'pl' => 'Udostępnij przez Pinterest', 'pt' => 'Compartilhar no Pinterest', 'ro' => 'Partajează pe Pinterest', 'ru' => 'Поделиться на Pinterest', 'sk' => 'Zdieľať na Pinterest', 'sl' => 'Deli na Pinterest', 'sr' => 'Podeli na Pinterest-u', 'sv' => 'Dela på Pinterest', 'tr' => 'Pinterest\'ta paylaş', 'zh' => '分享至Pinterest', ); } elseif ( isset( $backend ) && 1 === $backend ) { // Fetch counts. $pinterest = sanitize_text_field( wp_remote_retrieve_body( wp_remote_get( 'https://api.pinterest.com/v1/urls/count.json?callback=x&url=' . $post_url ) ) ); $pinterest_json = rtrim( substr( $pinterest, 2 ), ')' ); $pinterest_json = json_decode( $pinterest_json, true ); // Store results, if we have some and record errors, if enabled (e.g. request from the status tab). if ( isset( $pinterest_json['count'] ) ) { $share_counts['pinterest'] = intval( $pinterest_json['count'] ); } elseif ( isset( $record_errors ) && 1 === $record_errors ) { $service_errors['pinterest'] = $pinterest; } }