Using class methods and properties outside wordpress (functions.php)

Today I create a class within my functions.php that contains some properties and methods about WordPress post formats. now my class contain the some code about Quote post format. but I don’t know how I can use the YPE_QPA() method and icon property within other WordPress files. for example how I can use this method and property within index.php?

class YPE_post_formats {

public $icon = '<span class="pull-right glyphicon glyphicon-pause"></span>';

public function YPE_QPA() {
    $quote_post = get_the_content();
    $quote_post = wpautop($quote_post);

    $quote_text = substr($quote_post, 0 , strpos($quote_post, '</p>') + 4);
    $quote_text = strip_tags($quote_text, '<a><strong><em><i>');

}
}

$YPE_PFormats = new YPE_post_formats();

Related posts

1 comment

  1. Any script that includes your functions.php script should be able to create an instance of your YPE_QPA class.

    include_once('path/to/functions.php');
    
    $YPE_PFormats = new YPE_post_formats();
    $YPE_PFormats->YPE_QPA();
    

Comments are closed.