Forum Replies Created

Viewing 15 replies - 16 through 30 (of 55 total)
  • I have the same issue.

    Yoast could define the variable before using it.

    wpseoPostScraperL10n is not defined

    so define it

    var wpseoPostScraperL10n = null;
    or
    var wpseoPostScraperL10n = {};
    or
    var wpseoPostScraperL10n;

    They could resolve this very easily.

    Thanks

    Andi

    You do not need a templates subdirectory just copy them and paste them into the sub theme, although you could alter the code to check in a nd-learning subdirectory/templates in the child theme first.

    This may keep it neater.

    Thanks

    Andi

    function nd_learning_get_courses_template($nd_learning_single_course_template) {
         global $post;
        
         if ($post->post_type == 'courses') {
    
          $single_postType_postName_template = locate_template("nd-learning/templates/single-course.php");
    
          if( file_exists( $single_postType_postName_template ) )  {
    
            $nd_learning_single_course_template = $single_postType_postName_template;
    
          } else {
    
            $nd_learning_single_course_template = dirname( __FILE__ ) . '/templates/single-course.php';
          }
    
         }
         return $nd_learning_single_course_template;
    }
    add_filter( 'single_template', 'nd_learning_get_courses_template' );

    Further to that maybe incorporating this into this functions would work better.

    Ref — https://codex.www.ads-software.com/Plugin_API/Filter_Reference/single_template

    Add single-{post_type}-{slug}.php to Template Hierarchy
    This example loads the template file single-{post_type}-{slug}.php (i.e. single-event-wordcamp.php) only if the file exists, otherwise loads default template.
    
    <?php
    function add_posttype_slug_template( $single_template )
    {
    	$object = get_queried_object();
    	$single_postType_postName_template = locate_template("single-{$object->post_type}-{$object->post_name}.php");
    	if( file_exists( $single_postType_postName_template ) )
    	{
    		return $single_postType_postName_template;
    	} else {
    		return $single_template;
    	}
    }
    add_filter( 'single_template', 'add_posttype_slug_template', 10, 1 );
    ?>

    Applied to your function and does the job.

    
    function nd_learning_get_courses_template($nd_learning_single_course_template) {
         global $post;
        
         if ($post->post_type == 'courses') {
    
          $single_postType_postName_template = locate_template("single-course.php");
    
          if( file_exists( $single_postType_postName_template ) )  {
    
            $nd_learning_single_course_template = $single_postType_postName_template;
    
          } else {
    
            $nd_learning_single_course_template = dirname( __FILE__ ) . '/templates/single-course.php';
          }
          
         }
         return $nd_learning_single_course_template;
    }
    add_filter( 'single_template', 'nd_learning_get_courses_template' );
    
    

    Hi There,

    We have this issue too.

    Your currency placeholder is after the currency in the single-course template which is not correct in the UK.

    Currently the template is like this…

    //metabox
    	    $nd_learning_meta_box_price = get_post_meta( get_the_ID(), 'nd_learning_meta_box_price', true );
    	    if ( $nd_learning_meta_box_price == 0 ) { 
    	        $nd_learning_meta_box_price = 'Free';
    	    } else { 
    	        $nd_learning_meta_box_price = $nd_learning_meta_box_price.' '.$nd_learning_currency; 
    	    }

    It needed to be prior to this.

     //metabox
    	    $nd_learning_meta_box_price = get_post_meta( get_the_ID(), 'nd_learning_meta_box_price', true );
    	    if ( $nd_learning_meta_box_price == 0 ) { 
    	        $nd_learning_meta_box_price = 'Free';
    	    } else { 
    	        $nd_learning_meta_box_price = $nd_learning_currency.' '.$nd_learning_meta_box_price; 
    	    }

    Rather than hacking the template in the plugin we wanted to copy it and add it in the child theme.

    To do this create a directory called templates in the child theme.
    Save courses-single.php in there and make your amends.

    However this does not work :o(

    For the developer.
    To be more consistent with WP calls. You could update your plugin include change dirname(__FILE__) to plugin_dir_path( __FILE__ ) perhaps.

    Example: change this in file… nd-learning.php around line 79

    function nd_learning_get_courses_template($nd_learning_single_course_template) {
         global $post;
    
         if ($post->post_type == 'courses') {
              $nd_learning_single_course_template = dirname( __FILE__ ) . '/templates/single-course.php';
         }
         return $nd_learning_single_course_template;
    }
    add_filter( 'single_template', 'nd_learning_get_courses_template' );

    To something like this…

    function nd_learning_get_courses_template($nd_learning_single_course_template) {
         global $post;
    
         if ($post->post_type == 'courses') {
              $nd_learning_single_course_template = plugin_dir_path( __FILE__ ) . '/templates/single-course.php';
         }
         return $nd_learning_single_course_template;
    }
    add_filter( 'single_template', 'nd_learning_get_courses_template' );

    Thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Actually that would just amend the constructor but the error is still being output. Do you have a solution?

    Thanks

    Andi

    @jetonr – As far as I can see the developer isn’t updating or looking after this plugin any longer and hasn’t for a while.
    His own website is no longer available which means:

    1. He/she’s gone out and got a job
    2. He/she’s deceased
    3. Can’t be bothered

    The two patches that both myself and @oaxdeer have provided in this forum thread after encountering the same issue do resolve the issue.

    There are now plenty of alternatives. I am looking at others to replace these.

    Another Fix to this is to replace

    $image_data['url']        = $result['display_src'];

    in line 949 of the plugin instaram_slider.php

    With this

    /// resolves the issues
    $srcn = preg_split('/\?/',$result['display_src']);
    $image_data['url']        = $srcn[0];

    The new instagram urls come back like this:

    https://scontent.cdninstagram.com/t51.2885-15/e35/12783255_560370694128931_356804048_n.jpg?ig_cache_key=MTE5MTk5MjQwMTE5NTg5MTgxOQ%3D%3D.2

    Parsing that into the function thinks its extension is a 2.
    so by splitting it up works out ok.

    thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    If anyone else has this issue it is an alternative to use this:

    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium' );

    You can then use the array to output an image tag.

    In the file: /wp-content/plugins/ninja-forms/classes/subs-cpt.php

    Add the undefined variable $view_post_link_html to the global variable scope on line 638, so that it looks like this.

    global $post, $post_ID, $view_post_link_html;

    This is the fix, that variable outputs something like this

    var_dump($view_post_link_html);
    
    string(92) "
    <a href="https://mydomain.com/?post_type=product&p=67">View post</a> "

    Save the file and re-upload.

    Thanks

    Andi

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    From this point of view of this request, this is now resolved.

    Thread Starter Andi Lee Davis

    (@andi-lee-davis)

    Ok We got over this by adding the weight and dims to the product variations.

    We get a new error but I guess that is to do with in-correct information:
    Error
    100
    Validation Failure:Site Id is wrong

    Not to anyone you NEED to have weights and dimensions on all your products for this to work.

    This information is on the information of this product description, but would also help if this information was included on the installation instructions too.

    thanks

    Andi

    Hi there,

    I found a solution.
    You have to install ImageMagic on the server.

    I am using Ubuntu/Debain 14.04 LTS

    You will have to ask the host to add the package for you:
    https://php.net/manual/en/imagick.setup.php

    Now using these instructions I have managed to code in a way to do create the thumbnail but I am having trouble attaching the meta data for it, becuase you have to assign the GUID as the eps and the jpg as the thumbnails…

    https://php.net/manual/en/imagick.setimageformat.php

    During the scan directory phase using a rcursive scan I create the post.
    After creating the post with a type called resources I then chack by file type/mime type or extension.

    Here is the bit that creates a jpeg from an ai file.
    Where it says .ai you can change to .eps

    Its no where near finished yet and needs a lot of work and testing but it will give your dv team a head start hopefully.

    // Get the path to the upload directory.
    			$wp_upload_dir = wp_upload_dir();
    
    			// $filename should be the path to a file in the upload directory.
    			$filename = '/some/path/to/your/image.ai'; /// $wp_upload_dir['basedir'] . '/' . $val->filename;  /// $val->virtualPathname; /// $val->filepathname; ///
    
    			/*$filedims = getimagesize($filename);
    			$imagick = new Imagick();
    			$imagick->newImage($filedims[0], $filedims[1], "white");
    			$imagick->compositeimage($filename, Imagick::COMPOSITE_OVER, 0, 0);
    			$imagick->setImageFormat("jpg");
    			$filename = $imagick->writeImage($filename);*/
    
    			// read page 1
    			$im = new imagick( $filename );
    
    			// convert to jpg
    			$im->setImageColorspace(255);
    			$im->setCompression(Imagick::COMPRESSION_JPEG);
    			$im->setCompressionQuality(60);
    			$im->setImageFormat('jpeg');
    
    			//resize
    			$im->resizeImage(1024, 768, imagick::FILTER_LANCZOS, 1); 
    
    			//write image on server
    			$im->writeImage(str_replace('.ai','.jpg', $val->filepathname));
    			$im->clear();
    			$im->destroy(); 
    
    			$parent_post_id = $key;
    
    			// Construct the attachment array
    			$attachment = array(
    				'post_mime_type' => str_replace('; charset=binary','',$val->mimeType),// $filetype, //
    				'guid' => str_replace('.ai','.jpg', substr($val->virtualShortPathName,1,strlen($val->virtualShortPathName))), ///$wp_upload_dir['url'] . '/' . basename( $filename ), ///$val->virtualPath, ///   $val->filepathname, ///
    				'post_parent' => $parent_post_id,
    				'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
    				'post_name' => strtolower(str_replace(' ', '-', $val->filename)),
    				'post_content' => '',
    				'post_date' => $dateNow->format('Y-m-d H:i:s'),
    				'post_date_gmt' => $dateNow->format('Y-m-d H:i:s'),
    				'post_status'    => 'inherit'
    			);
    			// var_dump($attachment);
    			///$attachment = apply_filters('our-resources-import_details', $attachment, $val->filepath, $parent_post_id, $dateNow->format('Y-m-d H:i:s'));
    
    			// Save the attachement data
    			$attach_id = wp_insert_attachment($attachment, $val->virtualShortPathName/* strtolower(str_replace(' ', '-', $val->filename))*/, $parent_post_id);
    			if ( !is_wp_error($attach_id) ) {
    				$attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
    				// var_dump($attach_data);
    				wp_update_attachment_metadata( $attach_id, $attach_data );
    				add_post_meta($parent_post_id, '_thumbnail_id', $attach_id, true);
    			}

    Thanks

    Andi

    @rixie
    Well done those guys. Glad you got it sorted.

    @rixie
    I Was looking for the same thing and digging around to program this in for myself in PHP because I wrote a plugin to manage our studio stock photography, scans in and creates the resource on another drive on our server.

    Wordpres is written in PHP.

    PHP does not handle ai, eps or svg natively. It is not designed to.

    I realise that our Adobe desktop apps have had $$$$ of dollars spent on developing them and are meant for an entirely different purpose entirely no more than illustrator cannot server a web page to the public no more than a website create a layered vector illustration.

    Jpg’s, gifs, pngs are essentially flat and easy to read which is why PHP had a better time of developing libraries for those.

    These plugins, libraries have either been paid for by someone else or developed in peoples spare time. So if you got the plugin for free and does 99% the work for you well I wouldn’t beat up the people too hard who have to work with the tools they’ve been given, even if it doesn’t fit your dream, especilly if you didn’t have to pay for these tools in the first place.

Viewing 15 replies - 16 through 30 (of 55 total)