/**
  * The function that fix the YIWLink problem
  *
  *
  * @author Andrea Grillo <*****@*****.**>
  * @author Andrea Frascaspata <*****@*****.**>
  * @since 2.0
  **/
 function convert_yit_url(&$item, $key, $type)
 {
     if (yit_string_is_serialized($item)) {
         $item = maybe_unserialize($item);
         $item_type = 'serialized';
     } elseif (yit_string_is_json($item)) {
         $item = json_decode($item, true);
         $item_type = 'json_encoded';
     } else {
         $item_type = 'string';
     }
     switch ($type) {
         case 'in_import':
             $upload_dir = wp_upload_dir();
             $importer_uploads_url = $upload_dir['baseurl'];
             $importer_site_url = site_url();
             if (!is_object($item) && !is_a($item, '__PHP_Incomplete_Class')) {
                 if (is_array($item)) {
                     array_walk_recursive($item, 'convert_yit_url', $type);
                     if ($item_type == 'serialized') {
                         $item = serialize($item);
                     } elseif ($item_type == 'json_encoded') {
                         $item = json_encode($item);
                     }
                 } else {
                     $item = str_replace('%uploadsurl%', $importer_uploads_url, $item);
                     $item = str_replace('%siteurl%', $importer_site_url, $item);
                 }
             }
             break;
         case 'in_export':
             yit_update_db_value('bi-shop', $item, $item_type, $type);
             yit_update_db_value('bishop', $item, $item_type, $type);
             break;
     }
 }
Example #2
0
    function yit_convert_url( &$item, $key, $type ) {

        global $importer_uploads_url, $importer_site_url;

        if ( ! isset( $importer_uploads_url ) ) {
            $uploads = wp_upload_dir();
            $importer_uploads_url = YIT_WPCONTENT_URL;
        }

        if ( ! isset( $importer_site_url ) ) {
            $importer_site_url = YIT_SITE_URL;
        }

        if( yit_string_is_serialized( $item ) ){
            $item = maybe_unserialize( $item );
            $item_type = 'serialized';
        }elseif( yit_string_is_json( $item ) ){
            $item = json_decode( $item, true );
            $item_type = 'json_encoded';
        }else {
            $item_type = 'string';
        }

        switch ( $type ) {

            case 'in_import' :

                if ( ! is_object( $item ) && ! is_a( $item, '__PHP_Incomplete_Class' ) ) {
                    if ( is_array( $item ) ) {
                        array_walk_recursive( $item, "yit_convert_url", $type );
                        if( $item_type == 'serialized' ){
                            $item = serialize( $item );
                        } elseif( $item_type == 'json_encoded' ) {
                            $item = json_encode( $item );
                        }
                    }
                    else {
                        $item = str_replace( '%uploadsurl%', $importer_uploads_url, $item );
                        $item = str_replace( '%siteurl%', $importer_site_url, $item );
                    }
                }

                break;

            case 'in_export' :

                if ( ! is_object( $item ) && ! is_a( $item, '__PHP_Incomplete_Class' ) ) {
                    if ( is_array( $item ) ) {
                        array_walk_recursive( $item, "yit_convert_url", $type );
                        if( $item_type == 'serialized' ){
                            $item = serialize( $item );
                        } elseif( $item_type == 'json_encoded' ) {
                            $item = json_encode( $item );
                        }
                    }
                    else {
                        $parsed_site_url = @parse_url( site_url() );
                        $item = str_replace( $importer_uploads_url, '%uploadsurl%', $item );
                        $item = str_replace( str_replace( $parsed_site_url['scheme'] . '://' . $parsed_site_url['host'], '', $importer_uploads_url ), '%uploadsurl%', $item );
                        $item = str_replace( $importer_site_url, '%siteurl%', $item );
                    }
                }

                break;

        }

    }
