Skip to content

Commit

Permalink
Merge pull request #33 from a8cteam51/feat/add-reactions-block
Browse files Browse the repository at this point in the history
feat: add reactions block
  • Loading branch information
nate-allen authored Dec 19, 2024
2 parents bf03fc1 + c360a91 commit 742ec00
Show file tree
Hide file tree
Showing 58 changed files with 23,825 additions and 0 deletions.
570 changes: 570 additions & 0 deletions .eslintrc.js

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions .tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"target": "esnext",
"module": "esnext",
"lib": [ "DOM", "DOM.Iterable", "ESNext" ],
"declaration": true,
"declarationMap": true,
"composite": true,
"emitDeclarationOnly": true,
"isolatedModules": true,

"skipDefaultLibCheck": true,

/* Strict Type-Checking Options */
"strict": true,

/* Additional Checks */
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,

/* Module Resolution Options */
"moduleResolution": "node",

/* This needs to be false so our types are possible to consume without setting this */
"esModuleInterop": false,
"resolveJsonModule": true,

"typeRoots": [ "./typings", "./node_modules/@types" ],
"types": []
},
"exclude": [
"**/*.android.js",
"**/*.ios.js",
"**/*.native.js",
"**/benchmark",
"packages/*/build-*/**",
"packages/*/build/**",
"**/test/**",
"packages/**/react-native-*/**"
]
}
18 changes: 18 additions & 0 deletions reactions/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# WordPress Coding Standards
# https://make.wordpress.org/core/handbook/coding-standards/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab

[*.{yml,yaml}]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions reactions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Output of `npm pack`
*.tgz

# Output of `wp-scripts plugin-zip`
*.zip

# dotenv environment variables file
.env
5 changes: 5 additions & 0 deletions reactions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 1.0.0 (2024-06-25)

### New Features

- Initial version.
80 changes: 80 additions & 0 deletions reactions/classes/class-wpcomsp-blocks-self-update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
/**
* Plugin Autoupdate Filter Self Update class.
* sets up autoupdates for this GitHub-hosted plugin.
*
* @package wpcomsp
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

class WPCOMSP_Blocks_Self_Update {

public static $instance;

/**
* Get instance of this class.
*
* @return WPCOMSP_Blocks_Self_Update
*/
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}

return self::$instance;
}

/**
* Initialize WordPress hooks
*/
public function hooks() {
add_filter( 'update_plugins_opsoasis.wpspecialprojects.com', array( $this, 'self_update' ), 10, 3 );
}

/**
* Check for updates to this plugin
*
* @param array $update Array of update data.
* @param array $plugin_data Array of plugin data.
* @param string $plugin_file Path to plugin file.
*
* @return array|bool Array of update data or false if no update available.
*/
public function self_update( $update, array $plugin_data, string $plugin_file ) {
// Already completed update check elsewhere.
if ( ! empty( $update ) ) {
return $update;
}

$plugin_filename_parts = explode( '/', $plugin_file );

// Ask opsoasis.mystagingwebsite.com if there's an update.
$response = wp_remote_get(
'https://opsoasis.wpspecialprojects.com/wp-json/opsoasis-blocks-version-manager/v1/update-check',
array(
'body' => array(
'plugin' => $plugin_filename_parts[0],
'version' => $plugin_data['Version'],
),
)
);

// Bail if this plugin wasn't found on opsoasis.mystagingwebsite.com.
if ( 404 === wp_remote_retrieve_response_code( $response ) || 202 === wp_remote_retrieve_response_code( $response ) ) {
return $update;
}

$updated_version = wp_remote_retrieve_body( $response );
$updated_array = json_decode( $updated_version, true );

return array(
'slug' => $updated_array['slug'],
'version' => $updated_array['version'],
'url' => $updated_array['package_url'],
'package' => $updated_array['package_url'],
);
}
}
Loading

0 comments on commit 742ec00

Please sign in to comment.