{"action":"created","comment":{"url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/comments/31750963","id":31750963,"diff_hunk":"@@ -0,0 +1,92 @@\n+<?php\n+\n+class Speed_Bumps {\n+\tprivate static $instance;\n+\n+\tpublic static function get_instance() {\n+\t\tif ( ! isset( self::$instance ) ) {\n+\n+\t\t\tself::require_files();\n+\t\t\tself::$instance = new Speed_Bumps;\n+\t\t\tself::$instance->setup_filters();\n+\t\t\t\n+\t\t}\n+\t\treturn self::$instance;\n+\t}\n+\n+\tprivate static function require_files() {\n+\t\trequire_once( dirname( __FILE__ ) . '/class-speed-bumps-text-constraints.php' );\n+\t\trequire_once( dirname( __FILE__ ) . '/class-speed-bumps-element-constraints.php' );\n+\t}\n+\n+\tprivate static function setup_filters() {\n+\t\tadd_filter( 'speed_bumps_inject_content', 'Speed_Bumps::insert_speed_bumps', 10, 2 );\n+\t}\n+\n+\tpublic function register_speed_bump( $id, $args = array() ) {\n+\t\tglobal $_speed_bumps_args;\n+\t\t\n+\t\t$default = array(\n+\t\t\t'string_to_inject' => '',\n+\t\t\t'minimum_content_length' => 1200,\n+\t\t\t'element_constraints' => array( \n+\t\t\t\t'iframe',\n+\t\t\t\t'embed',\n+\t\t\t\t'image',\n+\t\t\t)\n+\t\t);\n+\t\t\n+\t\t$args = wp_parse_args( $args, $default );\n+\t\t$_speed_bumps_args = array();\n+\t\t$_speed_bumps_args[ $id ] = $args;\n+\t\t\n+\t\tadd_filter( 'speed_bumps_global_constraints', 'Speed_Bumps_Text_Constraints::minimum_content_length', 10, 3 );\n+\t\tadd_filter( 'speed_bumps_paragraph_constraints', 'Speed_Bumps_Element_Constraints::prev_paragraph_contains_element', 10, 2 );\n+\n+\t\tadd_filter( 'speed_bumps_insert_ad', 'Speed_Bumps::string_to_inject', 10, 1 );\n+\t}\n+\n+\tpublic static function string_to_inject( $speed_bump_id ) {\n+\t\tglobal $_speed_bumps_args;\n+\t\t$string_to_inject = $_speed_bumps_args[ $speed_bump_id ][ 'string_to_inject' ];\n+\t\n+\t\treturn $string_to_inject . PHP_EOL . PHP_EOL;\n+\t}\n+\n+\tpublic static function insert_speed_bumps( $speed_bump_id, $the_content ) {\n+\t\tif( apply_filters( 'speed_bumps_global_constraints', true, $speed_bump_id, $the_content ) ) {\n+\t\t\t$output = array();\n+\t\t\t$alreadyInsertAd = false;\n+\t\t\t$parts = explode( PHP_EOL, $the_content );\n+\n+\t\t\tif( count( $parts ) <= 1 ) {\n+\t\t\t\treturn  array_shift( $parts ) . apply_filters( 'speed_bumps_insert_ad', $speed_bump_id );","path":"inc/class-speed-bumps.php","position":63,"original_position":63,"commit_id":"172f4be61cab574b0871398d9fa7d727ba310e8d","original_commit_id":"172f4be61cab574b0871398d9fa7d727ba310e8d","user":{"login":"noppanit","id":638379,"avatar_url":"https://avatars.githubusercontent.com/u/638379?v=3","gravatar_id":"","url":"https://api.github.com/users/noppanit","html_url":"https://github.com/noppanit","followers_url":"https://api.github.com/users/noppanit/followers","following_url":"https://api.github.com/users/noppanit/following{/other_user}","gists_url":"https://api.github.com/users/noppanit/gists{/gist_id}","starred_url":"https://api.github.com/users/noppanit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noppanit/subscriptions","organizations_url":"https://api.github.com/users/noppanit/orgs","repos_url":"https://api.github.com/users/noppanit/repos","events_url":"https://api.github.com/users/noppanit/events{/privacy}","received_events_url":"https://api.github.com/users/noppanit/received_events","type":"User","site_admin":false},"body":"@danielbachhuber just want to be clear. Does it mean this method should be in the `theme` instead? ","created_at":"2015-06-04T18:36:40Z","updated_at":"2015-06-04T18:36:40Z","html_url":"https://github.com/fusioneng/speed-bumps/pull/1#discussion_r31750963","pull_request_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/comments/31750963"},"html":{"href":"https://github.com/fusioneng/speed-bumps/pull/1#discussion_r31750963"},"pull_request":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1","id":35248799,"html_url":"https://github.com/fusioneng/speed-bumps/pull/1","diff_url":"https://github.com/fusioneng/speed-bumps/pull/1.diff","patch_url":"https://github.com/fusioneng/speed-bumps/pull/1.patch","issue_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/1","number":1,"state":"open","locked":false,"title":"Intelligent Speed bumps","user":{"login":"noppanit","id":638379,"avatar_url":"https://avatars.githubusercontent.com/u/638379?v=3","gravatar_id":"","url":"https://api.github.com/users/noppanit","html_url":"https://github.com/noppanit","followers_url":"https://api.github.com/users/noppanit/followers","following_url":"https://api.github.com/users/noppanit/following{/other_user}","gists_url":"https://api.github.com/users/noppanit/gists{/gist_id}","starred_url":"https://api.github.com/users/noppanit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noppanit/subscriptions","organizations_url":"https://api.github.com/users/noppanit/orgs","repos_url":"https://api.github.com/users/noppanit/repos","events_url":"https://api.github.com/users/noppanit/events{/privacy}","received_events_url":"https://api.github.com/users/noppanit/received_events","type":"User","site_admin":false},"body":"https://github.com/fusioneng/fusion-theme/issues/2701","created_at":"2015-05-12T17:10:47Z","updated_at":"2015-06-04T18:36:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78d643d9c028af7674ef3a4aef5b08f6700e2b91","assignee":{"login":"noppanit","id":638379,"avatar_url":"https://avatars.githubusercontent.com/u/638379?v=3","gravatar_id":"","url":"https://api.github.com/users/noppanit","html_url":"https://github.com/noppanit","followers_url":"https://api.github.com/users/noppanit/followers","following_url":"https://api.github.com/users/noppanit/following{/other_user}","gists_url":"https://api.github.com/users/noppanit/gists{/gist_id}","starred_url":"https://api.github.com/users/noppanit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noppanit/subscriptions","organizations_url":"https://api.github.com/users/noppanit/orgs","repos_url":"https://api.github.com/users/noppanit/repos","events_url":"https://api.github.com/users/noppanit/events{/privacy}","received_events_url":"https://api.github.com/users/noppanit/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1/commits","review_comments_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1/comments","review_comment_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/1/comments","statuses_url":"https://api.github.com/repos/fusioneng/speed-bumps/statuses/172f4be61cab574b0871398d9fa7d727ba310e8d","head":{"label":"fusioneng:2701-speed-bumps","ref":"2701-speed-bumps","sha":"172f4be61cab574b0871398d9fa7d727ba310e8d","user":{"login":"fusioneng","id":8161069,"avatar_url":"https://avatars.githubusercontent.com/u/8161069?v=3","gravatar_id":"","url":"https://api.github.com/users/fusioneng","html_url":"https://github.com/fusioneng","followers_url":"https://api.github.com/users/fusioneng/followers","following_url":"https://api.github.com/users/fusioneng/following{/other_user}","gists_url":"https://api.github.com/users/fusioneng/gists{/gist_id}","starred_url":"https://api.github.com/users/fusioneng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusioneng/subscriptions","organizations_url":"https://api.github.com/users/fusioneng/orgs","repos_url":"https://api.github.com/users/fusioneng/repos","events_url":"https://api.github.com/users/fusioneng/events{/privacy}","received_events_url":"https://api.github.com/users/fusioneng/received_events","type":"Organization","site_admin":false},"repo":{"id":35431371,"name":"speed-bumps","full_name":"fusioneng/speed-bumps","owner":{"login":"fusioneng","id":8161069,"avatar_url":"https://avatars.githubusercontent.com/u/8161069?v=3","gravatar_id":"","url":"https://api.github.com/users/fusioneng","html_url":"https://github.com/fusioneng","followers_url":"https://api.github.com/users/fusioneng/followers","following_url":"https://api.github.com/users/fusioneng/following{/other_user}","gists_url":"https://api.github.com/users/fusioneng/gists{/gist_id}","starred_url":"https://api.github.com/users/fusioneng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusioneng/subscriptions","organizations_url":"https://api.github.com/users/fusioneng/orgs","repos_url":"https://api.github.com/users/fusioneng/repos","events_url":"https://api.github.com/users/fusioneng/events{/privacy}","received_events_url":"https://api.github.com/users/fusioneng/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fusioneng/speed-bumps","description":"","fork":false,"url":"https://api.github.com/repos/fusioneng/speed-bumps","forks_url":"https://api.github.com/repos/fusioneng/speed-bumps/forks","keys_url":"https://api.github.com/repos/fusioneng/speed-bumps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fusioneng/speed-bumps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fusioneng/speed-bumps/teams","hooks_url":"https://api.github.com/repos/fusioneng/speed-bumps/hooks","issue_events_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/events{/number}","events_url":"https://api.github.com/repos/fusioneng/speed-bumps/events","assignees_url":"https://api.github.com/repos/fusioneng/speed-bumps/assignees{/user}","branches_url":"https://api.github.com/repos/fusioneng/speed-bumps/branches{/branch}","tags_url":"https://api.github.com/repos/fusioneng/speed-bumps/tags","blobs_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/refs{/sha}","trees_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fusioneng/speed-bumps/statuses/{sha}","languages_url":"https://api.github.com/repos/fusioneng/speed-bumps/languages","stargazers_url":"https://api.github.com/repos/fusioneng/speed-bumps/stargazers","contributors_url":"https://api.github.com/repos/fusioneng/speed-bumps/contributors","subscribers_url":"https://api.github.com/repos/fusioneng/speed-bumps/subscribers","subscription_url":"https://api.github.com/repos/fusioneng/speed-bumps/subscription","commits_url":"https://api.github.com/repos/fusioneng/speed-bumps/commits{/sha}","git_commits_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/commits{/sha}","comments_url":"https://api.github.com/repos/fusioneng/speed-bumps/comments{/number}","issue_comment_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/comments{/number}","contents_url":"https://api.github.com/repos/fusioneng/speed-bumps/contents/{+path}","compare_url":"https://api.github.com/repos/fusioneng/speed-bumps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fusioneng/speed-bumps/merges","archive_url":"https://api.github.com/repos/fusioneng/speed-bumps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fusioneng/speed-bumps/downloads","issues_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues{/number}","pulls_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls{/number}","milestones_url":"https://api.github.com/repos/fusioneng/speed-bumps/milestones{/number}","notifications_url":"https://api.github.com/repos/fusioneng/speed-bumps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fusioneng/speed-bumps/labels{/name}","releases_url":"https://api.github.com/repos/fusioneng/speed-bumps/releases{/id}","created_at":"2015-05-11T15:08:48Z","updated_at":"2015-05-11T15:20:08Z","pushed_at":"2015-06-04T12:10:13Z","git_url":"git://github.com/fusioneng/speed-bumps.git","ssh_url":"git@github.com:fusioneng/speed-bumps.git","clone_url":"https://github.com/fusioneng/speed-bumps.git","svn_url":"https://github.com/fusioneng/speed-bumps","homepage":null,"size":224,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"fusioneng:master","ref":"master","sha":"64f2b286b884ff382b9480d826b25a0d4d9411b1","user":{"login":"fusioneng","id":8161069,"avatar_url":"https://avatars.githubusercontent.com/u/8161069?v=3","gravatar_id":"","url":"https://api.github.com/users/fusioneng","html_url":"https://github.com/fusioneng","followers_url":"https://api.github.com/users/fusioneng/followers","following_url":"https://api.github.com/users/fusioneng/following{/other_user}","gists_url":"https://api.github.com/users/fusioneng/gists{/gist_id}","starred_url":"https://api.github.com/users/fusioneng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusioneng/subscriptions","organizations_url":"https://api.github.com/users/fusioneng/orgs","repos_url":"https://api.github.com/users/fusioneng/repos","events_url":"https://api.github.com/users/fusioneng/events{/privacy}","received_events_url":"https://api.github.com/users/fusioneng/received_events","type":"Organization","site_admin":false},"repo":{"id":35431371,"name":"speed-bumps","full_name":"fusioneng/speed-bumps","owner":{"login":"fusioneng","id":8161069,"avatar_url":"https://avatars.githubusercontent.com/u/8161069?v=3","gravatar_id":"","url":"https://api.github.com/users/fusioneng","html_url":"https://github.com/fusioneng","followers_url":"https://api.github.com/users/fusioneng/followers","following_url":"https://api.github.com/users/fusioneng/following{/other_user}","gists_url":"https://api.github.com/users/fusioneng/gists{/gist_id}","starred_url":"https://api.github.com/users/fusioneng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fusioneng/subscriptions","organizations_url":"https://api.github.com/users/fusioneng/orgs","repos_url":"https://api.github.com/users/fusioneng/repos","events_url":"https://api.github.com/users/fusioneng/events{/privacy}","received_events_url":"https://api.github.com/users/fusioneng/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fusioneng/speed-bumps","description":"","fork":false,"url":"https://api.github.com/repos/fusioneng/speed-bumps","forks_url":"https://api.github.com/repos/fusioneng/speed-bumps/forks","keys_url":"https://api.github.com/repos/fusioneng/speed-bumps/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fusioneng/speed-bumps/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fusioneng/speed-bumps/teams","hooks_url":"https://api.github.com/repos/fusioneng/speed-bumps/hooks","issue_events_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/events{/number}","events_url":"https://api.github.com/repos/fusioneng/speed-bumps/events","assignees_url":"https://api.github.com/repos/fusioneng/speed-bumps/assignees{/user}","branches_url":"https://api.github.com/repos/fusioneng/speed-bumps/branches{/branch}","tags_url":"https://api.github.com/repos/fusioneng/speed-bumps/tags","blobs_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/refs{/sha}","trees_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fusioneng/speed-bumps/statuses/{sha}","languages_url":"https://api.github.com/repos/fusioneng/speed-bumps/languages","stargazers_url":"https://api.github.com/repos/fusioneng/speed-bumps/stargazers","contributors_url":"https://api.github.com/repos/fusioneng/speed-bumps/contributors","subscribers_url":"https://api.github.com/repos/fusioneng/speed-bumps/subscribers","subscription_url":"https://api.github.com/repos/fusioneng/speed-bumps/subscription","commits_url":"https://api.github.com/repos/fusioneng/speed-bumps/commits{/sha}","git_commits_url":"https://api.github.com/repos/fusioneng/speed-bumps/git/commits{/sha}","comments_url":"https://api.github.com/repos/fusioneng/speed-bumps/comments{/number}","issue_comment_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues/comments{/number}","contents_url":"https://api.github.com/repos/fusioneng/speed-bumps/contents/{+path}","compare_url":"https://api.github.com/repos/fusioneng/speed-bumps/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fusioneng/speed-bumps/merges","archive_url":"https://api.github.com/repos/fusioneng/speed-bumps/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fusioneng/speed-bumps/downloads","issues_url":"https://api.github.com/repos/fusioneng/speed-bumps/issues{/number}","pulls_url":"https://api.github.com/repos/fusioneng/speed-bumps/pulls{/number}","milestones_url":"https://api.github.com/repos/fusioneng/speed-bumps/milestones{/number}","notifications_url":"https://api.github.com/repos/fusioneng/speed-bumps/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fusioneng/speed-bumps/labels{/name}","releases_url":"https://api.github.com/repos/fusioneng/speed-bumps/releases{/id}","created_at":"2015-05-11T15:08:48Z","updated_at":"2015-05-11T15:20:08Z","pushed_at":"2015-06-04T12:10:13Z","git_url":"git://github.com/fusioneng/speed-bumps.git","ssh_url":"git@github.com:fusioneng/speed-bumps.git","clone_url":"https://github.com/fusioneng/speed-bumps.git","svn_url":"https://github.com/fusioneng/speed-bumps","homepage":null,"size":224,"stargazers_count":0,"watchers_count":0,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1"},"html":{"href":"https://github.com/fusioneng/speed-bumps/pull/1"},"issue":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/issues/1"},"comments":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/fusioneng/speed-bumps/statuses/172f4be61cab574b0871398d9fa7d727ba310e8d"}}}}