Пример #1
0
 /**
  * Save the order language with every checkout
  *
  * @param integer $order the order object
  */
 public function saveOrderLanguage($order)
 {
     $current = pll_current_language();
     if ($current) {
         pll_set_post_language($order, $current);
     }
 }
 /**
  * @inheritDoc
  */
 protected function createPostFromEntry(EntryInterface $entry)
 {
     $postId = parent::createPostFromEntry($entry);
     if (is_int($postId) && $this->language && function_exists('pll_set_post_language')) {
         pll_set_post_language($postId, $this->language);
     }
     return $postId;
 }
Пример #3
0
 public function saveLanguagesPost($languageSlug)
 {
     $newPostArgs = apply_filters('bp_trapp_save_language_post_args', ['post_title' => $this->post->post_title, 'post_content' => $this->post->post_content, 'post_type' => $this->post->post_type], $this->post, $languageSlug);
     $langPostId = wp_insert_post($newPostArgs);
     pll_set_post_language($langPostId, $languageSlug);
     $this->saveImages($langPostId, $languageSlug);
     $this->saveTerms($langPostId, $languageSlug);
     return $langPostId;
 }
Пример #4
0
 public static function add_page($title, $slug, $template, $language)
 {
     $page_exists = get_page_by_title($title);
     if ($page_exists) {
         return;
     }
     $page = array('post_title' => $title, 'post_name' => $slug, 'post_content' => '', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'page_template' => $template, 'lang' => $language);
     $post_id = wp_insert_post($page);
     if (function_exists('pll_set_post_language')) {
         pll_set_post_language($post_id, $language);
     }
     return $post_id;
 }
 /**
  * Short Description. (use period)
  *
  * Long Description.
  *
  * @since    1.0.0
  */
 public static function activate()
 {
     global $polylang;
     $page = get_page_by_title('Enquire Now');
     if (!$page) {
         if (isset($polylang)) {
             // START ENQUIRE PAGE SETUP
             $pagetranslations = array();
             $languages = $polylang->model->get_languages_list();
             foreach ($languages as $language) {
                 $slug = $language->slug;
                 //error_log($slug);
                 switch ($slug) {
                     /*case 'en':
                           $args = array(
                             'post_title'      => 'Enquire Now',
                             'post_content'    => '[enquireform]',
                             'post_status'     => 'publish',
                             'post_author'     => 1,
                             'post_type'       => 'page'
                           );
                       break;*/
                     case 'de':
                         $args = array('post_title' => 'Anfrage', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'fr':
                         $args = array('post_title' => 'Renseignez Vous', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'es':
                         $args = array('post_title' => 'Solicite Informacion', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'pt':
                         $args = array('post_title' => 'Consultar', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     default:
                         $args = array('post_title' => 'Enquire Now', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                 }
                 $page = get_page_by_title($args['post_title']);
                 if (!$page) {
                     $pid = wp_insert_post($args);
                     pll_set_post_language($pid, $slug);
                     if ($pid && !is_wp_error($pid)) {
                         //update_post_meta( $pid, '_wp_page_template', 'page-templates/enquire-template.php' );
                     }
                     $pagetranslations[$slug] = $pid;
                 } else {
                     $pid = $page->ID;
                     //update_post_meta( $pid, '_wp_page_template', 'page-templates/enquire-template.php' );
                     $pagetranslations[$slug] = $pid;
                 }
             }
             pll_save_post_translations($pagetranslations);
             // END ENQUIRE PAGE SETUP
             // START THANK YOU PAGE SETUP
             $pagetranslations = array();
             $languages = $polylang->model->get_languages_list();
             foreach ($languages as $language) {
                 $slug = $language->slug;
                 //error_log($slug);
                 switch ($slug) {
                     /*case 'en':
                           $targs = array(
                             'post_title'      => 'Thank You',
                             'post_content'    => 'thank you html markup here... best practice is to use a shortcode.',
                             'post_status'     => 'publish',
                             'post_author'     => 1,
                             'post_type'       => 'page'
                           );
                       break;*/
                     case 'de':
                         $targs = array('post_title' => 'Vielen Dank', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'fr':
                         $targs = array('post_title' => 'Merci', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'es':
                         $targs = array('post_title' => 'Gracias', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     case 'pt':
                         $targs = array('post_title' => 'Obrigado', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                         break;
                     default:
                         $targs = array('post_title' => 'Thank You', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
                 }
                 $page = get_page_by_title($targs['post_title']);
                 if (!$page) {
                     $pid = wp_insert_post($targs);
                     pll_set_post_language($pid, $slug);
                     if ($pid && !is_wp_error($pid)) {
                         //update_post_meta( $pid, '_wp_page_template', 'page-templates/thankyou-template.php' );
                     }
                     $pagetranslations[$slug] = $pid;
                 } else {
                     $pid = $page->ID;
                     //update_post_meta( $pid, '_wp_page_template', 'page-templates/thankyou-template.php' );
                     $pagetranslations[$slug] = $pid;
                 }
             }
             pll_save_post_translations($pagetranslations);
             // END THANK YOU PAGE SETUP
         } else {
             // Create post object
             $args = array('post_title' => 'Enquire Now', 'post_content' => '[enquireform]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
             $pid = wp_insert_post($args);
             if ($pid && !is_wp_error($pid)) {
                 //update_post_meta( $pid, '_wp_page_template', 'page-templates/enquire-template.php' );
             }
             // Create post object
             $args = array('post_title' => 'Thank You', 'post_content' => 'thank you html markup here... best practice is to use a shortcode.', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page');
             $pid = wp_insert_post($args);
             if ($pid && !is_wp_error($pid)) {
                 //update_post_meta( $pid, '_wp_page_template', 'page-templates/thankyou-template.php' );
             }
         }
     }
 }
Пример #6
0
    $postid = wp_insert_post($newpost);
    $url = 'https://cfp.openfest.org/uploads/speaker_profile/picture/' . $row->id . '/schedule_' . $row->picture;
    echo $url . "\n";
    $att = media_sideload_image($url, $postid, "photo_spk_bg_" . $row->user_id);
    preg_match("%src='(http://[^']*)'%", $att, $matches);
    $wpurl = $matches[1];
    $attid = pn_get_attachment_id_from_url($wpurl);
    add_post_meta($postid, '_thumbnail_id', $attid);
    pll_set_post_language($postid, 'bg');
    $postid_en = wp_insert_post($newpost);
    $url = 'https://cfp.openfest.org/uploads/speaker_profile/picture/' . $row->id . '/schedule_' . $row->picture;
    echo $url . "\n";
    $att = media_sideload_image($url, $postid_en, "photo_spk_en_" . $row->user_id);
    preg_match("%src='(http://[^']*)'%", $att, $matches);
    $wpurl = $matches[1];
    $attid = pn_get_attachment_id_from_url($wpurl);
    add_post_meta($postid_en, '_thumbnail_id', $attid);
    pll_set_post_language($postid_en, 'en');
    foreach (array($postid, $postid_en) as $v) {
        if (strlen($row->github) > 1) {
            add_post_meta($v, 'github', $row->github);
        }
        if (strlen($row->twitter) > 1) {
            add_post_meta($v, 'twitter', $row->twitter);
        }
        if (strlen($row->public_email) > 1) {
            add_post_meta($v, 'public_email', $row->public_email);
        }
    }
    pll_save_post_translations(array($postid => 'bg', $postid_en => '$en'));
}
 public function save_payment_language($payment, $payment_data)
 {
     pll_set_post_language($payment, pll_current_language());
 }