WordPress.org

Forums

LaTeX for WordPress
Deprecated use of snoopy class (4 posts)

  1. mrfrankster
    Member
    Posted 3 years ago #

    use of snoopy class needs to be replaced with WP_Http as per http://wpquestions.com/question/show/id/1925

    This is the fixed section of latex.php:

    if ( !is_file($cache_formula_path) || filesize($cache_formula_path) < 10) {
    if( !class_exists( 'WP_Http' ) )
    include_once( ABSPATH . WPINC. '/class-http.php' );

    $request = new WP_Http;

    $formula_text_html = str_replace('%C2%A0', '%20',
    rawurlencode(html_entity_decode(preg_replace('/\\\\label{.*?}/', '', $formula_text))));
    $result = $request->request(get_option('latex_img_server').$formula_text_html);
    if (strlen($result['body']) < 10)
    $result = $request->request('http://www.quantnet.com/cgi-bin/mathtex.cgi?'.rawurlencode(($formula_text)));
    $cache_file = fopen($cache_formula_path, 'w');
    fputs($cache_file, $result['body']);

    http://wordpress.org/extend/plugins/latex/

  2. goodseller
    Member
    Posted 2 years ago #

    Seems you removed a row:

    if (strlen($result['body']) < 10)
    $result = $request->request('http://www.quantnet.com/cgi-bin/mathtex.cgi?'.rawurlencode(($formula_text)));
    $cache_file = fopen($cache_formula_path, 'w');
    fputs($cache_file, $result['body']);

    The first row here, is that needed?

  3. mrfrankster
    Member
    Posted 2 years ago #

    It looks like the indenting gets lost when posted in the comments here.

    The original code has:

    $snoopy->fetch(get_option('latex_img_server').$formula_text_html);
                                    if (strlen($snoopy->results) < 10)
                                       $snoopy->fetch('http://www.quantnet.com/cgi-bin/mathtex.cgi?'.rawurlencode(($formula_text)));

    So the new code is intended to behave exactly the same as the original code.

  4. goodseller
    Member
    Posted 2 years ago #

    O... ic, I got the same problem while posting the above post. LOL
    Thanks for sharing!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • LaTeX for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.