Example #3
0
 /**
  * Convert the url in exported/imported data
  *
  * Change the url from the original path with a placeholder
  *
  * @param $item string
  * @param $key  string
  * @param $type string
  *
  * @since  1.0.0
  * @author Andrea Grillo <*****@*****.**>
  * @return void
  */
 public function convert_url(&$item, $key, $type)
 {
     if (!isset($this->importer_uploads_url)) {
         $upload_dir = wp_upload_dir();
         $this->importer_uploads_url = $upload_dir['baseurl'];
     }
     if (!isset($this->importer_content_url)) {
         $this->importer_content_url = content_url();
     }
     if (!isset($this->importer_site_url)) {
         $this->importer_site_url = site_url() . '/';
     }
     if (yit_string_is_serialized($item)) {
         $item = maybe_unserialize($item);
         $item_type = 'serialized';
     } elseif (yit_string_is_json($item)) {
         $item = json_decode($item, true);
         $item_type = 'json_encoded';
     } else {
         $item_type = 'string';
     }
     switch ($type) {
         case 'in_import':
             if (!is_object($item) && !is_a($item, '__PHP_Incomplete_Class')) {
                 if (is_array($item)) {
                     array_walk_recursive($item, array($this, 'convert_url'), $type);
                     if ($item_type == 'serialized') {
                         $item = serialize($item);
                     } elseif ($item_type == 'json_encoded') {
                         $item = json_encode($item);
                     }
                 } else {
                     $item = str_replace('%uploadsurl%', $this->importer_uploads_url, $item);
                     $item = str_replace('%contenturl%', $this->importer_content_url, $item);
                     $item = str_replace('%siteurl%', $this->importer_site_url, $item);
                 }
             }
             break;
         case 'in_export':
             if (!is_object($item) && !is_a($item, '__PHP_Incomplete_Class')) {
                 if (is_array($item)) {
                     array_walk_recursive($item, array($this, 'convert_url'), $type);
                     if ($item_type == 'serialized') {
                         $item = serialize($item);
                     } elseif ($item_type == 'json_encoded') {
                         $item = json_encode($item);
                     }
                 } else {
                     $parsed_site_url = @parse_url($this->importer_site_url);
                     $item = str_replace($this->importer_uploads_url, '%uploadsurl%', $item);
                     $item = str_replace(str_replace($parsed_site_url['scheme'] . '://' . $parsed_site_url['host'], '', $this->importer_uploads_url), '%uploadsurl%', $item);
                     $item = str_replace($this->importer_content_url, '%contenturl%', $item);
                     $item = str_replace($this->importer_site_url, '%siteurl%', $item);
                 }
             }
             break;
     }
 }
Example #4
0
    /**
     * The function that fix the YIWLink problem
     *
     *
     * @author Andrea Grillo <*****@*****.**>
     * @author Andrea Frascaspata <*****@*****.**>
     * @since 2.0
     **/
    function convert_yit_url( &$item, $key, $type ) {

        if( yit_string_is_serialized( $item ) ){
            $item = maybe_unserialize( $item );
            $item_type = 'serialized';
        }elseif( yit_string_is_json( $item ) ){
            $find =false;

            $item = json_decode( $item, true );

            $item_type = 'json_encoded';
        }else {
            $item_type = 'string';
        }

        switch ( $type ) {

            case 'in_import' :

                $upload_dir             = wp_upload_dir();
                $importer_uploads_url   = $upload_dir['baseurl'];
                $importer_site_url      = site_url();

                if ( ! is_object( $item ) && ! is_a( $item, '__PHP_Incomplete_Class' ) ) {
                    if ( is_array( $item ) ) {
                        array_walk_recursive( $item, 'convert_yit_url', $type );
                        if( $item_type == 'serialized' ){
                            $item = serialize( $item );
                        } elseif( $item_type == 'json_encoded' ) {
                            $item = json_encode( $item );
                        }
                    }
                    else {
                        $item = str_replace( '%uploadsurl%', $importer_uploads_url, $item );
                        $item = str_replace( '%siteurl%', $importer_site_url, $item );
                    }
                }
                break;

            case 'in_export' :

                yit_update_db_value('http://demo.yithemes.com/','bazar',$item,$item_type,$type);
                yit_update_db_value('http://yourinspirationtheme.com/demo/','bazar',$item,$item_type,$type);
                yit_update_db_value('http://www.yourinspirationweb.com/demo/','bazar',$item,$item_type,$type);
                yit_update_db_value('http://yourinspirationtheme.com/tf/','bazar',$item,$item_type,$type);

                yit_update_db_value('http://demo.yithemes.com/','cheope',$item,$item_type,$type);
                yit_update_db_value('http://yourinspirationtheme.com/demo/','cheope',$item,$item_type,$type);
                yit_update_db_value('http://www.yourinspirationweb.com/demo/','cheope',$item,$item_type,$type);
                yit_update_db_value('http://yourinspirationtheme.com/tf/','cheope',$item,$item_type,$type);

                break;
        }
    }