Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
😄

Takuro Hishikawa hissy

💭
😄
View GitHub Profile
@hissy
hissy / app.php
Last active Sep 15, 2020
concrete5 request debugger
View app.php
<?php
// application/bootstrap/app.php
if ($app->isInstalled()) {
/** @var \Concrete\Core\Routing\Router $router */
$router = $app->make('router');
$router->get('/ccm/debug/request/{key}', static function ($key) use ($app) {
if ($key === 'PleaseChangePassphrase') {
$content = '<dl>';
$content .= sprintf('<dt>Environment</dt><dd>%s</dd>', $app->environment());
@hissy
hissy / app.php
Last active Sep 14, 2020
#concrete5 Visualize rendering time of each blocks with DebugBar
View app.php
<?php
/**
* First, install the debug bar package. @link: https://github.com/concrete5cojp/concrete5_debugbar
* Then, add these code in your application/bootstrap/app.php
*/
if ($app->isInstalled()) {
$debugBar = $app->make(\Concrete\Core\Package\PackageService::class)->getByHandle('concrete5_debugbar');
if (is_object($debugBar) && $debugBar->isPackageInstalled()) {
$director->addListener('on_block_load', static function ($event) use ($app) {
$bID = $event->getArgument('bID');
@hissy
hissy / gist:7352933
Created Nov 7, 2013
[WordPress] Add file to media library programmatically
View gist:7352933
<?php
$file = '/path/to/file.png';
$filename = basename($file);
$upload_file = wp_upload_bits($filename, null, file_get_contents($file));
if (!$upload_file['error']) {
$wp_filetype = wp_check_filetype($filename, null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_parent' => $parent_post_id,
@hissy
hissy / database.php
Last active Sep 2, 2020
#concrete5 set sql_mode from config file
View database.php
<?php
/**
* How to set sql_mode from database.php
* It will help to solve the error like "SQLSTATE[42000]: Syntax error or access violation:
* 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
* 'concrete5.cv.cvPublishDate' which is not functionally dependent on columns in GROUP BY clause;
* this is incompatible with sql_mode=only_full_group_by"
*/
@hissy
hissy / backlog-deploy.php
Last active Aug 27, 2020
Git Webhookを使ったCPIへのデプロイスクリプト
View backlog-deploy.php
<?php
// CPIユーザーID(契約情報で確認してください)
$user_id = 'abc123defg';
// リポジトリ名(Backlogで確認してください)
$repo_name = 'repository_name';
// Gitレポジトリの位置の指定
$git_dir = '/usr/home/' . $user_id . '/' . $repo_name . '.git';
// 展開先ディレクトリの指定
$work_tree = '/usr/home/' . $user_id . '/html';
// logファイルの指定
@hissy
hissy / gist:6103177
Last active Aug 21, 2020
[WordPress] どうしても固定ページテンプレートでページ送り付きのアーカイブが作りたいのよと言う場合
View gist:6103177
<?php
/**
* Template Name: Archive Page */
?>
<?php
$paged = (int) get_query_var('paged');
$args = array(
'posts_per_page' => 3,
'paged' => $paged,
@hissy
hissy / gist:3613306
Last active Aug 20, 2020
[WordPress] change next / previous post link ordering
View gist:3613306
<?php
/**
* Customize Adjacent Post Link Order
*/
function my_custom_adjacent_post_where($sql) {
if ( !is_main_query() || !is_singular() )
return $sql;
$the_post = get_post( get_the_ID() );
$patterns = array();
@hissy
hissy / demo_users.xml
Created Aug 9, 2020
[concrete5] Example users & groups
View demo_users.xml
<?xml version="1.0" encoding="UTF-8"?>
<concrete5-cif version="1.0">
<users>
<user username="editor" email="editor@example.com">
<groups>
<group path="/Editor"/>
</groups>
</user>
<user username="approver_a" email="approver_a@example.com">
<groups>
@hissy
hissy / clear_empty_workflow_progress.php
Last active Jul 23, 2020
[concrete5] A job to deletes empty "Compare Versions" alerts.
View clear_empty_workflow_progress.php
<?php
namespace Application\Job;
use Job as AbstractJob;
use Concrete\Core\Workflow\Progress\PageProgress;
use Concrete\Core\Workflow\EmptyWorkflow;
class ClearEmptyWorkflowProgress extends AbstractJob
{
@hissy
hissy / importer-class-filter-example.php
Last active Jul 2, 2020
[Really Simple CSV Importer] add-on: Update row based on a custom field ID/key match
View importer-class-filter-example.php
<?php
/*
Plugin Name: Update row based on a custom field ID/key match
Plugin URI: https://wordpress.org/support/topic/update-row-based-on-a-custom-field-idkey-match
*/
add_filter('really_simple_csv_importer_class', function() {
return "ImporterCustomize";
});
You can’t perform that action at this time.