bobbingwide / oik-blocks

WordPress 5.0 blocks for oik shortcodes
https://oik-plugins.com/oik-plugins/oik-blocks
GNU General Public License v3.0
1 stars 0 forks source link

Uncaught Error: Call to undefined function is_plugin_active() #46

Closed bobbingwide closed 3 years ago

bobbingwide commented 3 years ago

Fatal error: Uncaught Error: Call to undefined function is_plugin_active() in C:\apache\htdocs\wordpress\wp-content\plugins\oik-blocks\oik-blocks.php:408

  | Stack trace:
  | #0 C:\apache\htdocs\wordpress\wp-content\plugins\oik-blocks\oik-blocks.php(316): oik_blocks_check_server_func('shortcodes/oik-...', 'oik-fields', 'bw_metadata')
  | #1 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat.php(132): oik_blocks_dynamic_block_fields(Array, '', Object(WP_Block))
  | #2 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(221): {closure}(Array, '', Object(WP_Block))
  | #3 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(211): WP_Block->render()
  | #4 C:\apache\htdocs\wp55\wp-includes\blocks.php(864): WP_Block->render()
  | #5 C:\apache\htdocs\wp55\wp-includes\blocks.php(902): render_block(Array)
  | #6 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\build\block-library\blocks\template-part.php(89): do_blocks('<!-- wp:group {...')
  | #7 C:\apache\htdocs\wp55\wp-content\plugins\gutenberg\lib\compat.php(132): gutenberg_render_block_core_template_part(Array, '', Object(WP_Block))
  | #8 C:\apache\htdocs\wp55\wp-includes\class-wp-block.php(221): {closure}(Array, '', Object(WP_Block))
  | #9 C:\apache\htdocs\wp55\wp-includes\blocks.php(864): WP_Block->render()
  | #10 C:\apache\htdocs\wp55\wp-includes\blocks.php(902): render_block(Array)
  | #11 C:\apache\htdocs\wp55\wp-includes\block-template.php(171): do_blocks('<!-- wp:html --...')
  | #12 C:\apache\htdocs\wp55\wp-includes\template-canvas.php(12): get_the_block_template_html()
  | #13 C:\apache\htdocs\wp55\wp-includes\template-loader.php(106): include('C:\\apache\\htdoc...')
  | #14 C:\apache\htdocs\wp55\wp-blog-header.php(19): require_once('C:\\apache\\htdoc...')
  | #15 C:\apache\htdocs\wp55\index.php(17): require('C:\\apache\\htdoc...')
  | #16 {main}
  | thrown in <b>C:\apache\htdocs\wordpress\wp-content\plugins\oik-blocks\oik-blocks.php</b> on line <b>408</b><br />
bobbingwide commented 3 years ago

I got this again during the refactoring of the oik-blocks/fields block. The line number in oik-blocks.php is quite different due to the refactoring.

bobbingwide commented 3 years ago

The pragmatic fix is to load the logic if it's missing. eg in oik_blocks_check_server_func() add the following code.

if ( !function_exists( 'is_plugin_active') ) {
        require_once ABSPATH . 'wp-admin/includes/admin.php';
    }
bobbingwide commented 3 years ago

Fix was committed in 4e760d3a449ed2ddf049866af4b40dccdc7b327f