Skip to content

Commit

Permalink
Change plugin name
Browse files Browse the repository at this point in the history
  • Loading branch information
tlovett1 committed Oct 6, 2020
1 parent 07028ad commit 6356955
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 73 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Convert classic editor posts to blocks on the fly.
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Release Version](https://img.shields.io/github/release/10up/gutenbridge.svg)](https://github.com/10up/gutenbridge/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v5.5%20tested-success.svg) [![GPLv2 License](https://img.shields.io/github/license/10up/gutenbridge.svg)](https://github.com/10up/gutenbridge/blob/develop/LICENSE.md)
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Release Version](https://img.shields.io/github/release/10up/convert-to-blocks.svg)](https://github.com/10up/convert-to-blocks/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v5.5%20tested-success.svg) [![GPLv2 License](https://img.shields.io/github/license/10up/convert-to-blocks.svg)](https://github.com/10up/convert-to-blocks/blob/develop/LICENSE.md)

## Overview

Expand All @@ -23,9 +23,9 @@ Convert to Blocks is a WordPress plugin that transforms classic editor content t

### How Do I Know It's Working?

Find a classic editor in the post, try to navigate away from the page. You will get an error saying your changes will be discarded. This is because Gutenbridge converted your content to blocks on the fly and those changes will be saved when you update the post.
Find a classic editor in the post, try to navigate away from the page. You will get an error saying your changes will be discarded. This is because Convert to Blocks converted your content to blocks on the fly and those changes will be saved when you update the post.

### Will Gutenbridge Handle My Custom Blocks?
### Will Convert to Blocks Handle My Custom Blocks?

By default it will not.

Expand All @@ -35,11 +35,11 @@ By default it will not.

## Changelog

A complete listing of all notable changes to Gutenbridge are documented in [CHANGELOG.md](https://github.com/10up/gutenbridge/blob/develop/CHANGELOG.md).
A complete listing of all notable changes to Convert to Blocks are documented in [CHANGELOG.md](https://github.com/10up/convert-to-blocks/blob/develop/CHANGELOG.md).

## Contributing

Please read [CODE_OF_CONDUCT.md](https://github.com/10up/gutenbridge/blob/develop/CODE_OF_CONDUCT.md) for details on our code of conduct, [CONTRIBUTING.md](https://github.com/10up/gutenbridge/blob/develop/CONTRIBUTING.md) for details on the process for submitting pull requests to us, and [CREDITS.md](https://github.com/10up/gutenbridge/blob/develop/CREDITS.md) for a listing of maintainers of, contributors to, and libraries used by Gutenbridge.
Please read [CODE_OF_CONDUCT.md](https://github.com/10up/convert-to-blocks/blob/develop/CODE_OF_CONDUCT.md) for details on our code of conduct, [CONTRIBUTING.md](https://github.com/10up/convert-to-blocks/blob/develop/CONTRIBUTING.md) for details on the process for submitting pull requests to us, and [CREDITS.md](https://github.com/10up/convert-to-blocks/blob/develop/CREDITS.md) for a listing of maintainers of, contributors to, and libraries used by Convert to Blocks.

## Like what you see?

Expand Down
94 changes: 28 additions & 66 deletions convert-to-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,77 +55,39 @@ function convert_to_blocks_get_setting( $name ) {

require_once __DIR__ . '/config.php';

/**
* Loads the Convert to Blocks PHP autoloader if possible.
*
* @return bool True or false if autoloading was successfull.
*/
function convert_to_blocks_autoload() {
if ( convert_to_blocks_can_autoload() ) {
require_once convert_to_blocks_autoloader();
// Require Composer autoloader if it exists.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
} else {
/**
* PSR-4-ish autoloading
*/
spl_autoload_register(
function( $class ) {
// project-specific namespace prefix.
$prefix = 'ConvertToBlocks\\';

return true;
} else {
return false;
}
}
// base directory for the namespace prefix.
$base_dir = __DIR__ . '/includes/ConvertToBlocks/';

/**
* In server mode we can autoload if autoloader file exists. For
* test environments we prevent autoloading of the plugin to prevent
* global pollution and for better performance.
*/
function convert_to_blocks_can_autoload() {
if ( file_exists( convert_to_blocks_autoloader() ) ) {
return true;
} else {
// phpcs:disable
error_log(
"Fatal Error: Composer not setup in " . CONVERT_TO_BLOCKS_DIR // only used for local debugging
);
// phpcs:enable
return false;
}
}
// does the class use the namespace prefix?
$len = strlen( $prefix );

/**
* Default is Composer's autoloader
*/
function convert_to_blocks_autoloader() {
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
return CONVERT_TO_BLOCKS_DIR . '/vendor/autoload.php';
} else {
return CONVERT_TO_BLOCKS_DIR . '/autoload.php';
}
}
if ( strncmp( $prefix, $class, $len ) !== 0 ) {
return;
}

/**
* Plugin code entry point. Singleton instance is used to maintain a common single
* instance of the plugin throughout the current request's lifecycle.
*
* If autoloading failed an admin notice is shown and logged to
* the PHP error_log.
*/
function convert_to_blocks_autorun() {
if ( convert_to_blocks_autoload() ) {
$plugin = \ConvertToBlocks\Plugin::get_instance();
$plugin->enable();
} else {
add_action( 'admin_notices', 'convert_to_blocks_autoload_notice' );
}
}
$relative_class = substr( $class, $len );

/**
* Displays an admin notice if composer install was not run
*/
function convert_to_blocks_autoload_notice() {
$class = 'notice notice-error';
$message = 'Error: Please run $ composer install in the Convert to Blocks plugin directory.';
$file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php';

printf( '<div class="%1$s"><p>%2$s</p></div>', sanitize_html_class( $class ), esc_html( $message ) );
// phpcs:disable
error_log( $message ); // only used for local debugging
// phpcs:enable
// if the file exists, require it.
if ( file_exists( $file ) ) {
require_once $file;
}
}
);
}

convert_to_blocks_autorun();
$plugin = \ConvertToBlocks\Plugin::get_instance();
$plugin->enable();
2 changes: 1 addition & 1 deletion includes/ConvertToBlocks/RESTSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function update_response( $response, $post, $request ) {
$updated = apply_filters( 'convert_to_blocks_raw_transform', $raw, $post, $request );
$data['content']['raw'] = $updated;

$data = apply_filters( 'gutenbridge_data_transform', $data, $post, $request );
$data = apply_filters( 'convert_to_blocks_data_transform', $data, $post, $request );

$response->set_data( $data );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Gutenbridge;
namespace ConvertToBlocks;

class PluginTest extends \WP_UnitTestCase {

Expand Down

0 comments on commit 6356955

Please sign in to comment.