1583 | | ?> |
| 1583 | if ( !function_exists( 'wp_log' ) ) : |
| 1584 | /** |
| 1585 | * Log a message based on severity of the problem. |
| 1586 | * |
| 1587 | * The severity parameter accepts only 'notice', 'low', 'medium', 'warning', |
| 1588 | * 'high', and 'error' in that order of severity. |
| 1589 | * |
| 1590 | * @since {@internal Version Unknown}} |
| 1591 | * |
| 1592 | * @param string $type The area which the message was logged. |
| 1593 | * @param string $message The message to display to the user about the problem. |
| 1594 | * @param string $severity Severity level of the log message |
| 1595 | * @return bool False if failed to log message, true if message was logged. |
| 1596 | */ |
| 1597 | function wp_log($type, $message, $severity) { |
| 1598 | echo "<p><strong>{$type}</strong> (<em>{$severity}</em>: $message</p>"; |
| 1599 | return true; |
| 1600 | } |
| 1601 | endif; |
| 1602 | |
| 1603 | if ( !function_exists( 'wp_plugin_log' ) ) : |
| 1604 | /** |
| 1605 | * Log a plugin message based on severity of the problem. |
| 1606 | * |
| 1607 | * The severity parameter accepts only 'notice', 'low', 'medium', 'warning', |
| 1608 | * 'high', and 'error' in that order of severity. |
| 1609 | * |
| 1610 | * @since {@internal Version Unknown}} |
| 1611 | * |
| 1612 | * @param string $plugin Plugin Name |
| 1613 | * @param string $message The message to display to the user about the problem. |
| 1614 | * @param string $severity Severity level of the log message |
| 1615 | * @return bool False if failed to log message, true if message was logged. |
| 1616 | */ |
| 1617 | function wp_plugin_log($plugin, $message, $severity) { |
| 1618 | echo "<p><strong>{$plugin}</strong> (<em>{$severity}</em>: $message</p>"; |
| 1619 | return true; |
| 1620 | } |
| 1621 | endif; |
| 1622 | |
| 1623 | if ( !function_exists( 'wp_log_error_handler' ) ) : |
| 1624 | /** |
| 1625 | * Custom WordPress error handler. |
| 1626 | * |
| 1627 | * @param int $iError |
| 1628 | * @param string $strError |
| 1629 | * @param string $strFile |
| 1630 | * @param string $strLine |
| 1631 | * @param array $arrContext |
| 1632 | * @return bool |
| 1633 | */ |
| 1634 | function wp_log_error_handler($iError, $strError, $strFile, $strLine, $arrContext) { |
| 1635 | $content = "<p>"; |
| 1636 | |
| 1637 | if( defined('E_RECOVERABLE_ERROR') && E_RECOVERABLE_ERROR === $iError ) { |
| 1638 | $content .= "<strong>Recoverable Error</strong>: "; |
| 1639 | return true; |
| 1640 | } |
| 1641 | |
| 1642 | switch( $iError ) { |
| 1643 | |
| 1644 | case E_USER_ERROR: |
| 1645 | $content .= "<strong>User Error</strong>: "; |
| 1646 | break; |
| 1647 | |
| 1648 | case E_USER_WARNING: |
| 1649 | case E_WARNING: |
| 1650 | $content .= "<strong>Warning</strong>: "; |
| 1651 | break; |
| 1652 | |
| 1653 | case E_USER_NOTICE: |
| 1654 | case E_NOTICE: |
| 1655 | $content .= "<strong>Notice</strong>: "; |
| 1656 | break; |
| 1657 | default: |
| 1658 | return false; |
| 1659 | } |
| 1660 | |
| 1661 | $content .= "$strError found in <em>$strFile</em> on line <em>$strLine</em>.</p>"; |
| 1662 | echo $content; |
| 1663 | |
| 1664 | return true; |
| 1665 | } |
| 1666 | endif; |
| 1667 | |
| 1668 | ?> |
| 1669 | No newline at end of file |