Пример #1
0
 /**
  * @param int  $limit
  * @param bool $provide_object
  * @param bool $ignore_args
  *
  * @return array
  */
 public function get_backtrace($limit = 0, $provide_object = false, $ignore_args = true)
 {
     $options = false;
     if (version_compare($this->wp_api->phpversion(), '5.3.6') < 0) {
         // Before 5.3.6, the only values recognized are TRUE or FALSE,
         // which are the same as setting or not setting the DEBUG_BACKTRACE_PROVIDE_OBJECT option respectively.
         $options = $provide_object;
     } else {
         // As of 5.3.6, 'options' parameter is a bitmask for the following options:
         if ($provide_object) {
             $options |= DEBUG_BACKTRACE_PROVIDE_OBJECT;
         }
         if ($ignore_args) {
             $options |= DEBUG_BACKTRACE_IGNORE_ARGS;
         }
     }
     if (version_compare($this->wp_api->phpversion(), '5.4.0') >= 0) {
         $actual_limit = $limit == 0 ? 0 : $limit + 1;
         $debug_backtrace = debug_backtrace($options, $actual_limit);
         //add one item to include the current frame
     } elseif (version_compare($this->wp_api->phpversion(), '5.2.4') >= 0) {
         //@link https://core.trac.wordpress.org/ticket/20953
         $debug_backtrace = debug_backtrace();
     } else {
         $debug_backtrace = debug_backtrace($options);
     }
     //Remove the current frame
     if ($debug_backtrace) {
         array_shift($debug_backtrace);
     }
     return $debug_backtrace;
 }