WordPress.org

Ready to get started?Download WordPress

Forums

Shortcode Exec PHP
[resolved] How to use external class (3 posts)

  1. mav666
    Member
    Posted 1 year ago #

    Hello!

    I try to implement external class SEOstats.

    In shortcode [test] I have example usage of this class:

    include '../src/class.seostats.php';
    try
    {
      $url = new SEOstats("http://www.google.com/");
      print $url->Google_Page_Rank();
    }
    catch (SEOstatsException $e)
    {
      die($e->getMessage());
    }

    When I save shortcode and test it - everything is ok:
    [test]="9" (Google PR).

    But when I insert shortcode into post, I have a lot on errors:

    Warning: include(../src/class.seostats.php) [function.include]: failed to open stream: No such file or directory in /home/wordpress/domains/mydomain/public_html/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(967) : eval()'d code on line 1

    Warning: include(../src/class.seostats.php) [function.include]: failed to open stream: No such file or directory in /home/wordpress/domains/mydomain/public_html/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(967) : eval()'d code on line 1

    Warning: include() [function.include]: Failed opening '../src/class.seostats.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /home/wordpress/domains/mydomain/public_html/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(967) : eval()'d code on line 1

    Fatal error: Class 'SEOstats' not found in /home/wordpress/domains/mydomain/public_html/wp-content/plugins/shortcode-exec-php/shortcode-exec-php-class.php(967) : eval()'d code on line 4

    What I do wrong?
    Is any way to include this class?

    http://wordpress.org/extend/plugins/shortcode-exec-php/

  2. Marcel Bokhorst
    Member
    Plugin Author

    Posted 1 year ago #

    You will need an absolute path for the include, something like this:

    include WP_CONTENT_DIR . '/.../class.seostats.php'

    More info here.

  3. mav666
    Member
    Posted 1 year ago #

    Thanks! It works.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.