Version Description
- Removing vestigial files
Download this release
Release Info
Developer | cartpauj |
Plugin | ![]() |
Version | 3.2.3 |
Comparing to | |
See all releases |
Code changes from version 3.2.2 to 3.2.3
- .distignore +0 -18
- .github/workflows/main.yml +0 -17
- .gitignore +0 -2
- .phpcs.xml.dist +0 -49
- .travis.yml +0 -67
- .wordpress-org/banner-1544x500.png +0 -0
- .wordpress-org/banner-772x250.png +0 -0
- .wordpress-org/icon-128x128.png +0 -0
- .wordpress-org/icon-256x256.png +0 -0
- README +0 -5
- i18n/pretty-link.pot +2 -2
- images/not_tracking.png +0 -0
- package.json +0 -37
- phpunit.xml.dist +0 -15
- pretty-link.php +1 -1
- pro/README +0 -0
- pro/app/controllers/PlpAppController.php +0 -179
- pro/app/controllers/PlpDbController.php +0 -282
- pro/app/controllers/PlpImportExportController.php +0 -378
- pro/app/controllers/PlpKeywordsController.php +0 -513
- pro/app/controllers/PlpLinkCategoriesController.php +0 -43
- pro/app/controllers/PlpLinkTagsController.php +0 -50
- pro/app/controllers/PlpLinksController.php +0 -892
- pro/app/controllers/PlpOptionsController.php +0 -249
- pro/app/controllers/PlpPostsController.php +0 -259
- pro/app/controllers/PlpPrettyBarController.php +0 -127
- pro/app/controllers/PlpPublicLinksController.php +0 -154
- pro/app/controllers/PlpReportsController.php +0 -344
- pro/app/controllers/PlpSocialButtonsController.php +0 -71
- pro/app/controllers/PlpToolsController.php +0 -18
- pro/app/controllers/PlpTwitterController.php +0 -22
- pro/app/controllers/index.php +0 -2
- pro/app/helpers/PlpLinksHelper.php +0 -36
- pro/app/helpers/PlpOptionsHelper.php +0 -36
- pro/app/helpers/PlpPostsHelper.php +0 -84
- pro/app/helpers/PlpPrettyBarHelper.php +0 -65
- pro/app/helpers/PlpPublicLinksHelper.php +0 -19
- pro/app/helpers/PlpSocialButtonsHelper.php +0 -65
- pro/app/helpers/PlpTwitterHelper.php +0 -26
- pro/app/helpers/index.php +0 -2
- pro/app/index.php +0 -2
- pro/app/models/PlpKeyword.php +0 -724
- pro/app/models/PlpLinkRotation.php +0 -186
- pro/app/models/PlpOptions.php +0 -407
- pro/app/models/PlpPostOptions.php +0 -79
- pro/app/models/PlpReport.php +0 -497
- pro/app/models/PlpUrlReplacement.php +0 -409
- pro/app/models/PlpUtils.php +0 -276
- pro/app/models/index.php +0 -2
- pro/app/views/import-export/form.php +0 -52
- pro/app/views/import-export/import-error.php +0 -11
- pro/app/views/import-export/import.php +0 -51
- pro/app/views/import-export/index.php +0 -2
- pro/app/views/index.php +0 -2
- pro/app/views/links/bulk-edit.php +0 -31
- pro/app/views/links/cloaked-redirect.php +0 -22
- pro/app/views/links/form.php +0 -338
- pro/app/views/links/geo_row.php +0 -41
- pro/app/views/links/index.php +0 -2
- pro/app/views/links/javascript-redirect.php +0 -25
- pro/app/views/links/link-has-expired.php +0 -31
- pro/app/views/links/link-options.php +0 -84
- pro/app/views/links/metarefresh-redirect.php +0 -23
- pro/app/views/links/prettybar-redirect.php +0 -24
- pro/app/views/links/prettybar.php +0 -85
- pro/app/views/links/tech_row.php +0 -102
- pro/app/views/links/time_row.php +0 -54
- pro/app/views/options/autocreate.php +0 -73
- pro/app/views/options/form.php +0 -934
- pro/app/views/options/general.php +0 -66
- pro/app/views/options/index.php +0 -2
- pro/app/views/public/form.php +0 -48
- pro/app/views/public/index.php +0 -2
- pro/app/views/reports/custom-report.php +0 -74
- pro/app/views/reports/edit.php +0 -69
- pro/app/views/reports/index.php +0 -2
- pro/app/views/reports/list.php +0 -94
- pro/app/views/reports/new.php +0 -70
- pro/app/views/reports/reports.php +0 -9
- pro/app/views/reports/split-test-report.php +0 -69
- pro/app/views/tools/generator.php +0 -44
- pro/app/views/tools/index.php +0 -2
- pro/app/views/tools/nav.php +0 -4
- pro/app/widgets/PlpPublicLinksWidget.php +0 -105
- pro/app/widgets/index.php +0 -2
- pro/css/admin_bookmarklet.css +0 -11
- pro/css/admin_options.css +0 -26
- pro/css/admin_post.css +0 -1
- pro/css/admin_reports.css +0 -35
- pro/css/index.php +0 -2
- pro/css/jquery-ui-timepicker-addon.css +0 -30
- pro/css/prettybar.css +0 -96
- pro/css/prlipro-post.css +0 -5
- pro/i18n/countries.php +0 -249
- pro/images/dark_add_twitter_account.png +0 -0
- pro/images/download_qr_code_icon.gif +0 -0
- pro/images/index.php +0 -2
- pro/index.php +0 -2
- pro/js/admin_bookmarklet.js +0 -14
- pro/js/admin_draw_report.js +0 -25
- pro/js/admin_links.js +0 -110
- pro/js/admin_options.js +0 -7
- pro/js/admin_post.js +0 -24
- pro/js/admin_reports.js +0 -12
- pro/js/date_picker.js +0 -57
- pro/js/index.php +0 -2
- pro/js/javascript-redirect.js +0 -3
- pro/js/jquery-ui-timepicker-addon.js +0 -2291
- pro/pretty-link-pro.php +0 -99
- pro/vendor/index.php +0 -2
- pro/vendor/phpqrcode/.gitignore +0 -2
- pro/vendor/phpqrcode/CHANGELOG +0 -38
- pro/vendor/phpqrcode/INSTALL +0 -67
- pro/vendor/phpqrcode/LICENSE +0 -165
- pro/vendor/phpqrcode/README +0 -61
- pro/vendor/phpqrcode/VERSION +0 -2
- pro/vendor/phpqrcode/bindings/index.php +0 -2
- pro/vendor/phpqrcode/bindings/tcpdf/index.php +0 -2
- pro/vendor/phpqrcode/bindings/tcpdf/qrcode.php +0 -2875
- pro/vendor/phpqrcode/cache/frame_1.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_1.png +0 -0
- pro/vendor/phpqrcode/cache/frame_10.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_10.png +0 -0
- pro/vendor/phpqrcode/cache/frame_11.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_11.png +0 -0
- pro/vendor/phpqrcode/cache/frame_12.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_12.png +0 -0
- pro/vendor/phpqrcode/cache/frame_13.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_13.png +0 -0
- pro/vendor/phpqrcode/cache/frame_14.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_14.png +0 -0
- pro/vendor/phpqrcode/cache/frame_15.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_15.png +0 -0
- pro/vendor/phpqrcode/cache/frame_16.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_16.png +0 -0
- pro/vendor/phpqrcode/cache/frame_17.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_17.png +0 -0
- pro/vendor/phpqrcode/cache/frame_18.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_18.png +0 -0
- pro/vendor/phpqrcode/cache/frame_19.dat +0 -3
- pro/vendor/phpqrcode/cache/frame_19.png +0 -0
- pro/vendor/phpqrcode/cache/frame_2.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_2.png +0 -0
- pro/vendor/phpqrcode/cache/frame_20.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_20.png +0 -0
- pro/vendor/phpqrcode/cache/frame_21.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_21.png +0 -0
- pro/vendor/phpqrcode/cache/frame_22.dat +0 -3
- pro/vendor/phpqrcode/cache/frame_22.png +0 -0
- pro/vendor/phpqrcode/cache/frame_23.dat +0 -3
- pro/vendor/phpqrcode/cache/frame_23.png +0 -0
- pro/vendor/phpqrcode/cache/frame_24.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_24.png +0 -0
- pro/vendor/phpqrcode/cache/frame_25.dat +0 -3
- pro/vendor/phpqrcode/cache/frame_25.png +0 -0
- pro/vendor/phpqrcode/cache/frame_26.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_26.png +0 -0
- pro/vendor/phpqrcode/cache/frame_27.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_27.png +0 -0
- pro/vendor/phpqrcode/cache/frame_28.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_28.png +0 -0
- pro/vendor/phpqrcode/cache/frame_29.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_29.png +0 -0
- pro/vendor/phpqrcode/cache/frame_3.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_3.png +0 -0
- pro/vendor/phpqrcode/cache/frame_30.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_30.png +0 -0
- pro/vendor/phpqrcode/cache/frame_31.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_31.png +0 -0
- pro/vendor/phpqrcode/cache/frame_32.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_32.png +0 -0
- pro/vendor/phpqrcode/cache/frame_33.dat +0 -14
- pro/vendor/phpqrcode/cache/frame_33.png +0 -0
- pro/vendor/phpqrcode/cache/frame_34.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_34.png +0 -0
- pro/vendor/phpqrcode/cache/frame_35.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_35.png +0 -0
- pro/vendor/phpqrcode/cache/frame_36.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_36.png +0 -0
- pro/vendor/phpqrcode/cache/frame_37.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_37.png +0 -0
- pro/vendor/phpqrcode/cache/frame_38.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_38.png +0 -0
- pro/vendor/phpqrcode/cache/frame_39.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_39.png +0 -0
- pro/vendor/phpqrcode/cache/frame_4.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_4.png +0 -0
- pro/vendor/phpqrcode/cache/frame_40.dat +0 -2
- pro/vendor/phpqrcode/cache/frame_40.png +0 -0
- pro/vendor/phpqrcode/cache/frame_5.dat +0 -1
- pro/vendor/phpqrcode/cache/frame_5.png +0 -0
- pro/vendor/phpqrcode/cache/frame_6.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_6.png +0 -0
- pro/vendor/phpqrcode/cache/frame_7.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_7.png +0 -0
- pro/vendor/phpqrcode/cache/frame_8.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_8.png +0 -0
- pro/vendor/phpqrcode/cache/frame_9.dat +0 -0
- pro/vendor/phpqrcode/cache/frame_9.png +0 -0
- pro/vendor/phpqrcode/cache/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_0/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_101_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_105_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_109_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_113_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_117_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_121_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_125_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_129_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_133_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_137_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_141_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_145_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_149_0.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_0/mask_153_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_157_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_161_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_165_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_169_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_173_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_177_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_21_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_25_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_29_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_33_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_37_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_41_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_45_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_49_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_53_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_57_0.dat +0 -4
- pro/vendor/phpqrcode/cache/mask_0/mask_61_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_65_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_0/mask_69_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_73_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_77_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_81_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_85_0.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_0/mask_89_0.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_0/mask_93_0.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_0/mask_97_0.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_101_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_105_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_109_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_113_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_117_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_121_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_125_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_129_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_133_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_137_1.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_1/mask_141_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_145_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_149_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_153_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_157_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_161_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_165_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_169_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_173_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_177_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_21_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_25_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_29_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_33_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_37_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_41_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_45_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_49_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_53_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_57_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_61_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_65_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_69_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_73_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_77_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_81_1.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_1/mask_85_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_89_1.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_1/mask_93_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_1/mask_97_1.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_101_2.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_2/mask_105_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_109_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_113_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_117_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_121_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_125_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_129_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_133_2.dat +0 -10
- pro/vendor/phpqrcode/cache/mask_2/mask_137_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_141_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_145_2.dat +0 -4
- pro/vendor/phpqrcode/cache/mask_2/mask_149_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_153_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_157_2.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_2/mask_161_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_165_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_169_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_173_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_177_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_21_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_25_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_29_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_33_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_37_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_41_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_45_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_49_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_53_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_57_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_61_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_65_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_69_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_73_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_77_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_81_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_85_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_2/mask_89_2.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_2/mask_93_2.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_2/mask_97_2.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_101_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_105_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_109_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_113_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_117_3.dat +0 -4
- pro/vendor/phpqrcode/cache/mask_3/mask_121_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_125_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_129_3.dat +0 -8
- pro/vendor/phpqrcode/cache/mask_3/mask_133_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_137_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_141_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_145_3.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_3/mask_149_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_153_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_157_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_161_3.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_3/mask_165_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_169_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_173_3.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_3/mask_177_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_21_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_25_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_29_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_33_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_37_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_41_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_45_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_49_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_53_3.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_3/mask_57_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_61_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_65_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_69_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_73_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_77_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_81_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_85_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_3/mask_89_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_93_3.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_3/mask_97_3.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_101_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_105_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_109_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_113_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_117_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_121_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_125_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_129_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_133_4.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_4/mask_137_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_141_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_145_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_149_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_153_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_157_4.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_4/mask_161_4.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_4/mask_165_4.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_4/mask_169_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_173_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_177_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_21_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_25_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_29_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_33_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_37_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_41_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_45_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_49_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_53_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_57_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_61_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_65_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_69_4.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_4/mask_73_4.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_4/mask_77_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_81_4.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_4/mask_85_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_4/mask_89_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_93_4.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_4/mask_97_4.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_101_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_105_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_109_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_113_5.dat +0 -9
- pro/vendor/phpqrcode/cache/mask_5/mask_117_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_121_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_125_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_129_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_133_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_137_5.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_5/mask_141_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_145_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_149_5.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_5/mask_153_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_157_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_161_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_165_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_169_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_173_5.dat +0 -4
- pro/vendor/phpqrcode/cache/mask_5/mask_177_5.dat +0 -11
- pro/vendor/phpqrcode/cache/mask_5/mask_21_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_25_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_29_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_33_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_37_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_41_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_45_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_49_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_53_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_57_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_61_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_65_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_69_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_73_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_77_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_5/mask_81_5.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_5/mask_85_5.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_5/mask_89_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_93_5.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_5/mask_97_5.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_101_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_105_6.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_6/mask_109_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_113_6.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_6/mask_117_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_121_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_125_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_129_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_133_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_137_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_141_6.dat +0 -10
- pro/vendor/phpqrcode/cache/mask_6/mask_145_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_149_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_153_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_157_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_161_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_165_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_169_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_173_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_177_6.dat +0 -14
- pro/vendor/phpqrcode/cache/mask_6/mask_21_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_25_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_29_6.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_6/mask_33_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_37_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_41_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_45_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_49_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_53_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_57_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_61_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_6/mask_65_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_69_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_73_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_77_6.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_6/mask_81_6.dat +0 -3
- pro/vendor/phpqrcode/cache/mask_6/mask_85_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_89_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_93_6.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_6/mask_97_6.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/index.php +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_101_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_105_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_109_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_113_7.dat +0 -11
- pro/vendor/phpqrcode/cache/mask_7/mask_117_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_121_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_125_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_129_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_133_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_137_7.dat +0 -5
- pro/vendor/phpqrcode/cache/mask_7/mask_141_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_145_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_149_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_153_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_157_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_161_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_165_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_169_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_173_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_177_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_21_7.dat +0 -4
- pro/vendor/phpqrcode/cache/mask_7/mask_25_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_29_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_33_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_37_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_41_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_45_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_49_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_53_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_57_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_61_7.dat +0 -2
- pro/vendor/phpqrcode/cache/mask_7/mask_65_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_69_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_73_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_77_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_81_7.dat +0 -1
- pro/vendor/phpqrcode/cache/mask_7/mask_85_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_89_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_93_7.dat +0 -0
- pro/vendor/phpqrcode/cache/mask_7/mask_97_7.dat +0 -2
- pro/vendor/phpqrcode/index.php +0 -94
- pro/vendor/phpqrcode/phpqrcode.php +0 -3609
- pro/vendor/phpqrcode/qrbitstream.php +0 -180
- pro/vendor/phpqrcode/qrconfig.php +0 -17
- pro/vendor/phpqrcode/qrconst.php +0 -54
- pro/vendor/phpqrcode/qrencode.php +0 -569
- pro/vendor/phpqrcode/qrimage.php +0 -107
- pro/vendor/phpqrcode/qrinput.php +0 -729
- pro/vendor/phpqrcode/qrlib.php +0 -44
- pro/vendor/phpqrcode/qrmask.php +0 -328
- pro/vendor/phpqrcode/qrrscode.php +0 -210
- pro/vendor/phpqrcode/qrspec.php +0 -592
- pro/vendor/phpqrcode/qrsplit.php +0 -213
.distignore
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
.gitignore
|
2 |
-
.distignore
|
3 |
-
/pro
|
4 |
-
/assets
|
5 |
-
/tests
|
6 |
-
/node_modules
|
7 |
-
^test.*
|
8 |
-
^phpunit.*
|
9 |
-
^README
|
10 |
-
^script/.*
|
11 |
-
^script
|
12 |
-
^composer.json
|
13 |
-
^phpcs.ruleset.xml
|
14 |
-
^\.travis.yml
|
15 |
-
^\.phpcs.xml.dist
|
16 |
-
^webpack.config.js
|
17 |
-
^package.*
|
18 |
-
^phpunit.*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.github/workflows/main.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
name: Deploy to WordPress.org
|
2 |
-
on:
|
3 |
-
push:
|
4 |
-
tags:
|
5 |
-
- "*"
|
6 |
-
jobs:
|
7 |
-
tag:
|
8 |
-
name: New tag
|
9 |
-
runs-on: ubuntu-latest
|
10 |
-
steps:
|
11 |
-
- uses: actions/checkout@master
|
12 |
-
- name: WordPress Plugin Deploy
|
13 |
-
uses: 10up/action-wordpress-plugin-deploy@stable
|
14 |
-
env:
|
15 |
-
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
|
16 |
-
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
|
17 |
-
SLUG: pretty-link # optional, remove if GitHub repo name matches SVN slug, including capitalization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
script/
|
2 |
-
node_modules/
|
|
|
|
.phpcs.xml.dist
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<ruleset name="WordPress Coding Standards based custom ruleset for your plugin">
|
3 |
-
<description>Generally-applicable sniffs for WordPress plugins.</description>
|
4 |
-
|
5 |
-
<!-- What to scan -->
|
6 |
-
<file>.</file>
|
7 |
-
<exclude-pattern>/vendor/</exclude-pattern>
|
8 |
-
<exclude-pattern>/node_modules/</exclude-pattern>
|
9 |
-
|
10 |
-
<!-- How to scan -->
|
11 |
-
<!-- Usage instructions: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
|
12 |
-
<!-- Annotated ruleset: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
|
13 |
-
<arg value="sp"/> <!-- Show sniff and progress -->
|
14 |
-
<arg name="basepath" value="./"/><!-- Strip the file paths down to the relevant bit -->
|
15 |
-
<arg name="colors"/>
|
16 |
-
<arg name="extensions" value="php"/>
|
17 |
-
<arg name="parallel" value="8"/><!-- Enables parallel processing when available for faster results. -->
|
18 |
-
|
19 |
-
<!-- Rules: Check PHP version compatibility -->
|
20 |
-
<!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
|
21 |
-
<config name="testVersion" value="5.3-"/>
|
22 |
-
<!-- https://github.com/PHPCompatibility/PHPCompatibilityWP -->
|
23 |
-
<rule ref="PHPCompatibilityWP"/>
|
24 |
-
|
25 |
-
<!-- Rules: WordPress Coding Standards -->
|
26 |
-
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
|
27 |
-
<!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
|
28 |
-
<config name="minimum_supported_wp_version" value="4.6"/>
|
29 |
-
<rule ref="WordPress">
|
30 |
-
<exclude name="WordPress.VIP"/>
|
31 |
-
</rule>
|
32 |
-
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
|
33 |
-
<properties>
|
34 |
-
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
|
35 |
-
<property name="prefixes" type="array" value="my-plugin"/>
|
36 |
-
</properties>
|
37 |
-
</rule>
|
38 |
-
<rule ref="WordPress.WP.I18n">
|
39 |
-
<properties>
|
40 |
-
<!-- Value: replace the text domain used. -->
|
41 |
-
<property name="text_domain" type="array" value="my-plugin"/>
|
42 |
-
</properties>
|
43 |
-
</rule>
|
44 |
-
<rule ref="WordPress.WhiteSpace.ControlStructureSpacing">
|
45 |
-
<properties>
|
46 |
-
<property name="blank_line_check" value="true"/>
|
47 |
-
</properties>
|
48 |
-
</rule>
|
49 |
-
</ruleset>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.travis.yml
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
sudo: false
|
2 |
-
dist: trusty
|
3 |
-
|
4 |
-
language: php
|
5 |
-
|
6 |
-
notifications:
|
7 |
-
email:
|
8 |
-
on_success: never
|
9 |
-
on_failure: change
|
10 |
-
|
11 |
-
branches:
|
12 |
-
only:
|
13 |
-
- master
|
14 |
-
|
15 |
-
cache:
|
16 |
-
directories:
|
17 |
-
- $HOME/.composer/cache
|
18 |
-
|
19 |
-
matrix:
|
20 |
-
include:
|
21 |
-
- php: 7.2
|
22 |
-
env: WP_VERSION=latest
|
23 |
-
- php: 7.1
|
24 |
-
env: WP_VERSION=latest
|
25 |
-
- php: 7.0
|
26 |
-
env: WP_VERSION=latest
|
27 |
-
- php: 5.6
|
28 |
-
env: WP_VERSION=4.9
|
29 |
-
- php: 5.6
|
30 |
-
env: WP_VERSION=latest
|
31 |
-
- php: 5.6
|
32 |
-
env: WP_VERSION=trunk
|
33 |
-
- php: 5.6
|
34 |
-
env: WP_TRAVISCI=phpcs
|
35 |
-
- php: 5.3
|
36 |
-
env: WP_VERSION=latest
|
37 |
-
dist: precise
|
38 |
-
|
39 |
-
before_script:
|
40 |
-
- export PATH="$HOME/.composer/vendor/bin:$PATH"
|
41 |
-
- |
|
42 |
-
if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then
|
43 |
-
phpenv config-rm xdebug.ini
|
44 |
-
else
|
45 |
-
echo "xdebug.ini does not exist"
|
46 |
-
fi
|
47 |
-
- |
|
48 |
-
if [[ ! -z "$WP_VERSION" ]] ; then
|
49 |
-
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
50 |
-
composer global require "phpunit/phpunit=4.8.*|5.7.*"
|
51 |
-
fi
|
52 |
-
- |
|
53 |
-
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
54 |
-
composer global require wp-coding-standards/wpcs
|
55 |
-
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs
|
56 |
-
fi
|
57 |
-
|
58 |
-
script:
|
59 |
-
- |
|
60 |
-
if [[ ! -z "$WP_VERSION" ]] ; then
|
61 |
-
phpunit
|
62 |
-
WP_MULTISITE=1 phpunit
|
63 |
-
fi
|
64 |
-
- |
|
65 |
-
if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then
|
66 |
-
phpcs
|
67 |
-
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.wordpress-org/banner-1544x500.png
DELETED
Binary file
|
.wordpress-org/banner-772x250.png
DELETED
Binary file
|
.wordpress-org/icon-128x128.png
DELETED
Binary file
|
.wordpress-org/icon-256x256.png
DELETED
Binary file
|
README
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
To install i18n pre-commit hook issue this command:
|
2 |
-
|
3 |
-
```
|
4 |
-
ln -s ../../script/mki18n .git/hooks/pre-commit
|
5 |
-
```
|
|
|
|
|
|
|
|
|
|
i18n/pretty-link.pot
CHANGED
@@ -2,14 +2,14 @@
|
|
2 |
# This file is distributed under the same license as the Pretty Links plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Pretty Links 3.2.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pretty-link\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"POT-Creation-Date: 2021-03-
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: pretty-link\n"
|
2 |
# This file is distributed under the same license as the Pretty Links plugin.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Pretty Links 3.2.3\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/pretty-link\n"
|
7 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
8 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=UTF-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"POT-Creation-Date: 2021-03-25T17:28:19+00:00\n"
|
13 |
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
14 |
"X-Generator: WP-CLI 2.4.0\n"
|
15 |
"X-Domain: pretty-link\n"
|
images/not_tracking.png
CHANGED
File without changes
|
package.json
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "pretty-link",
|
3 |
-
"version": "2.1.9",
|
4 |
-
"description": "Shrink, track and share any URL on the Internet from your WordPress website!",
|
5 |
-
"main": "index.js",
|
6 |
-
"directories": {
|
7 |
-
"test": "tests"
|
8 |
-
},
|
9 |
-
"scripts": {
|
10 |
-
"build": "wp-scripts build",
|
11 |
-
"start": "wp-scripts start"
|
12 |
-
},
|
13 |
-
"repository": {
|
14 |
-
"type": "git",
|
15 |
-
"url": "git+https://github.com/caseproof/pretty-link.git"
|
16 |
-
},
|
17 |
-
"keywords": [],
|
18 |
-
"author": "Caseproof, LLC",
|
19 |
-
"license": "GPLv2",
|
20 |
-
"devDependencies": {
|
21 |
-
"@wordpress/scripts": "^3.2.1",
|
22 |
-
"classnames": "^2.2.6",
|
23 |
-
"css-loader": "^2.1.1",
|
24 |
-
"node-sass": "^4.12.0",
|
25 |
-
"postcss-loader": "^3.0.0",
|
26 |
-
"sass-loader": "^7.1.0",
|
27 |
-
"style-loader": "^0.23.1"
|
28 |
-
},
|
29 |
-
"bugs": {
|
30 |
-
"url": "https://github.com/caseproof/pretty-link/issues"
|
31 |
-
},
|
32 |
-
"homepage": "https://github.com/caseproof/pretty-link#readme",
|
33 |
-
"dependencies": {
|
34 |
-
"dom-scroll-into-view": "^1.2.1",
|
35 |
-
"lodash": "^4.17.11"
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
phpunit.xml.dist
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<phpunit
|
3 |
-
bootstrap="tests/bootstrap.php"
|
4 |
-
backupGlobals="false"
|
5 |
-
colors="true"
|
6 |
-
convertErrorsToExceptions="true"
|
7 |
-
convertNoticesToExceptions="true"
|
8 |
-
convertWarningsToExceptions="true"
|
9 |
-
>
|
10 |
-
<testsuites>
|
11 |
-
<testsuite name="tests">
|
12 |
-
<directory prefix="Test" suffix=".php">./tests/</directory>
|
13 |
-
</testsuite>
|
14 |
-
</testsuites>
|
15 |
-
</phpunit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pretty-link.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Pretty Links
|
4 |
Plugin URI: https://prettylinks.com/pl/plugin-uri
|
5 |
Description: Shrink, track and share any URL using your website and brand!
|
6 |
-
Version: 3.2.
|
7 |
Author: Pretty Links
|
8 |
Author URI: http://prettylinks.com
|
9 |
Text Domain: pretty-link
|
3 |
Plugin Name: Pretty Links
|
4 |
Plugin URI: https://prettylinks.com/pl/plugin-uri
|
5 |
Description: Shrink, track and share any URL using your website and brand!
|
6 |
+
Version: 3.2.3
|
7 |
Author: Pretty Links
|
8 |
Author URI: http://prettylinks.com
|
9 |
Text Domain: pretty-link
|
pro/README
DELETED
File without changes
|
pro/app/controllers/PlpAppController.php
DELETED
@@ -1,179 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpAppController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action('admin_menu', array($this, 'admin_menu'));
|
6 |
-
add_action('prli_load_admin_scripts', array($this, 'enqueue_admin_scripts'), 10, 2);
|
7 |
-
add_action('init', array($this,'route_standalone_request'));
|
8 |
-
}
|
9 |
-
|
10 |
-
public function admin_menu() {
|
11 |
-
global $plp_options;
|
12 |
-
|
13 |
-
$role = 'administrator';
|
14 |
-
|
15 |
-
if(isset($plp_options->min_role)) {
|
16 |
-
$role = $plp_options->min_role;
|
17 |
-
}
|
18 |
-
|
19 |
-
do_action('plp_admin_menu', $role);
|
20 |
-
}
|
21 |
-
|
22 |
-
public function enqueue_admin_scripts($hook, $page_vars) {
|
23 |
-
global $prli_link, $prli_options, $prli_link_meta, $current_screen;
|
24 |
-
|
25 |
-
extract($page_vars);
|
26 |
-
|
27 |
-
if( preg_match('/_page_plp-reports$/', $hook) ) {
|
28 |
-
wp_enqueue_style('plp-reports', PLP_CSS_URL.'/admin_reports.css', null, PRLI_VERSION);
|
29 |
-
wp_register_script('plp-google-vis', 'https://www.gstatic.com/charts/loader.js', array(), PRLI_VERSION);
|
30 |
-
|
31 |
-
// TODO: We actually want localize script for the data and separate js files for these
|
32 |
-
if(isset($_GET['action']) && $_GET['action'] == 'display-custom-report') {
|
33 |
-
global $plp_report;
|
34 |
-
wp_enqueue_script('plp-draw-report', PLP_JS_URL.'/admin_draw_report.js', array('jquery','plp-google-vis'), PRLI_VERSION);
|
35 |
-
wp_localize_script('plp-draw-report', 'PlpReport', $plp_report->custom_report_vars());
|
36 |
-
}
|
37 |
-
else if(isset($_GET['action']) && $_GET['action'] == 'display-split-test-report') {
|
38 |
-
global $plp_report;
|
39 |
-
wp_enqueue_script('plp-draw-report', PLP_JS_URL.'/admin_draw_report.js', array('jquery','plp-google-vis'), PRLI_VERSION);
|
40 |
-
wp_localize_script('plp-draw-report', 'PlpReport', $plp_report->split_test_report_vars());
|
41 |
-
}
|
42 |
-
else {
|
43 |
-
wp_enqueue_script('plp-reports', PLP_JS_URL.'/admin_reports.js', array('jquery'), PRLI_VERSION);
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
if( preg_match('/_page_pretty-link-options$/', $hook) ) {
|
48 |
-
wp_register_style('plp-spectrum', PLP_VENDOR_URL.'/spectrum/spectrum.min.css', array(), '1.8.0');
|
49 |
-
wp_register_script('plp-spectrum', PLP_VENDOR_URL.'/spectrum/spectrum.min.js', array(), '1.8.0', true);
|
50 |
-
|
51 |
-
wp_enqueue_style('plp-options', PLP_CSS_URL.'/admin_options.css', array('pl-options','plp-spectrum'), PRLI_VERSION);
|
52 |
-
wp_enqueue_script('plp-options', PLP_JS_URL.'/admin_options.js', array('jquery','pl-options','plp-spectrum'), PRLI_VERSION);
|
53 |
-
}
|
54 |
-
|
55 |
-
if( preg_match('/_page_pretty-link-tools$/', $hook) ) {
|
56 |
-
wp_enqueue_style('plp-bookmarklet', PLP_CSS_URL.'/admin_bookmarklet.css', null, PRLI_VERSION);
|
57 |
-
wp_enqueue_script('plp-bookmarklet', PLP_JS_URL.'/admin_bookmarklet.js', array('jquery'), PRLI_VERSION);
|
58 |
-
wp_localize_script('plp-bookmarklet', 'PlpBookmarklet', array( 'url' => site_url("index.php?action=prli_bookmarklet&k={$prli_options->bookmarklet_auth}") ));
|
59 |
-
}
|
60 |
-
|
61 |
-
if( in_array( $hook, array('post-new.php','post.php') ) ) {
|
62 |
-
global $post;
|
63 |
-
wp_enqueue_style('plp-post', PLP_CSS_URL.'/admin_post.css', null, PRLI_VERSION);
|
64 |
-
wp_enqueue_script('plp-post', PLP_JS_URL.'/admin_post.js', array('jquery'), PRLI_VERSION);
|
65 |
-
wp_localize_script('plp-post', 'PlpPost', array( 'post_id' => $post->ID ));
|
66 |
-
}
|
67 |
-
|
68 |
-
if( $is_link_edit_page || $is_link_new_page ) {
|
69 |
-
global $post;
|
70 |
-
|
71 |
-
wp_enqueue_style('jquery-ui-timepicker-addon', PLP_CSS_URL.'/jquery-ui-timepicker-addon.css', array('pl-ui-smoothness'), PRLI_VERSION);
|
72 |
-
|
73 |
-
wp_register_script('plp-timepicker-js', PLP_JS_URL.'/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker'));
|
74 |
-
wp_register_script('plp-datepicker', PLP_JS_URL.'/date_picker.js', array('plp-timepicker-js'), PRLI_VERSION);
|
75 |
-
|
76 |
-
ob_start();
|
77 |
-
PlpLinksHelper::rotation_row('',0);
|
78 |
-
$rotation_row_html = ob_get_clean();
|
79 |
-
|
80 |
-
ob_start();
|
81 |
-
PlpLinksHelper::geo_row();
|
82 |
-
$geo_row_html = ob_get_clean();
|
83 |
-
|
84 |
-
ob_start();
|
85 |
-
PlpLinksHelper::tech_row();
|
86 |
-
$tech_row_html = ob_get_clean();
|
87 |
-
|
88 |
-
ob_start();
|
89 |
-
PlpLinksHelper::time_row();
|
90 |
-
$time_row_html = ob_get_clean();
|
91 |
-
|
92 |
-
$link_id = 0;
|
93 |
-
if(isset($post) && isset($post->ID)) {
|
94 |
-
$link_id = $prli_link->get_link_from_cpt($post->ID);
|
95 |
-
}
|
96 |
-
|
97 |
-
if(!empty($link_id) &&
|
98 |
-
empty($_POST['prli_geo_url']) &&
|
99 |
-
empty($_POST['prli_geo_countries'])) {
|
100 |
-
$geo_url = $prli_link_meta->get_link_meta($link_id, 'geo_url');
|
101 |
-
$geo_countries = $prli_link_meta->get_link_meta($link_id, 'geo_countries');
|
102 |
-
}
|
103 |
-
else {
|
104 |
-
$geo_url = isset($_POST['prli_geo_url']) && is_array($_POST['prli_geo_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_geo_url']))) : array();
|
105 |
-
$geo_countries = isset($_POST['prli_geo_countries']) && is_array($_POST['prli_geo_countries']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_geo_countries'])) : array();
|
106 |
-
}
|
107 |
-
|
108 |
-
if(!empty($link_id) && empty($_POST['prli_tech_url']) &&
|
109 |
-
empty($_POST['prli_tech_device']) &&
|
110 |
-
empty($_POST['prli_tech_os']) &&
|
111 |
-
empty($_POST['prli_tech_browser'])) {
|
112 |
-
$tech_url = $prli_link_meta->get_link_meta($link_id, 'tech_url');
|
113 |
-
$tech_device = $prli_link_meta->get_link_meta($link_id, 'tech_device');
|
114 |
-
$tech_os = $prli_link_meta->get_link_meta($link_id, 'tech_os');
|
115 |
-
$tech_browser = $prli_link_meta->get_link_meta($link_id, 'tech_browser');
|
116 |
-
}
|
117 |
-
else {
|
118 |
-
$tech_url = isset($_POST['prli_tech_url']) && is_array($_POST['prli_tech_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_tech_url']))) : array();
|
119 |
-
$tech_device = isset($_POST['prli_tech_device']) && is_array($_POST['prli_tech_device']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_device'])) : array();
|
120 |
-
$tech_os = isset($_POST['prli_tech_os']) && is_array($_POST['prli_tech_os']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_os'])) : array();
|
121 |
-
$tech_browser = isset($_POST['prli_tech_browser']) && is_array($_POST['prli_tech_browser']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_browser'])) : array();
|
122 |
-
}
|
123 |
-
|
124 |
-
if(!empty($link_id) && empty($_POST['prli_time_url']) &&
|
125 |
-
empty($_POST['prli_time_start']) &&
|
126 |
-
empty($_POST['prli_time_end'])) {
|
127 |
-
$time_url = $prli_link_meta->get_link_meta($link_id, 'time_url');
|
128 |
-
$time_start = $prli_link_meta->get_link_meta($link_id, 'time_start');
|
129 |
-
$time_end = $prli_link_meta->get_link_meta($link_id, 'time_end');
|
130 |
-
}
|
131 |
-
else {
|
132 |
-
$time_url = isset($_POST['prli_time_url']) && is_array($_POST['prli_time_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_time_url']))) : array();
|
133 |
-
$time_start = isset($_POST['prli_time_start']) && is_array($_POST['prli_time_start']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_time_start'])) : array();
|
134 |
-
$time_end = isset($_POST['prli_time_end']) && is_array($_POST['prli_time_end']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_time_end'])) : array();
|
135 |
-
}
|
136 |
-
|
137 |
-
wp_enqueue_script('plp-admin-links', PLP_JS_URL.'/admin_links.js', array('jquery','prli-admin-links','suggest','plp-datepicker'), PRLI_VERSION);
|
138 |
-
wp_localize_script('plp-admin-links', 'PlpLink', array(
|
139 |
-
'l10n_print_after' => 'PlpLink = ' . wp_json_encode(compact('rotation_row_html','geo_row_html','geo_url','geo_countries','tech_row_html','tech_url','tech_device','tech_os','tech_browser','time_row_html','time_url','time_start','time_end'))
|
140 |
-
));
|
141 |
-
}
|
142 |
-
}
|
143 |
-
|
144 |
-
public function route_standalone_request() {
|
145 |
-
$plugin = (isset($_REQUEST['plugin'])?sanitize_key(stripslashes($_REQUEST['plugin'])):'');
|
146 |
-
$controller = (isset($_REQUEST['controller'])?sanitize_key(stripslashes($_REQUEST['controller'])):'');
|
147 |
-
$action = (isset($_REQUEST['action'])?sanitize_key(stripslashes($_REQUEST['action'])):'');
|
148 |
-
|
149 |
-
if( $plugin && $plugin=='pretty-link-pro' && $controller && $action ) {
|
150 |
-
if($controller && $controller=='links') {
|
151 |
-
if($action && $action=='prettybar') {
|
152 |
-
PlpPrettyBarHelper::render_prettybar(sanitize_text_field(stripslashes($_REQUEST['s'])));
|
153 |
-
}
|
154 |
-
}
|
155 |
-
exit;
|
156 |
-
}
|
157 |
-
else if( $action == 'prli_endpoint_url' ) {
|
158 |
-
global $prli_options;
|
159 |
-
|
160 |
-
$key = sanitize_key(stripslashes($_REQUEST['k']));
|
161 |
-
$url = esc_url_raw(trim(stripslashes($_REQUEST['url'])));
|
162 |
-
|
163 |
-
if($key == $prli_options->bookmarklet_auth) {
|
164 |
-
$pretty_link_id = prli_create_pretty_link( $url );
|
165 |
-
if( $pretty_link = prli_get_pretty_link_url( $pretty_link_id ) ) {
|
166 |
-
echo esc_url($pretty_link);
|
167 |
-
}
|
168 |
-
else {
|
169 |
-
esc_html_e('ERROR: Your Pretty Link was unable to be created', 'pretty-link');
|
170 |
-
}
|
171 |
-
}
|
172 |
-
else {
|
173 |
-
esc_html_e('Unauthorized', 'pretty-link');
|
174 |
-
}
|
175 |
-
|
176 |
-
exit;
|
177 |
-
}
|
178 |
-
}
|
179 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpDbController.php
DELETED
@@ -1,282 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpDbController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action('init', array($this,'install'), 11);
|
6 |
-
}
|
7 |
-
|
8 |
-
public function install() {
|
9 |
-
if($this->should_install_pro_db()) {
|
10 |
-
// For some reason, install gets called multiple times so we're basically
|
11 |
-
// adding a mutex here (ala a transient) to ensure this only gets run once
|
12 |
-
$is_installing = get_transient('plp_installing');
|
13 |
-
if($is_installing) {
|
14 |
-
return;
|
15 |
-
}
|
16 |
-
else {
|
17 |
-
// 30 minutes
|
18 |
-
set_transient('plp_installing', 1, 60*30);
|
19 |
-
}
|
20 |
-
|
21 |
-
@ignore_user_abort(true);
|
22 |
-
@set_time_limit(0);
|
23 |
-
$this->install_pro_db();
|
24 |
-
|
25 |
-
delete_transient('plp_installing');
|
26 |
-
}
|
27 |
-
}
|
28 |
-
|
29 |
-
public function should_install_pro_db() {
|
30 |
-
global $plp_db_version;
|
31 |
-
$old_pro_db_version = get_option('prlipro_db_version');
|
32 |
-
|
33 |
-
if($plp_db_version != $old_pro_db_version) { return true; }
|
34 |
-
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
|
38 |
-
public function install_pro_db() {
|
39 |
-
global $wpdb, $plp_db_version;
|
40 |
-
|
41 |
-
$upgrade_path = ABSPATH . 'wp-admin/includes/upgrade.php';
|
42 |
-
require_once($upgrade_path);
|
43 |
-
|
44 |
-
// Pretty Links Pro Tables
|
45 |
-
$keywords_table = "{$wpdb->prefix}prli_keywords";
|
46 |
-
$post_keywords_table = "{$wpdb->prefix}prli_post_keywords";
|
47 |
-
$post_urls_table = "{$wpdb->prefix}prli_post_urls";
|
48 |
-
$reports_table = "{$wpdb->prefix}prli_reports";
|
49 |
-
$report_links_table = "{$wpdb->prefix}prli_report_links";
|
50 |
-
$link_rotations_table = "{$wpdb->prefix}prli_link_rotations";
|
51 |
-
$clicks_rotations_table = "{$wpdb->prefix}prli_clicks_rotations";
|
52 |
-
|
53 |
-
// This was introduced in WordPress 3.5
|
54 |
-
// $char_col = $wpdb->get_charset_collate(); //This doesn't work for most non english setups
|
55 |
-
$char_col = "";
|
56 |
-
$collation = $wpdb->get_row("SHOW FULL COLUMNS FROM {$wpdb->posts} WHERE field = 'post_content'");
|
57 |
-
|
58 |
-
if(isset($collation->Collation)) {
|
59 |
-
$charset = explode('_', $collation->Collation);
|
60 |
-
|
61 |
-
if(is_array($charset) && count($charset) > 1) {
|
62 |
-
$charset = $charset[0]; //Get the charset from the collation
|
63 |
-
$char_col = "DEFAULT CHARACTER SET {$charset} COLLATE {$collation->Collation}";
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
//Fine we'll try it your way this time
|
68 |
-
if(empty($char_col)) { $char_col = $wpdb->get_charset_collate(); }
|
69 |
-
|
70 |
-
//Fix for large indexes
|
71 |
-
//$wpdb->query("SET GLOBAL innodb_large_prefix=1");
|
72 |
-
|
73 |
-
/* Create/Upgrade Keywords Table */
|
74 |
-
$sql = "
|
75 |
-
CREATE TABLE {$keywords_table} (
|
76 |
-
id int(11) NOT NULL auto_increment,
|
77 |
-
text varchar(255) NOT NULL,
|
78 |
-
link_id int(11) NOT NULL,
|
79 |
-
created_at datetime NOT NULL,
|
80 |
-
PRIMARY KEY (id),
|
81 |
-
KEY link_id (link_id),
|
82 |
-
KEY text (text(191))
|
83 |
-
) {$char_col};
|
84 |
-
";
|
85 |
-
|
86 |
-
dbDelta($sql);
|
87 |
-
|
88 |
-
/* Create/Upgrade Keywords Table */
|
89 |
-
$sql = "
|
90 |
-
CREATE TABLE {$post_keywords_table} (
|
91 |
-
id int(11) NOT NULL auto_increment,
|
92 |
-
keyword_id int(11) NOT NULL,
|
93 |
-
post_id int(11) NOT NULL,
|
94 |
-
PRIMARY KEY (id),
|
95 |
-
KEY keyword_id (keyword_id),
|
96 |
-
KEY post_id (post_id),
|
97 |
-
UNIQUE KEY post_keyword_index (keyword_id,post_id)
|
98 |
-
) {$char_col};
|
99 |
-
";
|
100 |
-
|
101 |
-
dbDelta($sql);
|
102 |
-
|
103 |
-
/* Create/Upgrade URLs Table */
|
104 |
-
$sql = "
|
105 |
-
CREATE TABLE {$post_urls_table} (
|
106 |
-
id int(11) NOT NULL auto_increment,
|
107 |
-
url_id int(11) NOT NULL,
|
108 |
-
post_id int(11) NOT NULL,
|
109 |
-
PRIMARY KEY (id),
|
110 |
-
KEY url_id (url_id),
|
111 |
-
KEY post_id (post_id),
|
112 |
-
UNIQUE KEY post_url_index (url_id,post_id)
|
113 |
-
) {$char_col};
|
114 |
-
";
|
115 |
-
|
116 |
-
dbDelta($sql);
|
117 |
-
|
118 |
-
/* Create/Upgrade Reports Table */
|
119 |
-
$sql = "
|
120 |
-
CREATE TABLE {$reports_table} (
|
121 |
-
id int(11) NOT NULL auto_increment,
|
122 |
-
name varchar(255) NOT NULL,
|
123 |
-
goal_link_id int(11) default NULL,
|
124 |
-
created_at datetime NOT NULL,
|
125 |
-
PRIMARY KEY (id),
|
126 |
-
KEY goal_link_id (goal_link_id),
|
127 |
-
KEY name (name(191))
|
128 |
-
) {$char_col};
|
129 |
-
";
|
130 |
-
|
131 |
-
dbDelta($sql);
|
132 |
-
|
133 |
-
/* Create/Upgrade Reports Table */
|
134 |
-
$sql = "
|
135 |
-
CREATE TABLE {$report_links_table} (
|
136 |
-
id int(11) NOT NULL auto_increment,
|
137 |
-
report_id int(11) NOT NULL,
|
138 |
-
link_id int(11) NOT NULL,
|
139 |
-
created_at datetime NOT NULL,
|
140 |
-
PRIMARY KEY (id),
|
141 |
-
KEY report_id (report_id),
|
142 |
-
KEY link_id (link_id)
|
143 |
-
) {$char_col};
|
144 |
-
";
|
145 |
-
|
146 |
-
dbDelta($sql);
|
147 |
-
|
148 |
-
/* Create/Upgrade Link Rotations Table */
|
149 |
-
$sql = "
|
150 |
-
CREATE TABLE {$link_rotations_table} (
|
151 |
-
id int(11) NOT NULL auto_increment,
|
152 |
-
url varchar(255) default NULL,
|
153 |
-
weight int(11) default 0,
|
154 |
-
r_index int(11) default 0,
|
155 |
-
link_id int(11) NOT NULL,
|
156 |
-
created_at datetime NOT NULL,
|
157 |
-
PRIMARY KEY (id),
|
158 |
-
KEY link_id (link_id),
|
159 |
-
KEY url (url(191)),
|
160 |
-
KEY weight (weight),
|
161 |
-
KEY r_index (r_index)
|
162 |
-
) {$char_col};
|
163 |
-
";
|
164 |
-
|
165 |
-
dbDelta($sql);
|
166 |
-
|
167 |
-
/* Create/Upgrade Clicks / Rotations Table */
|
168 |
-
$sql = "
|
169 |
-
CREATE TABLE {$clicks_rotations_table} (
|
170 |
-
id int(11) NOT NULL auto_increment,
|
171 |
-
click_id int(11) NOT NULL,
|
172 |
-
link_id int(11) NOT NULL,
|
173 |
-
url text NOT NULL,
|
174 |
-
PRIMARY KEY (id),
|
175 |
-
KEY click_id (click_id),
|
176 |
-
KEY link_id (link_id)
|
177 |
-
) {$char_col};
|
178 |
-
";
|
179 |
-
|
180 |
-
dbDelta($sql);
|
181 |
-
|
182 |
-
$this->migrate_after_db_upgrade($plp_db_version);
|
183 |
-
|
184 |
-
/***** SAVE DB VERSION *****/
|
185 |
-
update_option('prlipro_db_version', $plp_db_version);
|
186 |
-
wp_cache_delete('alloptions', 'options');
|
187 |
-
}
|
188 |
-
|
189 |
-
public function migrate_after_db_upgrade($db_version) {
|
190 |
-
global $wpdb;
|
191 |
-
|
192 |
-
$prli_db = new PrliDb();
|
193 |
-
|
194 |
-
$group_table = "{$wpdb->prefix}prli_groups";
|
195 |
-
if(get_option('prlipro_db_version') <= 10 && $prli_db->table_exists($group_table)) {
|
196 |
-
$ctax = PlpLinkCategoriesController::$ctax;
|
197 |
-
$group_category_map = array();
|
198 |
-
|
199 |
-
$q = "SELECT * FROM {$group_table}";
|
200 |
-
$groups = $wpdb->get_results($q);
|
201 |
-
|
202 |
-
// for each group
|
203 |
-
foreach($groups as $group) {
|
204 |
-
|
205 |
-
// Skip this group if term already exists
|
206 |
-
if (term_exists($group->name, $ctax)) {
|
207 |
-
continue;
|
208 |
-
}
|
209 |
-
|
210 |
-
// - Add group as category
|
211 |
-
$term = wp_insert_term(
|
212 |
-
$group->name,
|
213 |
-
$ctax,
|
214 |
-
array( 'description' => $group->description )
|
215 |
-
);
|
216 |
-
|
217 |
-
if(is_wp_error($term)) {
|
218 |
-
continue;
|
219 |
-
}
|
220 |
-
|
221 |
-
// - Save the group to category mapping to migrate Auto-Create groups
|
222 |
-
$group_category_map[$group->id] = $term['term_id'];
|
223 |
-
|
224 |
-
$q = $wpdb->prepare("SELECT link_cpt_id FROM {$wpdb->prefix}prli_links WHERE group_id=%d", $group->id);
|
225 |
-
$link_cpt_ids = $wpdb->get_col($q);
|
226 |
-
|
227 |
-
// - Add links associated with group to new category
|
228 |
-
foreach($link_cpt_ids as $link_cpt_id) {
|
229 |
-
$wpdb->insert(
|
230 |
-
$wpdb->term_relationships,
|
231 |
-
array(
|
232 |
-
'object_id' => $link_cpt_id,
|
233 |
-
'term_taxonomy_id' => $term['term_taxonomy_id']
|
234 |
-
),
|
235 |
-
array( '%d', '%d' )
|
236 |
-
);
|
237 |
-
}
|
238 |
-
|
239 |
-
// Update the term_taxonomy count
|
240 |
-
$q = $wpdb->prepare("
|
241 |
-
UPDATE {$wpdb->term_taxonomy}
|
242 |
-
SET `count`=%d
|
243 |
-
WHERE `term_taxonomy_id`=%d
|
244 |
-
",
|
245 |
-
count($link_cpt_ids),
|
246 |
-
$term['term_taxonomy_id']
|
247 |
-
);
|
248 |
-
|
249 |
-
$wpdb->query($q);
|
250 |
-
}
|
251 |
-
|
252 |
-
// - Migrate Auto-Create groups to category
|
253 |
-
global $plp_options;
|
254 |
-
|
255 |
-
if (isset($plp_options->posts_group) && !empty($plp_options->posts_group) && isset($group_category_map[$plp_options->posts_group])) {
|
256 |
-
$plp_options->posts_category = $group_category_map[$plp_options->posts_group];
|
257 |
-
}
|
258 |
-
|
259 |
-
if (isset($plp_options->pages_group) && !empty($plp_options->pages_group) && isset($group_category_map[$plp_options->pages_group])) {
|
260 |
-
$plp_options->pages_category = $group_category_map[$plp_options->pages_group];
|
261 |
-
}
|
262 |
-
|
263 |
-
// - CPTs
|
264 |
-
if (is_array($plp_options->autocreate)) {
|
265 |
-
foreach ($plp_options->autocreate as $post_type => $options) {
|
266 |
-
if (isset($options['group'])) {
|
267 |
-
if (is_numeric($options['group']) && isset($group_category_map[$options['group']])) {
|
268 |
-
$category = $group_category_map[$options['group']];
|
269 |
-
} else {
|
270 |
-
$category = '';
|
271 |
-
}
|
272 |
-
|
273 |
-
$plp_options->autocreate[$post_type]['category'] = $category;
|
274 |
-
}
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
$plp_options->store();
|
279 |
-
}
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpImportExportController.php
DELETED
@@ -1,378 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpImportExportController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action('wp_ajax_plp-export-links', array($this, 'export'));
|
6 |
-
add_action('plp_admin_menu', array($this, 'admin_menu'), 10, 1);
|
7 |
-
}
|
8 |
-
|
9 |
-
public function admin_menu($role) {
|
10 |
-
$pl_link_cpt = PrliLink::$cpt;
|
11 |
-
|
12 |
-
add_submenu_page(
|
13 |
-
"edit.php?post_type={$pl_link_cpt}",
|
14 |
-
esc_html__('Pretty Links Pro | Import / Export', 'pretty-link'),
|
15 |
-
esc_html__('Import / Export', 'pretty-link'),
|
16 |
-
$role, 'plp-import-export',
|
17 |
-
array($this, 'route')
|
18 |
-
);
|
19 |
-
}
|
20 |
-
|
21 |
-
public function route() {
|
22 |
-
if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'import') {
|
23 |
-
$this->import();
|
24 |
-
}
|
25 |
-
else {
|
26 |
-
require_once(PLP_VIEWS_PATH.'/import-export/form.php');
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
public function import() {
|
31 |
-
global $prli_link, $prli_link_meta, $plp_keyword, $plp_options, $prli_error_messages;
|
32 |
-
|
33 |
-
if(empty($_FILES['importedfile']['tmp_name']) || !is_string($_FILES['importedfile']['tmp_name'])) {
|
34 |
-
$error = __('Import file not found.', 'pretty-link');
|
35 |
-
require_once PLP_VIEWS_PATH . '/import-export/import-error.php';
|
36 |
-
return;
|
37 |
-
}
|
38 |
-
|
39 |
-
// Helps with CSV's that don't use DOS style line endings
|
40 |
-
@ini_set("auto_detect_line_endings", true);
|
41 |
-
|
42 |
-
$filename = $_FILES['importedfile']['tmp_name'];
|
43 |
-
$headers = array();
|
44 |
-
$csvdata = array();
|
45 |
-
$row = -1;
|
46 |
-
$delimeter = $this->get_file_delimeter($filename);
|
47 |
-
$handle = fopen($filename, 'r');
|
48 |
-
|
49 |
-
if(!$handle) {
|
50 |
-
$error = __('Import file could not be opened.', 'pretty-link');
|
51 |
-
require_once PLP_VIEWS_PATH . '/import-export/import-error.php';
|
52 |
-
return;
|
53 |
-
}
|
54 |
-
|
55 |
-
while(($data = fgetcsv($handle, 0, $delimeter)) !== FALSE) {
|
56 |
-
$num = count($data);
|
57 |
-
for ($c=0; $c < $num; $c++) {
|
58 |
-
if($row < 0) {
|
59 |
-
$headers[] = $data[$c];
|
60 |
-
}
|
61 |
-
else if($row >= 0) {
|
62 |
-
$csvdata[$row][$headers[$c]] = $data[$c];
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
$row++;
|
67 |
-
}
|
68 |
-
|
69 |
-
fclose($handle);
|
70 |
-
|
71 |
-
$total_row_count = count($csvdata);
|
72 |
-
|
73 |
-
$successful_update_count = 0;
|
74 |
-
$successful_create_count = 0;
|
75 |
-
$no_action_taken_count = 0;
|
76 |
-
|
77 |
-
$creation_errors = array();
|
78 |
-
$update_errors = array();
|
79 |
-
|
80 |
-
foreach($csvdata as $csvrow) {
|
81 |
-
if(!empty($csvrow['id'])) {
|
82 |
-
$record = $prli_link->get_link_min($csvrow['id'], ARRAY_A);
|
83 |
-
|
84 |
-
if($record) {
|
85 |
-
$update_record = false; // assume there aren't any changes
|
86 |
-
$update_keywords = false; // assume there aren't any changes
|
87 |
-
foreach($csvrow as $csvkey => $csvval) {
|
88 |
-
// We'll get to the keywords in a sec for now ignore them
|
89 |
-
if($csvkey == 'keywords') { continue; }
|
90 |
-
|
91 |
-
// If there's a change, flag for update
|
92 |
-
if(isset($record[$csvkey]) && $csvval != $record[$csvkey]) {
|
93 |
-
$update_record = true;
|
94 |
-
break;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
// Add Keywords
|
99 |
-
if( $plp_options->keyword_replacement_is_on ) {
|
100 |
-
$keyword_str = $plp_keyword->getTextByLinkId( $csvrow['id'] );
|
101 |
-
$keywords = explode( ",", $keyword_str );
|
102 |
-
$new_keywords = explode(",",$csvrow['keywords']);
|
103 |
-
|
104 |
-
if(count($keywords) == count($new_keywords)) {
|
105 |
-
for($i=0;$i < count($keywords);$i++) {
|
106 |
-
$keywords[$i] = trim($keywords[$i]);
|
107 |
-
}
|
108 |
-
|
109 |
-
sort($keywords);
|
110 |
-
|
111 |
-
for($i=0;$i < count($new_keywords);$i++) {
|
112 |
-
$new_keywords[$i] = trim($new_keywords[$i]);
|
113 |
-
}
|
114 |
-
|
115 |
-
sort($new_keywords);
|
116 |
-
|
117 |
-
for($i=0; $i < count($new_keywords); $i++) {
|
118 |
-
if($keywords[$i] != $new_keywords[$i]) {
|
119 |
-
$update_keywords = true;
|
120 |
-
break;
|
121 |
-
}
|
122 |
-
}
|
123 |
-
}
|
124 |
-
else {
|
125 |
-
$update_keywords = true;
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
$record_updated = false;
|
130 |
-
|
131 |
-
if($update_record) {
|
132 |
-
if( $record_updated =
|
133 |
-
prli_update_pretty_link(
|
134 |
-
$csvrow['id'],
|
135 |
-
trim($csvrow['url']),
|
136 |
-
$csvrow['slug'],
|
137 |
-
$csvrow['name'],
|
138 |
-
(isset($csvrow['description']))?$csvrow['description']:'',
|
139 |
-
null,// group_id deprecated
|
140 |
-
$csvrow['track_me'],
|
141 |
-
$csvrow['nofollow'],
|
142 |
-
$csvrow['sponsored'],
|
143 |
-
$csvrow['redirect_type'],
|
144 |
-
$csvrow['param_forwarding'],
|
145 |
-
'' /*param_struct*/ ) ) {
|
146 |
-
$successful_update_count++;
|
147 |
-
$prli_link_meta->update_link_meta($csvrow['id'], 'delay', (isset($csvrow['delay']))?(int)$csvrow['delay']:0);
|
148 |
-
$prli_link_meta->update_link_meta($csvrow['id'], 'google_tracking', (isset($csvrow['google_tracking']))?(bool)$csvrow['google_tracking']:false);
|
149 |
-
|
150 |
-
if(isset($csvrow['link_categories'])) {
|
151 |
-
$this->import_link_categories($csvrow['id'], $csvrow['link_categories']);
|
152 |
-
}
|
153 |
-
|
154 |
-
if(isset($csvrow['link_tags'])) {
|
155 |
-
$this->import_link_tags($csvrow['id'], $csvrow['link_tags']);
|
156 |
-
}
|
157 |
-
}
|
158 |
-
else {
|
159 |
-
$update_errors[] = array('id' => $csvrow['id'], 'errors' => $prli_error_messages);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
|
163 |
-
if($update_keywords) {
|
164 |
-
// We don't want to update the keywords if there was an error
|
165 |
-
// in the record's update that is, if the record was updated
|
166 |
-
if($record_updated || !$update_record) {
|
167 |
-
$plp_keyword->updateLinkKeywords($csvrow['id'], stripslashes($csvrow['keywords']));
|
168 |
-
|
169 |
-
// If the record was never updated then increment the count
|
170 |
-
if(!$update_record) {
|
171 |
-
$successful_update_count++;
|
172 |
-
}
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
if(!$update_record && !$update_keywords) {
|
177 |
-
$no_action_taken_count++;
|
178 |
-
}
|
179 |
-
}
|
180 |
-
}
|
181 |
-
else {
|
182 |
-
if( $newid =
|
183 |
-
prli_create_pretty_link(
|
184 |
-
trim($csvrow['url']),
|
185 |
-
$csvrow['slug'],
|
186 |
-
$csvrow['name'],
|
187 |
-
(isset($csvrow['description']))?$csvrow['description']:'',
|
188 |
-
null, // group_id is deprecated
|
189 |
-
$csvrow['track_me'],
|
190 |
-
$csvrow['nofollow'],
|
191 |
-
$csvrow['sponsored'],
|
192 |
-
$csvrow['redirect_type'],
|
193 |
-
$csvrow['param_forwarding'],
|
194 |
-
'' /*param_struct*/ ) ) {
|
195 |
-
$successful_create_count++;
|
196 |
-
$prli_link_meta->update_link_meta($newid, 'delay', (isset($csvrow['delay']))?(int)$csvrow['delay']:0);
|
197 |
-
$prli_link_meta->update_link_meta($newid, 'google_tracking', (isset($csvrow['google_tracking']))?(bool)$csvrow['google_tracking']:false);
|
198 |
-
|
199 |
-
if(isset($csvrow['link_categories'])) {
|
200 |
-
$this->import_link_categories($newid, $csvrow['link_categories']);
|
201 |
-
}
|
202 |
-
|
203 |
-
if(isset($csvrow['link_tags'])) {
|
204 |
-
$this->import_link_tags($newid, $csvrow['link_tags']);
|
205 |
-
}
|
206 |
-
|
207 |
-
if( $plp_options->keyword_replacement_is_on && !empty($csvrow['keywords']) ) {
|
208 |
-
$plp_keyword->updateLinkKeywords($newid, stripslashes($csvrow['keywords']));
|
209 |
-
}
|
210 |
-
}
|
211 |
-
else {
|
212 |
-
$creation_errors[] = array('slug' => $csvrow['slug'], 'errors' => $prli_error_messages);
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
$prli_error_messages = array();
|
217 |
-
}
|
218 |
-
|
219 |
-
require_once(PLP_VIEWS_PATH.'/import-export/import.php');
|
220 |
-
}
|
221 |
-
|
222 |
-
public function export() {
|
223 |
-
global $wpdb, $prli_link, $prli_link_meta, $plp_options, $plp_keyword;
|
224 |
-
|
225 |
-
if(!PrliUtils::is_authorized()) {
|
226 |
-
echo "Why you creepin?";
|
227 |
-
die();
|
228 |
-
}
|
229 |
-
|
230 |
-
$q = $wpdb->prepare("
|
231 |
-
SELECT l.id, l.url, l.slug, l.name, l.redirect_type,
|
232 |
-
l.track_me, l.nofollow, l.sponsored, l.param_forwarding,
|
233 |
-
gt.meta_value AS google_tracking, d.meta_value AS delay,
|
234 |
-
l.created_at AS created_at, l.updated_at AS last_updated_at ,
|
235 |
-
(SELECT GROUP_CONCAT(DISTINCT t.slug ORDER BY t.slug ASC SEPARATOR ',')
|
236 |
-
FROM {$wpdb->terms} AS t
|
237 |
-
JOIN {$wpdb->term_taxonomy} AS tt
|
238 |
-
ON t.term_id = tt.term_id
|
239 |
-
AND tt.taxonomy = %s
|
240 |
-
JOIN {$wpdb->term_relationships} AS tr
|
241 |
-
ON tr.term_taxonomy_id = tt.term_taxonomy_id
|
242 |
-
WHERE tr.object_id=p.ID) AS link_categories,
|
243 |
-
(SELECT GROUP_CONCAT(DISTINCT t.slug ORDER BY t.slug ASC SEPARATOR ',')
|
244 |
-
FROM {$wpdb->terms} AS t
|
245 |
-
JOIN {$wpdb->term_taxonomy} AS tt
|
246 |
-
ON t.term_id = tt.term_id
|
247 |
-
AND tt.taxonomy = %s
|
248 |
-
JOIN {$wpdb->term_relationships} AS tr
|
249 |
-
ON tr.term_taxonomy_id = tt.term_taxonomy_id
|
250 |
-
WHERE tr.object_id=p.ID) AS link_tags
|
251 |
-
FROM {$prli_link->table_name} AS l
|
252 |
-
LEFT JOIN {$prli_link_meta->table_name} AS gt
|
253 |
-
ON l.id = gt.link_id AND gt.meta_key = 'google_tracking'
|
254 |
-
LEFT JOIN {$prli_link_meta->table_name} AS d
|
255 |
-
ON l.id = d.link_id AND d.meta_key = 'delay'
|
256 |
-
JOIN {$wpdb->posts} AS p
|
257 |
-
ON p.ID = l.link_cpt_id
|
258 |
-
WHERE l.link_status='enabled'
|
259 |
-
",
|
260 |
-
PlpLinkCategoriesController::$ctax,
|
261 |
-
PlpLinkTagsController::$ctax
|
262 |
-
);
|
263 |
-
|
264 |
-
$links = $wpdb->get_results($q, ARRAY_A);
|
265 |
-
|
266 |
-
// Maybe Add Keywords
|
267 |
-
if( $plp_options->keyword_replacement_is_on ) {
|
268 |
-
for($i=0; $i < count($links); $i++) {
|
269 |
-
$link_id = $links[$i]['id'];
|
270 |
-
$links[$i]['keywords'] = $plp_keyword->getTextByLinkId( $link_id );
|
271 |
-
}
|
272 |
-
}
|
273 |
-
|
274 |
-
$filename = date('ymdHis',time()) . '_pretty_links.csv';
|
275 |
-
header('Content-Type: text/x-csv');
|
276 |
-
header("Content-Disposition: attachment; filename=\"{$filename}\"");
|
277 |
-
header('Expires: '.gmdate('D, d M Y H:i:s', mktime(date('H')+2, date('i'), date('s'), date('m'), date('d'), date('Y'))).' GMT');
|
278 |
-
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
|
279 |
-
header('Cache-Control: no-cache, must-revalidate');
|
280 |
-
header('Pragma: no-cache');
|
281 |
-
|
282 |
-
if($links[0]) {
|
283 |
-
// print the header
|
284 |
-
echo '"'.implode('","',array_keys($links[0]))."\"\n";
|
285 |
-
}
|
286 |
-
|
287 |
-
foreach($links as $link) {
|
288 |
-
$first = true;
|
289 |
-
foreach($link as $value) {
|
290 |
-
if($first) {
|
291 |
-
echo '"';
|
292 |
-
$first = false;
|
293 |
-
}
|
294 |
-
else {
|
295 |
-
echo '","';
|
296 |
-
}
|
297 |
-
|
298 |
-
echo preg_replace('/\"/', '""', PrliClicksHelper::esc_spreadsheet_cell( stripslashes($value) ));
|
299 |
-
}
|
300 |
-
|
301 |
-
echo "\"\n";
|
302 |
-
}
|
303 |
-
|
304 |
-
exit;
|
305 |
-
}
|
306 |
-
|
307 |
-
/** Import link categories into the link. NOTE: This will overwrite link categories so
|
308 |
-
* whatever categories you have here will be the ONLY categories the link will belong
|
309 |
-
* to after this runs
|
310 |
-
*
|
311 |
-
* @param $link_id The id of the link we want to associate categories with
|
312 |
-
* @param $link_categories This should be either an array of category slugs or a
|
313 |
-
* comma-separated values string of categories.
|
314 |
-
*
|
315 |
-
* @return Same as https://codex.wordpress.org/Function_Reference/wp_set_object_terms
|
316 |
-
*/
|
317 |
-
private function import_link_categories($link_id, $link_categories) {
|
318 |
-
global $prli_link;
|
319 |
-
|
320 |
-
if(!is_array($link_categories)) {
|
321 |
-
$link_categories = array_map('trim',explode(',',$link_categories));
|
322 |
-
}
|
323 |
-
|
324 |
-
$link = $prli_link->getOne($link_id);
|
325 |
-
return wp_set_object_terms( $link->link_cpt_id, $link_categories, PlpLinkCategoriesController::$ctax );
|
326 |
-
}
|
327 |
-
|
328 |
-
/** Import link tags into the link. NOTE: This will overwrite link tags so
|
329 |
-
* whatever tags you have here will be the ONLY tags the link will belong
|
330 |
-
* to after this runs
|
331 |
-
*
|
332 |
-
* @param $link_id The id of the link we want to associate tags with
|
333 |
-
* @param $link_tags This should be either an array of tag slugs or a
|
334 |
-
* comma-separated values string of tags.
|
335 |
-
*
|
336 |
-
* @return Same as https://codex.wordpress.org/Function_Reference/wp_set_object_terms
|
337 |
-
*/
|
338 |
-
private function import_link_tags($link_id, $link_tags) {
|
339 |
-
global $prli_link;
|
340 |
-
|
341 |
-
if(!is_array($link_tags)) {
|
342 |
-
$link_tags = array_map('trim',explode(',',$link_tags));
|
343 |
-
}
|
344 |
-
|
345 |
-
$link = $prli_link->getOne($link_id);
|
346 |
-
return wp_set_object_terms( $link->link_cpt_id, $link_tags, PlpLinkTagsController::$ctax );
|
347 |
-
}
|
348 |
-
|
349 |
-
private function get_file_delimeter($filepath) {
|
350 |
-
$delimiters = apply_filters(
|
351 |
-
'plp-importer-delimiters',
|
352 |
-
array(
|
353 |
-
';' => 0,
|
354 |
-
',' => 0,
|
355 |
-
"\t" => 0,
|
356 |
-
"|" => 0
|
357 |
-
),
|
358 |
-
$filepath
|
359 |
-
);
|
360 |
-
|
361 |
-
$handle = fopen($filepath, "r");
|
362 |
-
|
363 |
-
if($handle) {
|
364 |
-
$first_line = fgets($handle);
|
365 |
-
fclose($handle);
|
366 |
-
|
367 |
-
foreach ($delimiters as $delimiter => &$count) {
|
368 |
-
$count = count(str_getcsv($first_line, $delimiter));
|
369 |
-
}
|
370 |
-
|
371 |
-
if (max($delimiters) > 0) {
|
372 |
-
return array_search(max($delimiters), $delimiters);
|
373 |
-
}
|
374 |
-
}
|
375 |
-
|
376 |
-
return ','; // Default to comma
|
377 |
-
}
|
378 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpKeywordsController.php
DELETED
@@ -1,513 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpKeywordsController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
global $plp_options;
|
6 |
-
|
7 |
-
//Go no further if keywords are off
|
8 |
-
if(!$plp_options->keyword_replacement_is_on) { return; }
|
9 |
-
|
10 |
-
// add_filter('widget_text', array($this, 'replace_keywords'), 999999);
|
11 |
-
// NOTE - This priority must be lower than social buttons bar
|
12 |
-
$priority = apply_filters('prli_keywords_content_filter_priority', 999);
|
13 |
-
add_filter('the_content', array($this, 'replace_keywords'), $priority);
|
14 |
-
|
15 |
-
// BBPress integration
|
16 |
-
add_filter('bbp_get_reply_content', array($this, 'replace_bbpress_keywords'), 11, 2);
|
17 |
-
|
18 |
-
// WooCommerce short descriptions
|
19 |
-
add_filter('woocommerce_short_description', array($this, 'replace_keywords'), 11);
|
20 |
-
|
21 |
-
if($plp_options->replace_keywords_in_feeds) {
|
22 |
-
add_filter('the_content_feed', array($this,'replace_keywords'), 1);
|
23 |
-
}
|
24 |
-
|
25 |
-
if($plp_options->replace_keywords_in_comments) {
|
26 |
-
add_filter('comment_text', array($this,'replace_keywords_in_comments'), 1);
|
27 |
-
}
|
28 |
-
|
29 |
-
if($plp_options->replace_keywords_in_feeds && $plp_options->replace_keywords_in_comments) {
|
30 |
-
add_filter('comment_text_rss', array($this,'replace_keywords_in_comments'), 1);
|
31 |
-
}
|
32 |
-
|
33 |
-
add_action('wp_enqueue_scripts', array($this,'keyword_link_style'));
|
34 |
-
|
35 |
-
add_filter('prli_link_column_keywords', array($this,'keyword_link_column_row'), 10, 2);
|
36 |
-
|
37 |
-
add_filter('get_the_excerpt', array($this, 'excerpt_remove_keyword_replacement'), 1);
|
38 |
-
|
39 |
-
$index_keywords = get_option('plp_index_keywords', false);
|
40 |
-
if($plp_options->keyword_replacement_is_on && $index_keywords) {
|
41 |
-
add_filter('cron_schedules', array($this,'intervals'));
|
42 |
-
|
43 |
-
$num_builders = 2;
|
44 |
-
$separation_t = MINUTE_IN_SECONDS;
|
45 |
-
|
46 |
-
for($i=0; $i<$num_builders; $i++) {
|
47 |
-
if (!wp_next_scheduled("plp_post_build_index{$i}")) {
|
48 |
-
wp_schedule_event( (time() + ($separation_t * $i)), 'plp_post_build_index_interval', "plp_post_build_index{$i}" );
|
49 |
-
}
|
50 |
-
|
51 |
-
add_action("plp_post_build_index{$i}", array($this,'post_index_builder'));
|
52 |
-
}
|
53 |
-
|
54 |
-
if($plp_options->replace_keywords_in_comments) {
|
55 |
-
add_action('wp_insert_comment', array($this, 'comment_inserted'), 10, 2);
|
56 |
-
add_action('wp_set_comment_status', array($this, 'set_comment_status'), 10, 2);
|
57 |
-
}
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
-
public function intervals ($schedules) {
|
62 |
-
$interval = 1 * MINUTE_IN_SECONDS;
|
63 |
-
return array_merge(
|
64 |
-
$schedules,
|
65 |
-
array(
|
66 |
-
'plp_post_build_index_interval' => array(
|
67 |
-
'interval' => $interval,
|
68 |
-
'display' => __('Pretty Link Post Build Index', 'pretty-link')
|
69 |
-
),
|
70 |
-
)
|
71 |
-
);
|
72 |
-
}
|
73 |
-
|
74 |
-
public function set_comment_status ($comment_id, $status) {
|
75 |
-
if($status=='approve') {
|
76 |
-
delete_comment_meta($comment_id, '_plp_comment_keywords_updated_at');
|
77 |
-
delete_comment_meta($comment_id, '_plp_comment_urls_updated_at');
|
78 |
-
}
|
79 |
-
}
|
80 |
-
|
81 |
-
public function comment_inserted ($comment_id, $c) {
|
82 |
-
if($c->comment_approved) {
|
83 |
-
delete_comment_meta($comment_id, '_plp_comment_keywords_updated_at');
|
84 |
-
delete_comment_meta($comment_id, '_plp_comment_urls_updated_at');
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
public function post_index_builder () {
|
89 |
-
global $plp_options, $plp_keyword, $plp_url_replacement;
|
90 |
-
|
91 |
-
$max_count = 2;
|
92 |
-
|
93 |
-
$index_keywords = get_option('plp_index_keywords', false);
|
94 |
-
if($plp_options->keyword_replacement_is_on && $index_keywords) {
|
95 |
-
|
96 |
-
// Index Keywords for Posts
|
97 |
-
$post_ids = $plp_keyword->get_indexable_posts($max_count);
|
98 |
-
if(!empty($post_ids)) {
|
99 |
-
for ($i=0; ($i < count($post_ids)); $i++) {
|
100 |
-
$plp_keyword->index_post($post_ids[$i]);
|
101 |
-
}
|
102 |
-
return; // Short circuit
|
103 |
-
}
|
104 |
-
|
105 |
-
// Index URLs for Posts
|
106 |
-
$post_ids = $plp_url_replacement->get_indexable_posts($max_count);
|
107 |
-
if(!empty($post_ids)) {
|
108 |
-
for ($i=0; ($i < count($post_ids)); $i++) {
|
109 |
-
$plp_url_replacement->index_post($post_ids[$i]);
|
110 |
-
}
|
111 |
-
return; // Short circuit
|
112 |
-
}
|
113 |
-
|
114 |
-
if($plp_options->replace_keywords_in_comments) {
|
115 |
-
|
116 |
-
// Index Kewords for Comments
|
117 |
-
$comment_ids = $plp_keyword->get_indexable_comments($max_count);
|
118 |
-
if(!empty($comment_ids)) {
|
119 |
-
for ($i=0; ($i < count($comment_ids)); $i++) {
|
120 |
-
$plp_keyword->index_comment($comment_ids[$i]);
|
121 |
-
}
|
122 |
-
return; // Short circuit
|
123 |
-
}
|
124 |
-
|
125 |
-
// Index URLs for Comments
|
126 |
-
$comment_ids = $plp_url_replacement->get_indexable_comments($max_count);
|
127 |
-
if(!empty($comment_ids)) {
|
128 |
-
for ($i=0; ($i < count($comment_ids)); $i++) {
|
129 |
-
$plp_url_replacement->index_comment($comment_ids[$i]);
|
130 |
-
}
|
131 |
-
return; // Short circuit
|
132 |
-
}
|
133 |
-
|
134 |
-
}
|
135 |
-
|
136 |
-
}
|
137 |
-
}
|
138 |
-
|
139 |
-
// Removes keyword replacement from excerpts
|
140 |
-
public function excerpt_remove_keyword_replacement($excerpt) {
|
141 |
-
remove_filter('the_content', array($this, 'replace_keywords'));
|
142 |
-
return $excerpt;
|
143 |
-
}
|
144 |
-
|
145 |
-
//Wrapper for replace_keywords() for bbPress
|
146 |
-
public function replace_bbpress_keywords($content, $id) {
|
147 |
-
return $this->replace_keywords($content,'',false);
|
148 |
-
}
|
149 |
-
|
150 |
-
public function replace_keywords($content, $request_uri = '', $allow_header_footer = true) {
|
151 |
-
global $post, $prli_link, $prli_blogurl, $plp_keyword, $plp_url_replacement, $plp_options;
|
152 |
-
|
153 |
-
if(!isset($post) || !isset($post->ID)) { return $content; }
|
154 |
-
|
155 |
-
//*************************** the_content static caching ***************************//
|
156 |
-
// the_content CAN be run more than once per page load
|
157 |
-
// so this static var prevents stuff from happening twice
|
158 |
-
// like cancelling a subscr or resuming etc...
|
159 |
-
static $already_run = array();
|
160 |
-
static $new_content = array();
|
161 |
-
static $content_length = array();
|
162 |
-
|
163 |
-
//Init this post's static values
|
164 |
-
if(!isset($new_content[$post->ID]) || empty($new_content[$post->ID])) {
|
165 |
-
$already_run[$post->ID] = false;
|
166 |
-
$new_content[$post->ID] = '';
|
167 |
-
$content_length[$post->ID] = -1;
|
168 |
-
}
|
169 |
-
|
170 |
-
//Have we been here before?
|
171 |
-
if($already_run[$post->ID] && strlen($content) == $content_length[$post->ID]) {
|
172 |
-
return $new_content[$post->ID];
|
173 |
-
}
|
174 |
-
|
175 |
-
$content_length[$post->ID] = strlen($content);
|
176 |
-
$already_run[$post->ID] = true;
|
177 |
-
//************************* end the_content static caching *************************//
|
178 |
-
|
179 |
-
//Needed to get around an issue with some plugins and themes that add random 's all over the place
|
180 |
-
if(apply_filters('plp_keywords_replace_nbsp', false)) {
|
181 |
-
$content = str_replace(' ', ' ', $content);
|
182 |
-
}
|
183 |
-
|
184 |
-
//Revert WP apostrophe and ampersand formatting
|
185 |
-
$content = str_replace(array('’'), array("'"), $content);
|
186 |
-
$content = str_replace(array('&'), array("&"), $content); //Keywords with & will finally work
|
187 |
-
|
188 |
-
$replacements_happened = false;
|
189 |
-
|
190 |
-
if($plp_options->keyword_replacement_is_on) {
|
191 |
-
$plp_post_options = PlpPostOptions::get_options($post->ID);
|
192 |
-
|
193 |
-
// Make sure keyword replacements haven't been disabled on this page / post
|
194 |
-
if( !$plp_post_options->disable_replacements ) {
|
195 |
-
// If post password required and it doesn't match the cookie.
|
196 |
-
// Just return the content unaltered -- we don't want to cache the password form.
|
197 |
-
if(post_password_required($post)) {
|
198 |
-
$new_content[$post->ID] = $content;
|
199 |
-
return $new_content[$post->ID];
|
200 |
-
}
|
201 |
-
|
202 |
-
// do a keyword replacement per post and per request_uri
|
203 |
-
// so we can handle <!--more--> tags, feeds, etc.
|
204 |
-
if($request_uri == '') {
|
205 |
-
$request_uri = $_SERVER['REQUEST_URI'];
|
206 |
-
}
|
207 |
-
|
208 |
-
// URL Replacements go first
|
209 |
-
if(($urls_to_links = $plp_url_replacement->getURLToLinksArray())) {
|
210 |
-
foreach($urls_to_links as $url => $links) {
|
211 |
-
$urlrep = $links[array_rand($links)];
|
212 |
-
|
213 |
-
// if the url is blank then skip it
|
214 |
-
if(preg_match("#^\s*$#",$url)) { continue; }
|
215 |
-
|
216 |
-
$urlregex = '#'.preg_quote($url,'#').'#';
|
217 |
-
|
218 |
-
// If any url matches then we know there were replacements
|
219 |
-
if(!$replacements_happened && preg_match( $urlregex, $content )) {
|
220 |
-
$replacements_happened = true;
|
221 |
-
}
|
222 |
-
|
223 |
-
$content = preg_replace($urlregex, $urlrep, $content);
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
// Grab keywords to links list
|
228 |
-
if(($keyword_to_links = apply_filters('plp_get_post_keywords_lookup', $plp_keyword->get_post_keywords_lookup($post->ID), $post))) {
|
229 |
-
// Pull out issue prone html code that keywords could appear in
|
230 |
-
$keyword_ignores = array();
|
231 |
-
$shortcode_ignore = '#(\[.*?\])#';
|
232 |
-
$html_tags_remove = '#(\<(a|h\d|pre|script|iframe|code|applet|audio|canvas|button|textarea).*?\>.*?\</(a|h\d|pre|script|iframe|code|applet|audio|canvas|button|textarea)\>)#';
|
233 |
-
$self_close_ignore = '#(\<[^\>]*?/\>)#'; //Should capture img tags and the likes
|
234 |
-
$gen_ignore = '#(\</?.*?/?\>)#'; //Clean up
|
235 |
-
|
236 |
-
$i = 0;
|
237 |
-
|
238 |
-
// Pull shortcodes
|
239 |
-
preg_match_all($shortcode_ignore,$content,$shortcode_matches);
|
240 |
-
|
241 |
-
foreach($shortcode_matches[1] as $shortcode_match) {
|
242 |
-
$placeholder = "||!prliignore".$i++."||";
|
243 |
-
$keyword_ignores[] = array('html' => $shortcode_match, 'placeholder' => $placeholder);
|
244 |
-
$content = preg_replace($shortcode_ignore,$placeholder,$content,1);
|
245 |
-
}
|
246 |
-
|
247 |
-
// Pull certain html tags completely out
|
248 |
-
// We need to make sure we pull full anchors out before we pull general and self closing tags
|
249 |
-
preg_match_all($html_tags_remove,$content,$tags_matches);
|
250 |
-
|
251 |
-
foreach($tags_matches[1] as $tag_match) {
|
252 |
-
$placeholder = "||!prliignore".$i++."||";
|
253 |
-
$keyword_ignores[] = array('html' => $tag_match, 'placeholder' => $placeholder);
|
254 |
-
$content = preg_replace($html_tags_remove,$placeholder,$content,1);
|
255 |
-
}
|
256 |
-
|
257 |
-
// Pull self closing html tags
|
258 |
-
preg_match_all($self_close_ignore,$content,$self_close_matches);
|
259 |
-
|
260 |
-
foreach($self_close_matches[1] as $self_close) {
|
261 |
-
$placeholder = "||!prliignore".$i++."||";
|
262 |
-
$keyword_ignores[] = array('html' => $self_close, 'placeholder' => $placeholder);
|
263 |
-
$content = preg_replace($self_close_ignore,$placeholder,$content,1);
|
264 |
-
}
|
265 |
-
|
266 |
-
// Pull other html tags
|
267 |
-
preg_match_all($gen_ignore,$content,$gen_matches);
|
268 |
-
|
269 |
-
foreach($gen_matches[1] as $gen_match) {
|
270 |
-
$placeholder = "||!prliignore".$i++."||";
|
271 |
-
$keyword_ignores[] = array('html' => $gen_match, 'placeholder' => $placeholder);
|
272 |
-
$content = preg_replace($gen_ignore,$placeholder,$content,1);
|
273 |
-
}
|
274 |
-
|
275 |
-
// Now sort through keyword array and do the actual replacements
|
276 |
-
$keywords = array_keys($keyword_to_links);
|
277 |
-
|
278 |
-
// Sort by stringlength so larger words get replaced first and we get our counts right
|
279 |
-
$keywords = PlpUtils::sort_by_stringlen($keywords,'DESC');
|
280 |
-
|
281 |
-
// Set the keyword links per page to unlimited if we're not using thresholds
|
282 |
-
$keyword_links_per_page = (($plp_options->set_keyword_thresholds)?$plp_options->keyword_links_per_page:-1);
|
283 |
-
$keywords_per_page = (($plp_options->set_keyword_thresholds)?$plp_options->keywords_per_page:-1);
|
284 |
-
|
285 |
-
$i = 0;
|
286 |
-
$keyword_count = 0;
|
287 |
-
$keyword_matches = array();
|
288 |
-
|
289 |
-
// First, see what keywords match in the post
|
290 |
-
foreach($keywords as $keyword) {
|
291 |
-
// if the keyword is blank then skip it
|
292 |
-
if(preg_match("#^\s*$#",$keyword)) { continue; }
|
293 |
-
|
294 |
-
//Fix for UTF-8 characters
|
295 |
-
if(function_exists('mb_detect_encoding') && mb_detect_encoding($keyword) != 'ASCII') {
|
296 |
-
$regex = '/\b('.preg_quote($keyword,'/').')\b/iu'; // add u modifer for UTF-8 or other encodings
|
297 |
-
}
|
298 |
-
else {
|
299 |
-
$regex = '/\b('.preg_quote($keyword,'/').')\b/i'; //For most people ASCII matching should be fine
|
300 |
-
}
|
301 |
-
|
302 |
-
$keyword_instances = array();
|
303 |
-
|
304 |
-
if(preg_match_all($regex,$content,$keyword_instances)) {
|
305 |
-
// If any keyword matches then we know there were replacements
|
306 |
-
if(!$replacements_happened) {
|
307 |
-
$replacements_happened = true;
|
308 |
-
}
|
309 |
-
|
310 |
-
$key_rep_count = $url_index = 0; // array_rand($keyword_to_links[$keyword]);
|
311 |
-
$kw_obj = $keyword_to_links[$keyword][$url_index];
|
312 |
-
$url = $kw_obj->url;
|
313 |
-
$title = htmlentities($kw_obj->title, ENT_QUOTES);
|
314 |
-
|
315 |
-
// Determine which keyword instances will be replaced
|
316 |
-
$keyword_instance_count = count($keyword_instances[1]);
|
317 |
-
$instance_indices = array();
|
318 |
-
for($ind = 0; $ind < $keyword_instance_count; $ind++) {
|
319 |
-
$instance_indices[] = $ind;
|
320 |
-
}
|
321 |
-
|
322 |
-
// Randomize the replacement indices if thresholds are set
|
323 |
-
// This only works because in the instance_indices array
|
324 |
-
// the keys are the same as the values (0=>0,1=>1,2=>2,etc.)
|
325 |
-
if($keyword_links_per_page != -1 && ($keyword_instance_count > $keyword_links_per_page)) {
|
326 |
-
$instance_indices = array_slice(array_keys($instance_indices), 0, $keyword_links_per_page); // array_rand($instance_indices, $keyword_links_per_page);
|
327 |
-
}
|
328 |
-
|
329 |
-
// Force this to be an array ... even though array_rand will sometimes return a scalar var
|
330 |
-
if(!is_array($instance_indices)) {
|
331 |
-
$instance_indices = array($instance_indices);
|
332 |
-
}
|
333 |
-
|
334 |
-
$index = 0;
|
335 |
-
foreach($keyword_instances[1] as $keyword_instance) {
|
336 |
-
$placeholder = "||!prlikeyword".$i++."||";
|
337 |
-
|
338 |
-
// if we're replacing this index with a link then do it -- but
|
339 |
-
// if not, then just replace it with itself later on. :)
|
340 |
-
if(in_array($index,$instance_indices)) {
|
341 |
-
$rel = 'rel="';
|
342 |
-
if($plp_options->keyword_links_nofollow) { $rel .= 'nofollow '; }
|
343 |
-
if($plp_options->keyword_links_sponsored) { $rel .= 'sponsored '; }
|
344 |
-
$rel .= '"';
|
345 |
-
|
346 |
-
$link_html = "<a href=\"{$url}\" title=\"{$title}\" class=\"pretty-link-keyword\"".$rel.(($plp_options->keyword_links_open_new_window)?" target=\"_blank\"":'').">{$keyword_instance}".($plp_options->enable_keyword_link_disclosures?" {$plp_options->keyword_link_disclosure}":'')."</a>";
|
347 |
-
$keyword_matches[] = array('html' => $link_html, 'placeholder' => $placeholder);
|
348 |
-
$content = preg_replace($regex, $placeholder, $content, 1, $key_rep_count);
|
349 |
-
}
|
350 |
-
else {
|
351 |
-
$keyword_matches[] = array('html' => $keyword_instance, 'placeholder' => $placeholder);
|
352 |
-
$content = preg_replace($regex, $placeholder, $content, 1, $key_rep_count);
|
353 |
-
}
|
354 |
-
|
355 |
-
$index++;
|
356 |
-
}
|
357 |
-
|
358 |
-
$keyword_count++;
|
359 |
-
}
|
360 |
-
|
361 |
-
// Short circuit once we've reached the keywords_per_page
|
362 |
-
if($keywords_per_page != -1 && $keyword_count >= $keywords_per_page) {
|
363 |
-
break;
|
364 |
-
}
|
365 |
-
}
|
366 |
-
|
367 |
-
$regexes = array();
|
368 |
-
// Put back the ignores putting the onion back together in reverse order
|
369 |
-
foreach(array_reverse($keyword_ignores) as $keyword_ignore) {
|
370 |
-
// Replace $'s so pcre doesn't think we've got back references
|
371 |
-
$ignore_text = str_replace('$','\$',$keyword_ignore['html']);
|
372 |
-
$ignores_regex = '#'. preg_quote($keyword_ignore['placeholder'], '#') . '#';
|
373 |
-
$regexes[] = $ignores_regex;
|
374 |
-
$content = preg_replace($ignores_regex,$ignore_text,$content);
|
375 |
-
}
|
376 |
-
|
377 |
-
// Put back the matches putting the onion back together in reverse order
|
378 |
-
foreach(array_reverse($keyword_matches) as $keyword_match) {
|
379 |
-
// Replace $'s so pcre doesn't think we've got back references
|
380 |
-
$keyword_text = str_replace('$','\$',$keyword_match['html']);
|
381 |
-
$matches_regex = '#'. preg_quote($keyword_match['placeholder'], '#') . '#';
|
382 |
-
$regexes[] = $matches_regex;
|
383 |
-
$content = preg_replace($matches_regex,$keyword_text,$content);
|
384 |
-
}
|
385 |
-
}
|
386 |
-
|
387 |
-
// Any remaining non-pretty links will now be pretty linked if url/pretty link
|
388 |
-
// replacement has been enabled on this blog
|
389 |
-
if($plp_options->replace_urls_with_pretty_links) {
|
390 |
-
if(apply_filters('prli_replace_urls_decode_content', true, $content)) {
|
391 |
-
$content = html_entity_decode(rawurldecode($content));
|
392 |
-
}
|
393 |
-
|
394 |
-
preg_match_all('#<a.*?href\s*?=\s*?[\'"](https?://.*?)[\'"]#mi', $content, $matches);
|
395 |
-
|
396 |
-
//Filter out our blacklist domains so they don't get replaced
|
397 |
-
if(!empty($plp_options->replace_urls_with_pretty_links_blacklist) && !empty($matches[1])) {
|
398 |
-
$blacklist = preg_split('/[\r\n]+/', $plp_options->replace_urls_with_pretty_links_blacklist, -1, PREG_SPLIT_NO_EMPTY);
|
399 |
-
|
400 |
-
foreach($blacklist as $bl_url) {
|
401 |
-
$bl_url_host = parse_url($bl_url, PHP_URL_HOST);
|
402 |
-
|
403 |
-
foreach($matches[1] as $key => $rep_url) {
|
404 |
-
$rep_url_host = parse_url($rep_url, PHP_URL_HOST);
|
405 |
-
|
406 |
-
if($bl_url_host == $rep_url_host) {
|
407 |
-
unset($matches[1][$key]);
|
408 |
-
}
|
409 |
-
}
|
410 |
-
}
|
411 |
-
|
412 |
-
//reindex the array
|
413 |
-
$matches[1] = array_values($matches[1]);
|
414 |
-
}
|
415 |
-
|
416 |
-
$prli_lookup = $prli_link->get_target_to_pretty_urls( $matches[1], true );
|
417 |
-
|
418 |
-
if($prli_lookup !== false && is_array($prli_lookup)) {
|
419 |
-
//Using this one to prevent partial url replacements -- seems to be working but I'm not 100% sure about the # of escapes on the double quote's
|
420 |
-
$url_patterns = array_map(
|
421 |
-
function($target_url) {
|
422 |
-
return '#["\']' . preg_quote($target_url, '#') . '["\']#';
|
423 |
-
},
|
424 |
-
array_keys($prli_lookup)
|
425 |
-
);
|
426 |
-
|
427 |
-
$url_replacements = array_values(array_map(
|
428 |
-
function($pretty_urls) {
|
429 |
-
return $pretty_urls[0];
|
430 |
-
},
|
431 |
-
$prli_lookup
|
432 |
-
));
|
433 |
-
|
434 |
-
if($plp_options->keyword_links_open_new_window) {
|
435 |
-
$url_patterns[] = "#<a\s#";
|
436 |
-
$url_replacements[] = '<a target="_blank" ';
|
437 |
-
}
|
438 |
-
|
439 |
-
$content = preg_replace($url_patterns, $url_replacements, $content);
|
440 |
-
}
|
441 |
-
}
|
442 |
-
}
|
443 |
-
}
|
444 |
-
|
445 |
-
if($allow_header_footer && $replacements_happened && $plp_options->enable_link_to_disclosures) {
|
446 |
-
ob_start();
|
447 |
-
|
448 |
-
?>
|
449 |
-
<div class="prli-link-to-disclosures">
|
450 |
-
<a href="<?php echo esc_url($plp_options->disclosures_link_url); ?>"><?php echo esc_html($plp_options->disclosures_link_text); ?></a>
|
451 |
-
</div>
|
452 |
-
<?php
|
453 |
-
|
454 |
-
$disclosure_link = ob_get_clean();
|
455 |
-
|
456 |
-
if($plp_options->disclosures_link_position=='top') {
|
457 |
-
$content = $disclosure_link.$content;
|
458 |
-
}
|
459 |
-
else if($plp_options->disclosures_link_position=='top_and_bottom') {
|
460 |
-
$content = $disclosure_link.$content.$disclosure_link;
|
461 |
-
}
|
462 |
-
else {
|
463 |
-
$content = $content.$disclosure_link;
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
$new_content[$post->ID] = $content;
|
468 |
-
return $new_content[$post->ID];
|
469 |
-
}
|
470 |
-
|
471 |
-
public function replace_keywords_in_comments( $content ) {
|
472 |
-
//global $comment;
|
473 |
-
// We don't care if it's a real uri -- it's used as an index
|
474 |
-
//$request_uri = "#prli-comment-{$comment->comment_ID}";
|
475 |
-
$request_uri = '#prli-comment-' . PlpUtils::base36_encode(mt_rand());
|
476 |
-
|
477 |
-
return $this->replace_keywords( $content, $request_uri, false );
|
478 |
-
}
|
479 |
-
|
480 |
-
// TODO: There must be a cleaner way to do this -- Blair Williams 11/2014
|
481 |
-
public function keyword_link_style() {
|
482 |
-
global $plp_options;
|
483 |
-
|
484 |
-
if ($plp_options->keyword_replacement_is_on) {
|
485 |
-
$css = '';
|
486 |
-
|
487 |
-
if (!empty($plp_options->keyword_link_custom_css)) {
|
488 |
-
$css .= sprintf('a.pretty-link-keyword { %s }', esc_html($plp_options->keyword_link_custom_css));
|
489 |
-
}
|
490 |
-
|
491 |
-
if (!empty($plp_options->keyword_link_hover_custom_css)) {
|
492 |
-
$css .= sprintf('a.pretty-link-keyword:hover { %s }', esc_html($plp_options->keyword_link_hover_custom_css));
|
493 |
-
}
|
494 |
-
|
495 |
-
if ($css) {
|
496 |
-
wp_register_style('plp-keywords', false);
|
497 |
-
wp_enqueue_style('plp-keywords');
|
498 |
-
wp_add_inline_style('plp-keywords', $css);
|
499 |
-
}
|
500 |
-
}
|
501 |
-
}
|
502 |
-
|
503 |
-
public function keyword_link_column_row($content, $link_id) {
|
504 |
-
global $plp_keyword, $plp_options;
|
505 |
-
|
506 |
-
if( $plp_options->keyword_replacement_is_on ) {
|
507 |
-
return $plp_keyword->getTextByLinkId( $link_id );
|
508 |
-
}
|
509 |
-
|
510 |
-
return '';
|
511 |
-
}
|
512 |
-
}
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpLinkCategoriesController.php
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpLinkCategoriesController extends PrliBaseController {
|
4 |
-
public static $ctax = 'pretty-link-category';
|
5 |
-
|
6 |
-
public function load_hooks() {
|
7 |
-
add_action('init', array($this,'register_taxonomy'));
|
8 |
-
}
|
9 |
-
|
10 |
-
public function register_taxonomy() {
|
11 |
-
$role = PrliUtils::get_minimum_role();
|
12 |
-
|
13 |
-
$args = array(
|
14 |
-
'labels' => array(
|
15 |
-
'name' => esc_html_x( 'Link Categories', 'taxonomy general name', 'pretty-link' ),
|
16 |
-
'singular_name' => esc_html_x( 'Link Category', 'taxonomy singular name', 'pretty-link' ),
|
17 |
-
'search_items' => esc_html__( 'Search Link Categories', 'pretty-link' ),
|
18 |
-
'all_items' => esc_html__( 'All Link Categories', 'pretty-link' ),
|
19 |
-
'parent_item' => esc_html__( 'Parent Link Category', 'pretty-link' ),
|
20 |
-
'parent_item_colon' => esc_html__( 'Parent Link Category:', 'pretty-link' ),
|
21 |
-
'edit_item' => esc_html__( 'Edit Link Category', 'pretty-link' ),
|
22 |
-
'update_item' => esc_html__( 'Update Link Category', 'pretty-link' ),
|
23 |
-
'add_new_item' => esc_html__( 'Add New Link Category', 'pretty-link' ),
|
24 |
-
'new_item_name' => esc_html__( 'New Link Category Name', 'pretty-link' ),
|
25 |
-
'menu_name' => esc_html__( 'Categories', 'pretty-link' ),
|
26 |
-
),
|
27 |
-
'hierarchical' => true,
|
28 |
-
'show_ui' => true,
|
29 |
-
'show_admin_column' => true,
|
30 |
-
'query_var' => false,
|
31 |
-
'rewrite' => false,
|
32 |
-
'capabilities' => array(
|
33 |
-
'manage_terms' => $role,
|
34 |
-
'edit_terms' => $role,
|
35 |
-
'delete_terms' => $role,
|
36 |
-
'assign_terms' => $role
|
37 |
-
)
|
38 |
-
);
|
39 |
-
|
40 |
-
register_taxonomy( self::$ctax, PrliLink::$cpt, $args );
|
41 |
-
}
|
42 |
-
}
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpLinkTagsController.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpLinkTagsController extends PrliBaseController {
|
4 |
-
public static $ctax = 'pretty-link-tag';
|
5 |
-
|
6 |
-
public function load_hooks() {
|
7 |
-
add_action('init', array($this,'register_taxonomy'));
|
8 |
-
}
|
9 |
-
|
10 |
-
public function register_taxonomy() {
|
11 |
-
$role = PrliUtils::get_minimum_role();
|
12 |
-
|
13 |
-
$args = array(
|
14 |
-
'labels' => array(
|
15 |
-
'name' => esc_html_x( 'Link Tags', 'taxonomy general name', 'pretty-link' ),
|
16 |
-
'singular_name' => esc_html_x( 'Link Tag', 'taxonomy singular name', 'pretty-link' ),
|
17 |
-
'search_items' => esc_html__( 'Search Link Tags', 'pretty-link' ),
|
18 |
-
'all_items' => esc_html__( 'All Link Tags', 'pretty-link' ),
|
19 |
-
'parent_item' => null,
|
20 |
-
'parent_item_colon' => null,
|
21 |
-
'edit_item' => esc_html__( 'Edit Link Tag', 'pretty-link' ),
|
22 |
-
'update_item' => esc_html__( 'Update Link Tag', 'pretty-link' ),
|
23 |
-
'add_new_item' => esc_html__( 'Add New Link Tag', 'pretty-link' ),
|
24 |
-
'new_item_name' => esc_html__( 'New Link Tag Name', 'pretty-link' ),
|
25 |
-
'separate_items_with_commas' => esc_html__( 'Separate Link Tags with commas', 'pretty-link' ),
|
26 |
-
'add_or_remove_items' => esc_html__( 'Add or remove Link Tags', 'pretty-link' ),
|
27 |
-
'choose_from_most_used' => esc_html__( 'Choose from the most used Link Tags', 'pretty-link' ),
|
28 |
-
'not_found' => esc_html__( 'No Link Tags found.', 'pretty-link' ),
|
29 |
-
'menu_name' => esc_html__( 'Tags', 'pretty-link' ),
|
30 |
-
),
|
31 |
-
'hierarchical' => false,
|
32 |
-
'show_ui' => true,
|
33 |
-
'show_admin_column' => true,
|
34 |
-
'update_count_callback' => '_update_post_term_count',
|
35 |
-
'query_var' => false,
|
36 |
-
'rewrite' => false,
|
37 |
-
'capabilities' => array(
|
38 |
-
'manage_terms' => $role,
|
39 |
-
'edit_terms' => $role,
|
40 |
-
'delete_terms' => $role,
|
41 |
-
'assign_terms' => $role
|
42 |
-
)
|
43 |
-
);
|
44 |
-
|
45 |
-
|
46 |
-
register_taxonomy( self::$ctax, PrliLink::$cpt, $args );
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpLinksController.php
DELETED
@@ -1,892 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpLinksController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action('prli_link_fields', array($this,'display_link_options'));
|
6 |
-
add_action('prli_record_click', array($this,'record_rotation_click'));
|
7 |
-
add_action('prli_update_link', array($this,'update_link_options'));
|
8 |
-
add_filter('prli_validate_link', array($this,'validate_link_options'));
|
9 |
-
add_filter('prli_target_url', array($this,'customize_target_url'), 99);
|
10 |
-
add_action('wp_head', array($this,'shorturl_autodiscover'));
|
11 |
-
|
12 |
-
add_action('prli_redirection_types', array($this,'redirection_types'), 10, 2);
|
13 |
-
add_action('prli_issue_cloaked_redirect', array($this,'issue_cloaked_redirect'), 10, 4);
|
14 |
-
add_action('prli_default_redirection_types',array($this,'default_redirection_options'));
|
15 |
-
add_action('prli_delete_link', array($this,'delete_link'));
|
16 |
-
add_action('prli_custom_link_options', array($this,'custom_link_options'));
|
17 |
-
add_action('prli-store-options', array($this,'store_link_options'));
|
18 |
-
add_action('prli-create-link', array($this,'create_link'), 10, 2);
|
19 |
-
|
20 |
-
add_filter('prli-check-if-slug', array($this,'generate_qr_code'),10,2);
|
21 |
-
|
22 |
-
add_action('prli_list_end_icon', array($this,'link_list_end_icons'));
|
23 |
-
|
24 |
-
add_action('prli-redirect-header', array($this, 'maybe_add_scripts_to_head'));
|
25 |
-
|
26 |
-
add_action('wp_ajax_prli_search_countries', array($this, 'ajax_search_countries'));
|
27 |
-
}
|
28 |
-
|
29 |
-
public function maybe_add_scripts_to_head() {
|
30 |
-
global $wpdb, $plp_options, $prli_link, $prli_link_meta;
|
31 |
-
|
32 |
-
//Global scripts
|
33 |
-
if(!empty($plp_options->global_head_scripts)) {
|
34 |
-
echo stripslashes($plp_options->global_head_scripts) . "\n";
|
35 |
-
}
|
36 |
-
|
37 |
-
//Per link scripts
|
38 |
-
$request_uri = preg_replace('#/(\?.*)?$#', '$1', rawurldecode($_SERVER['REQUEST_URI']));
|
39 |
-
|
40 |
-
if($link_info = $prli_link->is_pretty_link($request_uri, false)) {
|
41 |
-
$link_id = $link_info['pretty_link_found']->id;
|
42 |
-
$head_scripts = stripslashes($prli_link_meta->get_link_meta($link_id, 'head_scripts', true));
|
43 |
-
|
44 |
-
if(!empty($head_scripts)) {
|
45 |
-
echo stripslashes($head_scripts);
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
/************ DISPLAY & UPDATE PRO LINK OPTIONS ************/
|
51 |
-
public function display_link_options($link_id) {
|
52 |
-
global $prli_link, $prli_link_meta, $plp_keyword, $plp_link_rotation, $plp_options;
|
53 |
-
|
54 |
-
if( $plp_options->keyword_replacement_is_on ) {
|
55 |
-
if(empty($_POST['keywords']) && $link_id) {
|
56 |
-
$keywords = $plp_keyword->getTextByLinkId( $link_id );
|
57 |
-
}
|
58 |
-
else {
|
59 |
-
$keywords = isset($_POST['keywords']) && is_string($_POST['keywords']) ? sanitize_text_field(stripslashes($_POST['keywords'])) : '';
|
60 |
-
}
|
61 |
-
|
62 |
-
if(empty($_POST['url_replacements']) && $link_id) {
|
63 |
-
$url_replacements = $prli_link_meta->get_link_meta( $link_id, 'prli-url-replacements' );
|
64 |
-
|
65 |
-
if(is_array($url_replacements)) {
|
66 |
-
$url_replacements = implode(', ', $url_replacements);
|
67 |
-
}
|
68 |
-
else {
|
69 |
-
$url_replacements = '';
|
70 |
-
}
|
71 |
-
}
|
72 |
-
else {
|
73 |
-
$url_replacements = isset($_POST['url_replacements']) && is_string($_POST['url_replacements']) ? sanitize_text_field(stripslashes($_POST['url_replacements'])) : '';
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
if(empty($_POST['head-scripts']) && $link_id) {
|
78 |
-
$head_scripts = stripslashes($prli_link_meta->get_link_meta($link_id, 'head_scripts', true));
|
79 |
-
}
|
80 |
-
else {
|
81 |
-
$head_scripts = isset($_POST['head-scripts']) && is_string($_POST['head-scripts']) ? PrliUtils::sanitize_html(stripslashes($_POST['head-scripts'])) : '';
|
82 |
-
}
|
83 |
-
|
84 |
-
if(empty($_POST['dynamic_redirection']) && $link_id) {
|
85 |
-
$dynamic_redirection = $prli_link_meta->get_link_meta($link_id, 'prli_dynamic_redirection', true);
|
86 |
-
|
87 |
-
// Ensure reverse compatibility
|
88 |
-
if(empty($dynamic_redirection) &&
|
89 |
-
$plp_link_rotation->there_are_rotations_for_this_link($link_id)) {
|
90 |
-
$dynamic_redirection = 'rotate';
|
91 |
-
}
|
92 |
-
}
|
93 |
-
else {
|
94 |
-
$dynamic_redirection = isset($_POST['dynamic_redirection']) && is_string($_POST['dynamic_redirection']) ? sanitize_key(stripslashes($_POST['dynamic_redirection'])) : 'none';
|
95 |
-
}
|
96 |
-
|
97 |
-
if(empty($_POST['url_rotations']) && $link_id) {
|
98 |
-
$url_rotations = $plp_link_rotation->get_rotations( $link_id );
|
99 |
-
$url_rotation_weights = $plp_link_rotation->get_weights( $link_id );
|
100 |
-
|
101 |
-
if(!is_array($url_rotations)) {
|
102 |
-
$url_rotations = array('','','','');
|
103 |
-
}
|
104 |
-
|
105 |
-
if(!is_array($url_rotation_weights)) {
|
106 |
-
$url_rotation_weights = array('','','','');
|
107 |
-
}
|
108 |
-
}
|
109 |
-
else {
|
110 |
-
$url_rotations = isset($_POST['url_rotations']) && is_array($_POST['url_rotations']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['url_rotations']))) : array();
|
111 |
-
$url_rotation_weights = isset($_POST['url_rotation_weights']) && is_array($_POST['url_rotation_weights']) ? array_map(function ($value) { return PrliUtils::clamp((int) $value, 0, 100); }, wp_unslash($_POST['url_rotation_weights'])) : array();
|
112 |
-
}
|
113 |
-
|
114 |
-
if(empty($_POST['url']) && $link_id) {
|
115 |
-
$link = $prli_link->getOne($link_id);
|
116 |
-
$target_url = $link->url;
|
117 |
-
}
|
118 |
-
else {
|
119 |
-
$target_url = isset($_POST['url']) && is_string($_POST['url']) ? esc_url_raw(trim(stripslashes($_POST['url']))) : '';
|
120 |
-
}
|
121 |
-
|
122 |
-
if(!$link_id || !($target_url_weight = $prli_link_meta->get_link_meta($link_id, 'prli-target-url-weight', true))) {
|
123 |
-
$target_url_weight = 0;
|
124 |
-
}
|
125 |
-
|
126 |
-
if(!empty($_POST) && !isset($_POST['enable_split_test']) || (empty($link_id) || !$link_id)) {
|
127 |
-
$enable_split_test = isset($_POST['enable_split_test']);
|
128 |
-
}
|
129 |
-
else {
|
130 |
-
$enable_split_test = $prli_link_meta->get_link_meta($link_id, 'prli-enable-split-test', true);
|
131 |
-
}
|
132 |
-
|
133 |
-
if(isset($_POST['split_test_goal_link']) || (empty($link_id) || !$link_id)) {
|
134 |
-
$split_test_goal_link = isset($_POST['split_test_goal_link']) && is_numeric($_POST['split_test_goal_link']) ? (int) $_POST['split_test_goal_link'] : '';
|
135 |
-
}
|
136 |
-
else {
|
137 |
-
$split_test_goal_link = $prli_link_meta->get_link_meta($link_id, 'prli-split-test-goal-link', true);
|
138 |
-
}
|
139 |
-
|
140 |
-
$links = $prli_link->getAll('',' ORDER BY li.name');
|
141 |
-
|
142 |
-
if(isset($_POST['enable_expire']) || (empty($link_id) || !$link_id)) {
|
143 |
-
$enable_expire = isset($_POST['enable_expire']);
|
144 |
-
}
|
145 |
-
else {
|
146 |
-
$enable_expire = $prli_link_meta->get_link_meta($link_id, 'enable_expire', true);
|
147 |
-
}
|
148 |
-
|
149 |
-
if(isset($_POST['expire_type']) || (empty($link_id) || !$link_id)) {
|
150 |
-
$expire_type = isset($_POST['expire_type']) && is_string($_POST['expire_type']) ? sanitize_key(stripslashes($_POST['expire_type'])) : 'date';
|
151 |
-
}
|
152 |
-
else {
|
153 |
-
$expire_type = $prli_link_meta->get_link_meta($link_id, 'expire_type', true);
|
154 |
-
}
|
155 |
-
|
156 |
-
if(isset($_POST['expire_date']) || (empty($link_id) || !$link_id)) {
|
157 |
-
$expire_date = isset($_POST['expire_date']) && is_string($_POST['expire_date']) ? sanitize_text_field(stripslashes($_POST['expire_date'])) : '';
|
158 |
-
}
|
159 |
-
else {
|
160 |
-
$expire_date = $prli_link_meta->get_link_meta($link_id, 'expire_date', true);
|
161 |
-
}
|
162 |
-
|
163 |
-
if(isset($_POST['expire_clicks']) || (empty($link_id) || !$link_id)) {
|
164 |
-
$expire_clicks = isset($_POST['expire_clicks']) && is_numeric($_POST['expire_clicks']) ? (int) $_POST['expire_clicks'] : 0;
|
165 |
-
}
|
166 |
-
else {
|
167 |
-
$expire_clicks = $prli_link_meta->get_link_meta($link_id, 'expire_clicks', true);
|
168 |
-
}
|
169 |
-
|
170 |
-
if(isset($_POST['enable_expired_url']) || (empty($link_id) || !$link_id)) {
|
171 |
-
$enable_expired_url = isset($_POST['enable_expired_url']);
|
172 |
-
}
|
173 |
-
else {
|
174 |
-
$enable_expired_url = $prli_link_meta->get_link_meta($link_id, 'enable_expired_url', true);
|
175 |
-
}
|
176 |
-
|
177 |
-
if(isset($_POST['expired_url']) || (empty($link_id) || !$link_id)) {
|
178 |
-
$expired_url = isset($_POST['expired_url']) && is_string($_POST['expired_url']) ? esc_url_raw(trim(stripslashes($_POST['expired_url']))) : '';
|
179 |
-
}
|
180 |
-
else {
|
181 |
-
$expired_url = $prli_link_meta->get_link_meta($link_id, 'expired_url', true);
|
182 |
-
}
|
183 |
-
|
184 |
-
require_once(PLP_VIEWS_PATH.'/links/form.php');
|
185 |
-
}
|
186 |
-
|
187 |
-
public function validate_link_options($errors) {
|
188 |
-
global $prli_link_meta, $plp_options;
|
189 |
-
|
190 |
-
if( $plp_options->keyword_replacement_is_on ) {
|
191 |
-
if( !empty($_POST[ 'url_replacements' ]) ) {
|
192 |
-
$replacements = explode(',', $_POST['url_replacements']);
|
193 |
-
foreach($replacements as $replacement) {
|
194 |
-
if(!PrliUtils::is_url(trim($replacement))) {
|
195 |
-
$errors[] = __('Your URL Replacements must be formatted as a comma separated list of properly formatted URLs (http[s]://example.com/whatever)', 'pretty-link');
|
196 |
-
break;
|
197 |
-
}
|
198 |
-
}
|
199 |
-
}
|
200 |
-
}
|
201 |
-
|
202 |
-
if(isset($_POST['enable_expire'])) {
|
203 |
-
if(isset($_POST['expire_type']) && $_POST['expire_type']=='date') {
|
204 |
-
$_POST['expire_date'] = trim($_POST['expire_date']);
|
205 |
-
if(!PrliUtils::is_date($_POST['expire_date'])) {
|
206 |
-
$errors[] = __('Date must be valid and formatted YYYY-MM-DD.', 'pretty-link');
|
207 |
-
}
|
208 |
-
}
|
209 |
-
else if(isset($_POST['expire_type']) && $_POST['expire_type']=='clicks') {
|
210 |
-
$_POST['expire_clicks'] = trim($_POST['expire_clicks']);
|
211 |
-
|
212 |
-
// If they have clicks set here then we force tracking on for the link
|
213 |
-
// TODO: Is this the best way to do this?
|
214 |
-
$_POST['track_me'] = 'on';
|
215 |
-
|
216 |
-
if( !is_numeric($_POST['expire_clicks']) ||
|
217 |
-
(int)$_POST['expire_clicks'] <= 0 ) {
|
218 |
-
$errors[] = __('Expire Clicks must be a number greater than zero.', 'pretty-link');
|
219 |
-
}
|
220 |
-
}
|
221 |
-
|
222 |
-
if(isset($_POST['enable_expired_url'])) {
|
223 |
-
$_POST['expired_url'] = isset($_POST['expired_url']) && is_string($_POST['expired_url']) ? trim($_POST['expired_url']) : '';
|
224 |
-
if(!PrliUtils::is_url($_POST['expired_url'])) {
|
225 |
-
$errors[] = __('Expired URL must be a valid URL.', 'pretty-link');
|
226 |
-
}
|
227 |
-
}
|
228 |
-
}
|
229 |
-
|
230 |
-
if( !empty($_POST['dynamic_redirection']) && $_POST['dynamic_redirection']=='rotate' ) {
|
231 |
-
if( !empty($_POST[ 'url_rotations' ]) ) {
|
232 |
-
$num_active_links = 0;
|
233 |
-
$weight_sum = (int)$_POST['target_url_weight'];
|
234 |
-
foreach($_POST['url_rotations'] as $i => $rotation) {
|
235 |
-
if(!empty($rotation)) {
|
236 |
-
if(!PrliUtils::is_url($rotation)) {
|
237 |
-
$errors[] = __('Your URL Rotations must all be properly formatted URLs.', 'pretty-link');
|
238 |
-
}
|
239 |
-
|
240 |
-
$num_active_links++;
|
241 |
-
$weight_sum += (int)$_POST['url_rotation_weights'][$i];
|
242 |
-
}
|
243 |
-
}
|
244 |
-
|
245 |
-
if($num_active_links > 0 && $weight_sum != 100) {
|
246 |
-
$errors[] = __('Your Link Rotation Weights must add up to 100%.', 'pretty-link');
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
if( !empty($_POST['dynamic_redirection']) && $_POST['dynamic_redirection']=='geo' ) {
|
252 |
-
if( !empty($_POST['prli_geo_url']) ) {
|
253 |
-
foreach($_POST['prli_geo_url'] as $i => $geo_url) {
|
254 |
-
if(!empty($geo_url)) {
|
255 |
-
if(!PrliUtils::is_url($geo_url)) {
|
256 |
-
$errors[] = __('Your Geographic Redirect URLs must all be properly formatted.', 'pretty-link');
|
257 |
-
}
|
258 |
-
}
|
259 |
-
else {
|
260 |
-
$errors[] = __('Your Geographic Redirects URLs must not be empty.', 'pretty-link');
|
261 |
-
}
|
262 |
-
|
263 |
-
if(empty($_POST['prli_geo_countries']) || empty($_POST['prli_geo_countries'][$i])) {
|
264 |
-
$errors[] = __('Your Geographic Redirect Countries must not be empty.', 'pretty-link');
|
265 |
-
}
|
266 |
-
}
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
if( !empty($_POST['dynamic_redirection']) && $_POST['dynamic_redirection']=='tech' ) {
|
271 |
-
if( !empty($_POST['prli_tech_url']) ) {
|
272 |
-
foreach($_POST['prli_tech_url'] as $i => $tech_url) {
|
273 |
-
if(!empty($tech_url)) {
|
274 |
-
if(!PrliUtils::is_url($tech_url)) {
|
275 |
-
$errors[] = __('Your Technology Redirect URLs must all be properly formatted.', 'pretty-link');
|
276 |
-
}
|
277 |
-
}
|
278 |
-
else {
|
279 |
-
$errors[] = __('Your Technology Redirects URLs must not be empty.', 'pretty-link');
|
280 |
-
}
|
281 |
-
}
|
282 |
-
}
|
283 |
-
}
|
284 |
-
|
285 |
-
if( !empty($_POST['dynamic_redirection']) && $_POST['dynamic_redirection']=='time' ) {
|
286 |
-
if( !empty($_POST['prli_time_url']) ) {
|
287 |
-
foreach($_POST['prli_time_url'] as $i => $time_url) {
|
288 |
-
if(!empty($time_url)) {
|
289 |
-
if(!PrliUtils::is_url($time_url)) {
|
290 |
-
$errors[] = __('Your Time Period Redirect URLs must all be properly formatted.', 'pretty-link');
|
291 |
-
}
|
292 |
-
}
|
293 |
-
else {
|
294 |
-
$errors[] = __('Your Time Period Redirects URLs must not be empty.', 'pretty-link');
|
295 |
-
}
|
296 |
-
|
297 |
-
if(!empty($_POST['prli_time_start'])) {
|
298 |
-
if(empty($_POST['prli_time_start'][$i])) {
|
299 |
-
$errors[] = __('Your Time Period Redirect start time must not be empty.', 'pretty-link');
|
300 |
-
}
|
301 |
-
else if(!PrliUtils::is_date($_POST['prli_time_start'][$i])) {
|
302 |
-
$errors[] = __('Your Time Period Redirect start time must be a properly formatted date.', 'pretty-link');
|
303 |
-
}
|
304 |
-
}
|
305 |
-
|
306 |
-
if(!empty($_POST['prli_time_end'])) {
|
307 |
-
if(empty($_POST['prli_time_end'][$i])) {
|
308 |
-
$errors[] = __('Your Time Period Redirect end time must not be empty.', 'pretty-link');
|
309 |
-
}
|
310 |
-
else if(!PrliUtils::is_date($_POST['prli_time_end'][$i])) {
|
311 |
-
$errors[] = __('Your Time Period Redirect end time must be a properly formatted date.', 'pretty-link');
|
312 |
-
}
|
313 |
-
}
|
314 |
-
|
315 |
-
if(!empty($_POST['prli_time_start']) && !empty($_POST['prli_time_end']) &&
|
316 |
-
PrliUtils::is_date($_POST['prli_time_start'][$i]) && PrliUtils::is_date($_POST['prli_time_end'][$i]) &&
|
317 |
-
($time_start = strtotime($_POST['prli_time_start'][$i])) && ($time_end = strtotime($_POST['prli_time_end'][$i])) &&
|
318 |
-
$time_start > $time_end ) {
|
319 |
-
$errors[] = __('Your Time Period Redirect start time must come before the end time.', 'pretty-link');
|
320 |
-
}
|
321 |
-
}
|
322 |
-
}
|
323 |
-
}
|
324 |
-
|
325 |
-
if(isset($_POST['delay']) && !empty($_POST['delay'])) {
|
326 |
-
if(!is_numeric($_POST['delay'])) {
|
327 |
-
$errors[] = __('Delay Redirect must be a number', 'pretty-link');
|
328 |
-
}
|
329 |
-
}
|
330 |
-
|
331 |
-
return $errors;
|
332 |
-
}
|
333 |
-
|
334 |
-
public function update_link_options($link_id) {
|
335 |
-
global $prli_link_meta, $plp_link_rotation, $plp_keyword, $plp_options;
|
336 |
-
|
337 |
-
if($plp_options->keyword_replacement_is_on) {
|
338 |
-
if (isset($_POST['keywords']) && is_string($_POST['keywords'])) {
|
339 |
-
//Keywords first
|
340 |
-
$plp_keyword->updateLinkKeywords($link_id, sanitize_text_field(stripslashes($_POST['keywords'])));
|
341 |
-
}
|
342 |
-
|
343 |
-
if (isset($_POST['url_replacements']) && is_string($_POST['url_replacements'])) {
|
344 |
-
//Now URL replacements
|
345 |
-
$replacements = explode(',', sanitize_text_field(stripslashes($_POST['url_replacements'])));
|
346 |
-
|
347 |
-
for ($i = 0; $i < count($replacements); $i++) {
|
348 |
-
$replacements[$i] = esc_url_raw(trim($replacements[$i]));
|
349 |
-
}
|
350 |
-
|
351 |
-
//No point filling the meta table with a bunch of empty crap
|
352 |
-
if (count($replacements) == 1 && empty($replacements[0])) {
|
353 |
-
$prli_link_meta->delete_link_meta($link_id, 'prli-url-replacements');
|
354 |
-
} else {
|
355 |
-
$prli_link_meta->update_link_meta($link_id, 'prli-url-replacements', $replacements);
|
356 |
-
}
|
357 |
-
}
|
358 |
-
}
|
359 |
-
|
360 |
-
$dynamic_redirection = (isset($_POST['dynamic_redirection']) && is_string($_POST['dynamic_redirection']) ? sanitize_key(stripslashes($_POST['dynamic_redirection'])) : 'none');
|
361 |
-
$prli_link_meta->update_link_meta($link_id, 'prli_dynamic_redirection', $dynamic_redirection);
|
362 |
-
|
363 |
-
$target_url_weight = 100;
|
364 |
-
$url_rotations = $url_rotation_weights = array();
|
365 |
-
$enable_split_test = false;
|
366 |
-
$split_test_goal_link = '';
|
367 |
-
|
368 |
-
if($dynamic_redirection == 'rotate') {
|
369 |
-
$target_url_weight = isset($_POST['target_url_weight']) && is_numeric($_POST['target_url_weight']) ? PrliUtils::clamp((int) $_POST['target_url_weight'], 0, 100) : 100;
|
370 |
-
$url_rotations = isset($_POST['url_rotations']) && is_array($_POST['url_rotations']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['url_rotations']))) : array();
|
371 |
-
$url_rotation_weights = isset($_POST['url_rotation_weights']) && is_array($_POST['url_rotation_weights']) ? array_map(function ($value) { return PrliUtils::clamp((int) $value, 0, 100); }, wp_unslash($_POST['url_rotation_weights'])) : array();
|
372 |
-
$enable_split_test = isset($_POST['enable_split_test']);
|
373 |
-
$split_test_goal_link = isset($_POST['split_test_goal_link']) && is_numeric($_POST['split_test_goal_link']) ? (int) $_POST['split_test_goal_link'] : '';
|
374 |
-
}
|
375 |
-
|
376 |
-
$prli_link_meta->update_link_meta($link_id, 'prli-target-url-weight', $target_url_weight);
|
377 |
-
$plp_link_rotation->updateLinkRotations($link_id, $url_rotations, $url_rotation_weights);
|
378 |
-
$prli_link_meta->update_link_meta($link_id, 'prli-enable-split-test', $enable_split_test);
|
379 |
-
$prli_link_meta->update_link_meta($link_id, 'prli-split-test-goal-link', $split_test_goal_link);
|
380 |
-
|
381 |
-
$geo_url = $geo_countries = array();
|
382 |
-
|
383 |
-
if($dynamic_redirection == 'geo') {
|
384 |
-
$geo_url = isset($_POST['prli_geo_url']) && is_array($_POST['prli_geo_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_geo_url']))) : array();
|
385 |
-
$geo_countries = isset($_POST['prli_geo_countries']) && is_array($_POST['prli_geo_countries']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_geo_countries'])) : array();
|
386 |
-
}
|
387 |
-
|
388 |
-
$prli_link_meta->update_link_meta($link_id, 'geo_url', $geo_url);
|
389 |
-
$prli_link_meta->update_link_meta($link_id, 'geo_countries', $geo_countries);
|
390 |
-
|
391 |
-
$tech_url = $tech_device = $tech_os = $tech_browser = array();
|
392 |
-
|
393 |
-
if($dynamic_redirection == 'tech') {
|
394 |
-
$tech_url = isset($_POST['prli_tech_url']) && is_array($_POST['prli_tech_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_tech_url']))) : array();
|
395 |
-
$tech_device = isset($_POST['prli_tech_device']) && is_array($_POST['prli_tech_device']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_device'])) : array();
|
396 |
-
$tech_os = isset($_POST['prli_tech_os']) && is_array($_POST['prli_tech_os']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_os'])) : array();
|
397 |
-
$tech_browser = isset($_POST['prli_tech_browser']) && is_array($_POST['prli_tech_browser']) ? array_map('sanitize_key', wp_unslash($_POST['prli_tech_browser'])) : array();
|
398 |
-
}
|
399 |
-
|
400 |
-
$prli_link_meta->update_link_meta($link_id, 'tech_url', $tech_url);
|
401 |
-
$prli_link_meta->update_link_meta($link_id, 'tech_device', $tech_device);
|
402 |
-
$prli_link_meta->update_link_meta($link_id, 'tech_os', $tech_os);
|
403 |
-
$prli_link_meta->update_link_meta($link_id, 'tech_browser', $tech_browser);
|
404 |
-
|
405 |
-
$time_url = $time_start = $time_end = array();
|
406 |
-
|
407 |
-
if($dynamic_redirection == 'time') {
|
408 |
-
$time_url = isset($_POST['prli_time_url']) && is_array($_POST['prli_time_url']) ? array_map('esc_url_raw', array_map('trim', wp_unslash($_POST['prli_time_url']))) : array();
|
409 |
-
$time_start = isset($_POST['prli_time_start']) && is_array($_POST['prli_time_start']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_time_start'])) : array();
|
410 |
-
$time_end = isset($_POST['prli_time_end']) && is_array($_POST['prli_time_end']) ? array_map('sanitize_text_field', wp_unslash($_POST['prli_time_end'])) : array();
|
411 |
-
}
|
412 |
-
|
413 |
-
$prli_link_meta->update_link_meta($link_id, 'time_url', $time_url);
|
414 |
-
$prli_link_meta->update_link_meta($link_id, 'time_start', $time_start);
|
415 |
-
$prli_link_meta->update_link_meta($link_id, 'time_end', $time_end);
|
416 |
-
|
417 |
-
$prli_link_meta->update_link_meta($link_id, 'google_tracking', isset($_POST['google_tracking']));
|
418 |
-
$prli_link_meta->update_link_meta($link_id, 'delay', isset($_POST['delay']) && is_numeric($_POST['delay']) ? (int) $_POST['delay'] : 0);
|
419 |
-
$prli_link_meta->update_link_meta($link_id, 'head_scripts', isset($_POST['head-scripts']) && is_string($_POST['head-scripts']) ? PrliUtils::sanitize_html(stripslashes($_POST['head-scripts'])) : '');
|
420 |
-
|
421 |
-
$prli_link_meta->update_link_meta($link_id, 'enable_expire', isset($_POST['enable_expire']));
|
422 |
-
$prli_link_meta->update_link_meta($link_id, 'expire_type', isset($_POST['expire_type']) && is_string($_POST['expire_type']) ? sanitize_key(stripslashes($_POST['expire_type'])) : 'date');
|
423 |
-
$prli_link_meta->update_link_meta($link_id, 'expire_date', isset($_POST['expire_date']) && is_string($_POST['expire_date']) ? sanitize_text_field(stripslashes($_POST['expire_date'])) : '');
|
424 |
-
$prli_link_meta->update_link_meta($link_id, 'expire_clicks', isset($_POST['expire_clicks']) && is_numeric($_POST['expire_clicks']) ? (int) $_POST['expire_clicks'] : 0);
|
425 |
-
$prli_link_meta->update_link_meta($link_id, 'enable_expired_url', isset($_POST['enable_expired_url']));
|
426 |
-
$prli_link_meta->update_link_meta($link_id, 'expired_url', isset($_POST['expired_url']) && is_string($_POST['expired_url']) ? esc_url_raw(trim(stripslashes($_POST['expired_url']))) : '');
|
427 |
-
}
|
428 |
-
|
429 |
-
/** This is where we do link rotation or geolocated redirects */
|
430 |
-
public function customize_target_url($target) {
|
431 |
-
global $plp_link_rotation, $prli_link_meta, $prli_utils, $prli_link;
|
432 |
-
|
433 |
-
if(($expired_url = PlpUtils::is_link_expired($target['link_id']))) {
|
434 |
-
if($expired_url==404) {
|
435 |
-
// TODO: Not totally sure how to ensure this will use the WordPress 404 mechanism...figure it out
|
436 |
-
// For now just throw a 404 and render our page here
|
437 |
-
status_header(404);
|
438 |
-
|
439 |
-
wp_register_style('prli-bootstrap', PRLI_VENDOR_LIB_URL . '/bootstrap/bootstrap.min.css', array(), '3.3.6');
|
440 |
-
wp_register_style('prli-bootstrap-theme', PRLI_VENDOR_LIB_URL . '/bootstrap/bootstrap-theme.min.css', array('prli-bootstrap'), '3.3.6');
|
441 |
-
|
442 |
-
wp_add_inline_style('prli-bootstrap-theme', 'body { background-color: #dedede; } p { font-size: 120%; }');
|
443 |
-
|
444 |
-
require(PLP_VIEWS_PATH.'/links/link-has-expired.php');
|
445 |
-
exit;
|
446 |
-
}
|
447 |
-
else {
|
448 |
-
return array('url' => $expired_url, 'link_id' => $target['link_id']);
|
449 |
-
}
|
450 |
-
}
|
451 |
-
|
452 |
-
$dynamic_redirection = $prli_link_meta->get_link_meta($target['link_id'], 'prli_dynamic_redirection', true);
|
453 |
-
|
454 |
-
if((empty($dynamic_redirection) || $dynamic_redirection=='rotate') &&
|
455 |
-
$plp_link_rotation->there_are_rotations_for_this_link($target['link_id'])) {
|
456 |
-
return array('url' => $plp_link_rotation->get_target_url($target['link_id']), 'link_id' => $target['link_id']);
|
457 |
-
}
|
458 |
-
else if(!empty($dynamic_redirection) && $dynamic_redirection=='geo') {
|
459 |
-
$lookup = $this->get_country_lookup($target['link_id']);
|
460 |
-
$country = PlpUtils::country_by_ip($prli_utils->get_current_client_ip());
|
461 |
-
|
462 |
-
if(!empty($country) && isset($lookup[$country]) && !empty($lookup[$country])) {
|
463 |
-
return array('url' => $lookup[$country], 'link_id' => $target['link_id']);
|
464 |
-
}
|
465 |
-
}
|
466 |
-
else if(!empty($dynamic_redirection) && $dynamic_redirection=='tech') {
|
467 |
-
$binfo = $prli_utils->php_get_browser();
|
468 |
-
|
469 |
-
$tech_urls = $prli_link_meta->get_link_meta($target['link_id'], 'tech_url');
|
470 |
-
$tech_devices = $prli_link_meta->get_link_meta($target['link_id'], 'tech_device');
|
471 |
-
$tech_oses = $prli_link_meta->get_link_meta($target['link_id'], 'tech_os');
|
472 |
-
$tech_browsers = $prli_link_meta->get_link_meta($target['link_id'], 'tech_browser');
|
473 |
-
|
474 |
-
if(is_array($tech_urls) && !empty($tech_urls)) {
|
475 |
-
$ti = $this->get_tech_info($binfo);
|
476 |
-
foreach($tech_urls as $i => $tech_url) {
|
477 |
-
if(in_array($tech_devices[$i],$ti['devices']) &&
|
478 |
-
in_array($tech_oses[$i],$ti['oses']) &&
|
479 |
-
in_array($tech_browsers[$i],$ti['browsers'])) {
|
480 |
-
return array('url' => $tech_url, 'link_id' => $target['link_id']);
|
481 |
-
}
|
482 |
-
}
|
483 |
-
}
|
484 |
-
}
|
485 |
-
else if(!empty($dynamic_redirection) && $dynamic_redirection=='time') {
|
486 |
-
if(($time_url = PlpUtils::is_link_time_redirect_active($target['link_id']))) {
|
487 |
-
return array('url' => $time_url, 'link_id' => $target['link_id']);
|
488 |
-
}
|
489 |
-
}
|
490 |
-
|
491 |
-
return $target;
|
492 |
-
}
|
493 |
-
|
494 |
-
/** Return a single array able to lookup a target url from a country code based
|
495 |
-
* on the values entered with the geo-location specific redirects.
|
496 |
-
*/
|
497 |
-
private function get_country_lookup($link_id) {
|
498 |
-
global $prli_link_meta;
|
499 |
-
|
500 |
-
$dynamic_redirection = $prli_link_meta->get_link_meta($link_id, 'prli_dynamic_redirection', true);
|
501 |
-
if(!empty($dynamic_redirection) && $dynamic_redirection=='geo') {
|
502 |
-
$geo_url = $prli_link_meta->get_link_meta($link_id, 'geo_url');
|
503 |
-
$geo_countries = $prli_link_meta->get_link_meta($link_id, 'geo_countries');
|
504 |
-
|
505 |
-
$lookup = array();
|
506 |
-
foreach($geo_countries as $i => $cstr) {
|
507 |
-
$cs = explode(',', $cstr);
|
508 |
-
foreach($cs as $ci => $country) {
|
509 |
-
if(!empty($country) &&
|
510 |
-
preg_match('/\[([a-zA-Z]+)\]/i', $country, $m) &&
|
511 |
-
!empty($m[1]) &&
|
512 |
-
!isset($lookup[$m[1]])) { // First country set wins
|
513 |
-
$lookup[strtoupper($m[1])] = $geo_url[$i];
|
514 |
-
}
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
return $lookup;
|
519 |
-
}
|
520 |
-
|
521 |
-
return false;
|
522 |
-
}
|
523 |
-
|
524 |
-
private function get_tech_info($info) {
|
525 |
-
// Devices
|
526 |
-
$devices=array('any');
|
527 |
-
|
528 |
-
if($info['ismobiledevice']===true ||
|
529 |
-
$info['ismobiledevice']==='true') {
|
530 |
-
$devices[]='mobile';
|
531 |
-
}
|
532 |
-
|
533 |
-
if($info['istablet']===true ||
|
534 |
-
$info['istablet']==='true') {
|
535 |
-
$devices[]='tablet';
|
536 |
-
}
|
537 |
-
if(($info['istablet']===false ||
|
538 |
-
$info['istablet']==='false') &&
|
539 |
-
($info['ismobiledevice']===true ||
|
540 |
-
$info['ismobiledevice']==='true')) {
|
541 |
-
$devices[]='phone';
|
542 |
-
}
|
543 |
-
|
544 |
-
if(($info['istablet']===false ||
|
545 |
-
$info['istablet']==='false') &&
|
546 |
-
($info['ismobiledevice']===false ||
|
547 |
-
$info['ismobiledevice']==='false')) {
|
548 |
-
$devices[]='desktop';
|
549 |
-
}
|
550 |
-
|
551 |
-
// Operating Systems
|
552 |
-
$oses = array('any');
|
553 |
-
$info_os = strtolower($info['platform']);
|
554 |
-
$windows_oses = array( 'win10', 'win32', 'win7', 'win8', 'win8.1', 'winnt', 'winvista' );
|
555 |
-
$other_oses = array('android', 'linux', 'ios', 'macosx');
|
556 |
-
|
557 |
-
// map macos to macosx for now
|
558 |
-
$info_os = (($info_os=='macos') ? 'macosx' : $info_os);
|
559 |
-
|
560 |
-
if(in_array($info_os, $other_oses)) {
|
561 |
-
$oses[] = $info_os;
|
562 |
-
}
|
563 |
-
else if(in_array($info_os, $windows_oses)) {
|
564 |
-
$oses[] = 'win';
|
565 |
-
}
|
566 |
-
|
567 |
-
$browsers = array('any');
|
568 |
-
$info_browser = strtolower($info['browser']);
|
569 |
-
$android_browsers = array('android', 'android webview');
|
570 |
-
$ie_browsers = array('fake ie', 'ie');
|
571 |
-
$other_browsers = array('chrome', 'chromium', 'coast', 'edge', 'firefox', 'opera', 'safari', 'silk', 'kindle');
|
572 |
-
|
573 |
-
if(in_array($info_browser, $other_browsers)) {
|
574 |
-
$browsers[] = $info_browser;
|
575 |
-
}
|
576 |
-
else if(in_array($info_browser, $ie_browsers)) {
|
577 |
-
$browsers[] = 'ie';
|
578 |
-
}
|
579 |
-
else if(in_array($info_browser, $android_browsers)) {
|
580 |
-
$browsers[] = 'android';
|
581 |
-
}
|
582 |
-
|
583 |
-
return compact('devices','oses','browsers');
|
584 |
-
}
|
585 |
-
|
586 |
-
public function record_rotation_click($args) {
|
587 |
-
$link_id = $args['link_id'];
|
588 |
-
$click_id = $args['click_id'];
|
589 |
-
$target_url = $args['url'];
|
590 |
-
|
591 |
-
global $plp_link_rotation;
|
592 |
-
if($plp_link_rotation->there_are_rotations_for_this_link($link_id)) {
|
593 |
-
$plp_link_rotation->record_click($click_id,$link_id,$target_url);
|
594 |
-
}
|
595 |
-
}
|
596 |
-
|
597 |
-
/***** ADD SHORTLINK AUTO-DISCOVERY *****/
|
598 |
-
public function shorturl_autodiscover() {
|
599 |
-
global $post;
|
600 |
-
|
601 |
-
if(!is_object($post)) { return; }
|
602 |
-
|
603 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post->ID,"_pretty-link",true);
|
604 |
-
|
605 |
-
if($pretty_link_id && (is_single() || is_page())) {
|
606 |
-
$shorturl = prli_get_pretty_link_url($pretty_link_id);
|
607 |
-
|
608 |
-
if($shorturl && !empty($shorturl)) {
|
609 |
-
?><link rel="shorturl" href="<?php echo esc_url($shorturl); ?>" /><?php
|
610 |
-
}
|
611 |
-
}
|
612 |
-
}
|
613 |
-
|
614 |
-
/***************** ADD PRETTY BAR, PIXEL and CLOAKED REDIRECTION *********************/
|
615 |
-
public function redirection_types($v, $selected = false) {
|
616 |
-
$prettybar = isset($v['redirect_type']['prettybar']) ? $v['redirect_type']['prettybar'] : '';
|
617 |
-
$cloak = isset($v['redirect_type']['cloak']) ? $v['redirect_type']['cloak'] : '';
|
618 |
-
$pixel = isset($v['redirect_type']['pixel']) ? $v['redirect_type']['pixel'] : '';
|
619 |
-
$metarefresh = isset($v['redirect_type']['metarefresh']) ? $v['redirect_type']['metarefresh'] : '';
|
620 |
-
$javascript = isset($v['redirect_type']['javascript']) ? $v['redirect_type']['javascript'] : '';
|
621 |
-
|
622 |
-
?>
|
623 |
-
<option value="prettybar"<?php echo $prettybar; ?> <?php if($selected) { selected('prettybar', $selected); } ?>><?php esc_html_e('Pretty Bar', 'pretty-link'); ?> </option>
|
624 |
-
<option value="cloak"<?php echo $cloak; ?> <?php if($selected) { selected('cloak', $selected); } ?>><?php esc_html_e('Cloaked', 'pretty-link'); ?> </option>
|
625 |
-
<option value="pixel"<?php echo $pixel; ?> <?php if($selected) { selected('pixel', $selected); } ?>><?php esc_html_e('Pixel', 'pretty-link'); ?> </option>
|
626 |
-
<option value="metarefresh"<?php echo $metarefresh; ?> <?php if($selected) { selected('metarefresh', $selected); } ?>><?php esc_html_e('Meta Refresh', 'pretty-link'); ?> </option>
|
627 |
-
<option value="javascript"<?php echo $javascript; ?> <?php if($selected) { selected('javascript', $selected); } ?>><?php esc_html_e('Javascript', 'pretty-link'); ?> </option>
|
628 |
-
<?php
|
629 |
-
}
|
630 |
-
|
631 |
-
public function issue_cloaked_redirect($redirect_type, $pretty_link, $pretty_link_url, $param_string) {
|
632 |
-
global $prli_blogurl, $prli_link_meta, $prli_blogname;
|
633 |
-
|
634 |
-
$google_tracking = (($prli_link_meta->get_link_meta($pretty_link->id, 'google_tracking', true) == 1)?true:false);
|
635 |
-
$delay = $prli_link_meta->get_link_meta($pretty_link->id, 'delay', true);
|
636 |
-
|
637 |
-
header("Content-Type: text/html", true);
|
638 |
-
header("HTTP/1.1 200 OK", true);
|
639 |
-
|
640 |
-
switch($redirect_type) {
|
641 |
-
case 'pixel':
|
642 |
-
break;
|
643 |
-
case 'prettybar':
|
644 |
-
require_once(PLP_VIEWS_PATH . '/links/prettybar-redirect.php');
|
645 |
-
break;
|
646 |
-
case 'cloak':
|
647 |
-
wp_register_style('prli-cloaked-redirect', PRLI_CSS_URL . '/cloaked-redirect.css', array(), PRLI_VERSION);
|
648 |
-
require_once(PLP_VIEWS_PATH . '/links/cloaked-redirect.php');
|
649 |
-
break;
|
650 |
-
case 'metarefresh':
|
651 |
-
require_once(PLP_VIEWS_PATH . '/links/metarefresh-redirect.php');
|
652 |
-
break;
|
653 |
-
case 'javascript':
|
654 |
-
wp_register_script('plp-javascript-redirect', PLP_JS_URL . '/javascript-redirect.js', array(), PRLI_VERSION);
|
655 |
-
wp_localize_script('plp-javascript-redirect', 'plpJsRedirectL10n', array(
|
656 |
-
'url' => esc_url_raw($pretty_link_url . $param_string),
|
657 |
-
'delay' => ((int) $delay) * 1000
|
658 |
-
));
|
659 |
-
require_once(PLP_VIEWS_PATH . '/links/javascript-redirect.php');
|
660 |
-
break;
|
661 |
-
default:
|
662 |
-
wp_redirect("{$pretty_link_url}{$param_string}", 302);
|
663 |
-
exit;
|
664 |
-
}
|
665 |
-
}
|
666 |
-
|
667 |
-
public function default_redirection_options($link_redirect_type) {
|
668 |
-
?>
|
669 |
-
<option value="prettybar" <?php echo (($link_redirect_type == 'prettybar')?' selected="selected"':''); ?>><?php esc_html_e('Pretty Bar', 'pretty-link'); ?></option>
|
670 |
-
<option value="cloak" <?php echo (($link_redirect_type == 'cloak')?' selected="selected"':''); ?>><?php esc_html_e('Cloak', 'pretty-link'); ?></option>
|
671 |
-
<option value="pixel" <?php echo (($link_redirect_type == 'pixel')?' selected="selected"':''); ?>><?php esc_html_e('Pixel', 'pretty-link'); ?></option>
|
672 |
-
<option value="metarefresh" <?php echo (($link_redirect_type == 'metarefresh')?' selected="selected"':''); ?>><?php esc_html_e('Meta Refresh', 'pretty-link'); ?></option>
|
673 |
-
<option value="javascript" <?php echo (($link_redirect_type == 'javascript')?' selected="selected"':''); ?>><?php esc_html_e('Javascript', 'pretty-link'); ?></option>
|
674 |
-
<?php
|
675 |
-
}
|
676 |
-
|
677 |
-
/** Deletes all the pro-specific meta about a link right before the link is deleted.
|
678 |
-
* TODO: Relocate most of this to a model asap
|
679 |
-
*/
|
680 |
-
public function delete_link($id) {
|
681 |
-
global $wpdb, $plp_keyword, $plp_report, $plp_link_rotation;
|
682 |
-
$query = $wpdb->prepare("DELETE FROM {$plp_keyword->table_name} WHERE link_id=%d", $id);
|
683 |
-
$wpdb->query($query);
|
684 |
-
|
685 |
-
$query = $wpdb->prepare("UPDATE {$plp_report->table_name} SET goal_link_id=NULL WHERE goal_link_id=%d", $id);
|
686 |
-
$wpdb->query($query);
|
687 |
-
|
688 |
-
$query = $wpdb->prepare("DELETE FROM {$plp_report->links_table_name} WHERE link_id=%d", $id);
|
689 |
-
$wpdb->query($query);
|
690 |
-
|
691 |
-
$query = $wpdb->prepare("DELETE FROM {$plp_link_rotation->table_name} WHERE link_id=%d", $id);
|
692 |
-
$wpdb->query($query);
|
693 |
-
|
694 |
-
$query = $wpdb->prepare("DELETE FROM {$plp_link_rotation->cr_table_name} WHERE link_id=%d", $id);
|
695 |
-
$wpdb->query($query);
|
696 |
-
|
697 |
-
$query = $wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_key=%s AND meta_value=%s", '_pretty-link', $id);
|
698 |
-
$wpdb->query($query);
|
699 |
-
}
|
700 |
-
|
701 |
-
public function custom_link_options() {
|
702 |
-
global $plp_options;
|
703 |
-
require( PLP_VIEWS_PATH . '/links/link-options.php');
|
704 |
-
}
|
705 |
-
|
706 |
-
public function store_link_options() {
|
707 |
-
global $plp_options;
|
708 |
-
|
709 |
-
$plp_options->google_tracking = (int)isset($_REQUEST[ $plp_options->google_tracking_str ]);
|
710 |
-
$plp_options->generate_qr_codes = (int)isset($_REQUEST[ $plp_options->generate_qr_codes_str ]);
|
711 |
-
$plp_options->qr_code_links = (int)isset($_REQUEST[ $plp_options->qr_code_links_str ]);
|
712 |
-
$plp_options->global_head_scripts = isset($_REQUEST[$plp_options->global_head_scripts_str]) && is_string($_REQUEST[$plp_options->global_head_scripts_str]) ? PrliUtils::sanitize_html(stripslashes($_REQUEST[$plp_options->global_head_scripts_str])) : '';
|
713 |
-
$plp_options->base_slug_prefix = isset($_REQUEST[$plp_options->base_slug_prefix_str]) && is_string($_REQUEST[$plp_options->base_slug_prefix_str]) ? sanitize_title(stripslashes($_REQUEST[$plp_options->base_slug_prefix_str]), '') : '';
|
714 |
-
$plp_options->num_slug_chars = isset($_REQUEST[$plp_options->num_slug_chars_str]) && is_numeric($_REQUEST[$plp_options->num_slug_chars_str]) ? PrliUtils::clamp((int) $_REQUEST[$plp_options->num_slug_chars_str], 0, 500) : 4;
|
715 |
-
|
716 |
-
// Save the posted value in the database
|
717 |
-
$plp_options->store();
|
718 |
-
}
|
719 |
-
|
720 |
-
public function create_link($link_id, $values) {
|
721 |
-
global $plp_options, $prli_link_meta;
|
722 |
-
|
723 |
-
if(!isset($values['google_tracking'])) {
|
724 |
-
$prli_link_meta->update_link_meta($link_id, 'google_tracking', $plp_options->google_tracking);
|
725 |
-
}
|
726 |
-
}
|
727 |
-
|
728 |
-
public function qr_code_link($pretty_link_id) {
|
729 |
-
global $plp_options;
|
730 |
-
$pretty_link_url = prli_get_pretty_link_url($pretty_link_id);
|
731 |
-
|
732 |
-
ob_start();
|
733 |
-
|
734 |
-
if($plp_options->qr_code_links):
|
735 |
-
?><a href="<?php echo esc_url($pretty_link_url . '/qr.png'); ?>" title="<?php echo esc_attr(sprintf(__('View QR Code for this link: %s', 'pretty-link'), $pretty_link_url)); ?>" target="_blank"><?php esc_html_e('QR Code', 'pretty-link'); ?></a><?php
|
736 |
-
endif;
|
737 |
-
|
738 |
-
if($plp_options->generate_qr_codes):
|
739 |
-
?><a href="<?php echo esc_url($pretty_link_url . '/qr.png?download=' . wp_create_nonce('prli-generate-qr-code')); ?>" title="<?php echo esc_attr(sprintf(__('Download QR Code for this link: %s', 'pretty-link'), $pretty_link_url)); ?>"><?php esc_html_e('QR Code', 'pretty-link'); ?></a><?php
|
740 |
-
endif;
|
741 |
-
|
742 |
-
return ob_get_clean();
|
743 |
-
}
|
744 |
-
|
745 |
-
public function generate_qr_code($pretty_link_id, $slug) {
|
746 |
-
global $prli_link, $plp_options;
|
747 |
-
|
748 |
-
if( $plp_options->qr_code_links or
|
749 |
-
( $plp_options->generate_qr_codes and
|
750 |
-
isset($_REQUEST['download']) and
|
751 |
-
wp_verify_nonce($_REQUEST['download'], 'prli-generate-qr-code') ) ) {
|
752 |
-
|
753 |
-
$qr_regexp = '#/qr\.png$#';
|
754 |
-
|
755 |
-
if(!$pretty_link_id and preg_match($qr_regexp, $slug)) {
|
756 |
-
$slug_sans_qr = preg_replace($qr_regexp, '', $slug);
|
757 |
-
|
758 |
-
if($pretty_link = $prli_link->getOneFromSlug( $slug_sans_qr )) {
|
759 |
-
$pretty_link_url = prli_get_pretty_link_url($pretty_link->id);
|
760 |
-
|
761 |
-
header("Content-Type: image/png");
|
762 |
-
|
763 |
-
if(isset($_REQUEST['download']) and wp_verify_nonce($_REQUEST['download'], 'prli-generate-qr-code')) {
|
764 |
-
header("HTTP/1.1 200 OK"); // Have to hard code this for some reason?
|
765 |
-
header("Content-Disposition: attachment;filename=\"" . $slug_sans_qr . "_qr.png\"");
|
766 |
-
header("Content-Transfer-Encoding: binary");
|
767 |
-
//header("Pragma: public");
|
768 |
-
}
|
769 |
-
|
770 |
-
@include PLP_VENDOR_PATH."/phpqrcode/qrlib.php";
|
771 |
-
|
772 |
-
QRcode::png($pretty_link_url, false, QR_ECLEVEL_L, 20, 2);
|
773 |
-
|
774 |
-
exit;
|
775 |
-
}
|
776 |
-
}
|
777 |
-
}
|
778 |
-
|
779 |
-
return $pretty_link_id;
|
780 |
-
}
|
781 |
-
|
782 |
-
public function link_list_end_icons($link) {
|
783 |
-
global $prli_link_meta, $plp_link_rotation;
|
784 |
-
|
785 |
-
$dynamic_redirection = $prli_link_meta->get_link_meta($link->id, 'prli_dynamic_redirection', true);
|
786 |
-
$enable_expire = $prli_link_meta->get_link_meta($link->id, 'enable_expire', true);
|
787 |
-
$expire_type = $prli_link_meta->get_link_meta($link->id, 'expire_type', true);
|
788 |
-
|
789 |
-
// Ensure reverse compatibility
|
790 |
-
if(empty($dynamic_redirection)) {
|
791 |
-
$dynamic_redirection = 'none';
|
792 |
-
|
793 |
-
if($plp_link_rotation->there_are_rotations_for_this_link($link->id)) {
|
794 |
-
$dynamic_redirection = 'rotate';
|
795 |
-
}
|
796 |
-
}
|
797 |
-
|
798 |
-
if(empty($enable_expire) || empty($expire_type)) {
|
799 |
-
$enable_expire = false;
|
800 |
-
$expire_type = 'none';
|
801 |
-
}
|
802 |
-
|
803 |
-
if($enable_expire) {
|
804 |
-
if($expire_type=='date') {
|
805 |
-
$expire_date = $prli_link_meta->get_link_meta($link->id, 'expire_date', true);
|
806 |
-
$expire_icon = 'history';
|
807 |
-
$expire_class = '';
|
808 |
-
|
809 |
-
if(($expired_url = PlpUtils::is_link_expired($link->id))) {
|
810 |
-
$expire_class = 'prli-red';
|
811 |
-
if($expired_url==404) {
|
812 |
-
$expire_message = sprintf(__('This link expired on %1$s and will now cause a 404 error when visited', 'pretty-link'), $expire_date);
|
813 |
-
}
|
814 |
-
else {
|
815 |
-
$expire_message = sprintf(__('This link expired on %1$s and now redirects to %2$s', 'pretty-link'), $expire_date, $expired_url);
|
816 |
-
}
|
817 |
-
}
|
818 |
-
else {
|
819 |
-
$expire_message = sprintf(__('This link is set to expire after the date %s', 'pretty-link'), $expire_date);
|
820 |
-
}
|
821 |
-
}
|
822 |
-
else if($expire_type=='clicks') {
|
823 |
-
$expire_clicks = $prli_link_meta->get_link_meta($link->id, 'expire_clicks', true);
|
824 |
-
$expire_icon = 'ccw';
|
825 |
-
$expire_class = '';
|
826 |
-
|
827 |
-
if(($expired_url = PlpUtils::is_link_expired($link->id))) {
|
828 |
-
$expire_class = 'prli-red';
|
829 |
-
if($expired_url==404) {
|
830 |
-
$expire_message = sprintf(__('This link expired after %d clicks and will now cause a 404 error when visited', 'pretty-link'), $expire_clicks);
|
831 |
-
}
|
832 |
-
else {
|
833 |
-
$expire_message = sprintf(__('This link expired after %1$d clicks and now redirects to %2$s', 'pretty-link'), $expire_clicks, $expired_url);
|
834 |
-
}
|
835 |
-
}
|
836 |
-
else {
|
837 |
-
$expire_message = sprintf(__('This link is set to expire after %d clicks', 'pretty-link'), $expire_clicks);
|
838 |
-
}
|
839 |
-
}
|
840 |
-
|
841 |
-
?><i class="pl-list-icon pl-icon-<?php echo $expire_icon; ?> <?php echo $expire_class; ?>" title="<?php echo esc_attr($expire_message); ?>"></i><?php
|
842 |
-
}
|
843 |
-
|
844 |
-
if($dynamic_redirection=='rotate') {
|
845 |
-
?><i class="pl-list-icon pl-icon-shuffle" title="<?php esc_attr_e('This link has additional Target URL rotations', 'pretty-link'); ?>"></i><?php
|
846 |
-
}
|
847 |
-
else if($dynamic_redirection=='geo') {
|
848 |
-
?><i class="pl-list-icon pl-icon-globe" title="<?php esc_attr_e('This link has additional Geographic Target URLs', 'pretty-link'); ?>"></i><?php
|
849 |
-
}
|
850 |
-
else if($dynamic_redirection=='tech') {
|
851 |
-
?><i class="pl-list-icon pl-icon-mobile" title="<?php esc_attr_e('This link has additional Technology Dependent Conditional Target URLs', 'pretty-link'); ?>"></i><?php
|
852 |
-
}
|
853 |
-
else if($dynamic_redirection=='time') {
|
854 |
-
$time_class = '';
|
855 |
-
if(($time_url = PlpUtils::is_link_time_redirect_active($link->id))) {
|
856 |
-
$time_message = sprintf(__('A Time Period Redirect is currently active for this link. When visited it will currently redirect to %s rather than the Target URL unless the link is expired.', 'pretty-link'), $time_url);
|
857 |
-
$time_class = 'prli-green';
|
858 |
-
}
|
859 |
-
else {
|
860 |
-
$time_message = __('Time Period Redirects have been setup for this link but the current time is not within any of them currently.', 'pretty-link');
|
861 |
-
}
|
862 |
-
|
863 |
-
?><i class="pl-list-icon pl-icon-clock <?php echo $time_class; ?>" title="<?php echo esc_attr($time_message); ?>"></i><?php
|
864 |
-
}
|
865 |
-
}
|
866 |
-
|
867 |
-
public function ajax_search_countries() {
|
868 |
-
if(!PrliUtils::is_authorized()) {
|
869 |
-
echo "Why you creepin?";
|
870 |
-
die();
|
871 |
-
}
|
872 |
-
|
873 |
-
if(isset($_REQUEST['q']) && !empty($_REQUEST['q']) && is_string($_REQUEST['q'])) {
|
874 |
-
$res = '';
|
875 |
-
$countries = require(PLP_I18N_PATH.'/countries.php');
|
876 |
-
|
877 |
-
$q = sanitize_text_field(stripslashes($_REQUEST['q']));
|
878 |
-
|
879 |
-
foreach($countries as $code => $name) {
|
880 |
-
if(preg_match('/'.preg_quote($q).'/i', $code) ||
|
881 |
-
preg_match('/'.preg_quote($q).'/i', $name)) {
|
882 |
-
$res .= "{$name} [{$code}]\n";
|
883 |
-
}
|
884 |
-
}
|
885 |
-
|
886 |
-
echo $res;
|
887 |
-
}
|
888 |
-
|
889 |
-
exit;
|
890 |
-
}
|
891 |
-
}
|
892 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpOptionsController.php
DELETED
@@ -1,249 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpOptionsController extends PrliBaseController {
|
5 |
-
public $opt_fields;
|
6 |
-
|
7 |
-
public function load_hooks() {
|
8 |
-
add_action('prli_admin_general_options', array($this, 'general'));
|
9 |
-
add_action('prli_admin_options_pages', array($this, 'display'));
|
10 |
-
|
11 |
-
add_filter( 'prli-validate-options', array($this, 'validate') );
|
12 |
-
add_filter( 'prli-update-options', array($this, 'update') );
|
13 |
-
add_filter( 'prli-store-options', array($this, 'store') );
|
14 |
-
|
15 |
-
$this->opt_fields = array(
|
16 |
-
'hidden_field_name' => 'prlipro_update_options',
|
17 |
-
'pages_auto' => 'prli_pages_auto',
|
18 |
-
'posts_auto' => 'prli_posts_auto',
|
19 |
-
'pages_category' => 'prli_pages_category',
|
20 |
-
'posts_category' => 'prli_posts_category',
|
21 |
-
'autocreate' => 'prli_autocreate',
|
22 |
-
'social_buttons' => 'prli_social_buttons',
|
23 |
-
'social_buttons_placement' => 'prli_social_buttons_placement',
|
24 |
-
'social_buttons_padding' => 'prli_social_buttons_padding',
|
25 |
-
'social_buttons_show_in_feed' => 'prli_social_buttons_show_in_feed',
|
26 |
-
'social_posts_buttons' => 'prli_social_posts_buttons',
|
27 |
-
'social_pages_buttons' => 'prli_social_pages_buttons',
|
28 |
-
'keyword_replacement_is_on' => 'prli_keyword_replacement_is_on',
|
29 |
-
'keywords_per_page' => 'prli_keywords_per_page',
|
30 |
-
'keyword_links_per_page' => 'prli_keyword_links_per_page',
|
31 |
-
'keyword_links_open_new_window' => 'prli_keyword_links_open_new_window',
|
32 |
-
'keyword_links_nofollow' => 'prli_keyword_links_nofollow',
|
33 |
-
'keyword_links_sponsored' => 'prli_keyword_links_sponsored',
|
34 |
-
'keyword_link_custom_css' => 'prli_keyword_link_custom_css',
|
35 |
-
'keyword_link_hover_custom_css' => 'prli_keyword_link_hover_custom_css',
|
36 |
-
'set_keyword_thresholds' => 'prli_set_keyword_thresholds',
|
37 |
-
'replace_urls_with_pretty_links' => 'prli_replace_urls_with_pretty_links',
|
38 |
-
'replace_urls_with_pretty_links_blacklist' => 'prli_replace_urls_with_pretty_links_blacklist',
|
39 |
-
'replace_keywords_in_comments' => 'prli_replace_keywords_in_comments',
|
40 |
-
'replace_keywords_in_feeds' => 'prli_replace_keywords_in_feeds',
|
41 |
-
'enable_link_to_disclosures' => 'prli_enable_link_to_disclosures',
|
42 |
-
'disclosures_link_url' => 'prli_disclosures_link_url',
|
43 |
-
'disclosures_link_text' => 'prli_disclosures_link_text',
|
44 |
-
'disclosures_link_position' => 'prli_disclosures_link_position',
|
45 |
-
'enable_keyword_link_disclosures' => 'prli_enable_keyword_link_disclosures',
|
46 |
-
'keyword_link_disclosure' => 'prli_keyword_link_disclosure',
|
47 |
-
'use_prettylink_url' => 'prli_use_prettylink_url',
|
48 |
-
'prettylink_url' => 'prli_prettylink_url',
|
49 |
-
'minimum_access_role' => 'prli_min_role',
|
50 |
-
'allow_public_link_creation' => 'prli_allow_public_link_creation',
|
51 |
-
'use_public_link_display_page' => 'prli_use_public_link_display_page',
|
52 |
-
'public_link_display_page' => 'prli_public_link_display_page',
|
53 |
-
'prettybar_image_url' => 'prli_prettybar_image_url',
|
54 |
-
'prettybar_background_image_url' => 'prli_prettybar_background_image_url',
|
55 |
-
'prettybar_color' => 'prli_prettybar_color',
|
56 |
-
'prettybar_text_color' => 'prli_prettybar_text_color',
|
57 |
-
'prettybar_link_color' => 'prli_prettybar_link_color',
|
58 |
-
'prettybar_hover_color' => 'prli_prettybar_hover_color',
|
59 |
-
'prettybar_visited_color' => 'prli_prettybar_visited_color',
|
60 |
-
'prettybar_show_title' => 'prli_prettybar_show_title',
|
61 |
-
'prettybar_show_description' => 'prli_prettybar_show_description',
|
62 |
-
'prettybar_show_share_links' => 'prli_prettybar_show_share_links',
|
63 |
-
'prettybar_show_target_url_link' => 'prli_prettybar_show_target_url_link',
|
64 |
-
'prettybar_title_limit' => 'prli_prettybar_title_limit',
|
65 |
-
'prettybar_desc_limit' => 'prli_prettybar_desc_limit',
|
66 |
-
'prettybar_link_limit' => 'prli_prettybar_link_limit',
|
67 |
-
'prettybar_hide_attrib_link' => 'prettybar_hide_attrib_link',
|
68 |
-
'prettybar_attrib_url' => 'prettybar_attrib_url'
|
69 |
-
);
|
70 |
-
}
|
71 |
-
|
72 |
-
public function display() {
|
73 |
-
global $prli_options, $plp_options;
|
74 |
-
|
75 |
-
extract($this->opt_fields);
|
76 |
-
|
77 |
-
$index_keywords = get_option('plp_index_keywords', false);
|
78 |
-
|
79 |
-
require_once(PLP_VIEWS_PATH.'/options/form.php');
|
80 |
-
}
|
81 |
-
|
82 |
-
public function general() {
|
83 |
-
global $plp_options;
|
84 |
-
|
85 |
-
extract($this->opt_fields);
|
86 |
-
|
87 |
-
require_once(PLP_VIEWS_PATH.'/options/general.php');
|
88 |
-
}
|
89 |
-
|
90 |
-
public function validate($errors=array()) {
|
91 |
-
extract( $this->opt_fields );
|
92 |
-
|
93 |
-
// Validate This
|
94 |
-
//if( !empty($params[ $prettybar_link_limit ]) && !preg_match( "#^[0-9]*$#", $params[ $prettybar_link_limit ] ) )
|
95 |
-
// $errors[] = __("PrettyBar Link Character Limit must be a number", 'pretty-link');
|
96 |
-
|
97 |
-
if( isset($_POST[$set_keyword_thresholds]) && empty($_POST[ $keywords_per_page ]) ) {
|
98 |
-
$errors[] = __('Keywords Per Page is required', 'pretty-link');
|
99 |
-
}
|
100 |
-
|
101 |
-
if( isset($_POST[$set_keyword_thresholds]) && empty($_POST[ $keyword_links_per_page ]) ) {
|
102 |
-
$errors[] = __('Keyword Links Per Page is required', 'pretty-link');
|
103 |
-
}
|
104 |
-
|
105 |
-
if( isset($_POST[ $use_prettylink_url ]) &&
|
106 |
-
!preg_match('/^http.?:\/\/.*\..*[^\/]$/', $_POST[ $prettylink_url ] )) {
|
107 |
-
$errors[] = __('You need to enter a valid Pretty Link Base URL now that you have selected "Use an alternate base url for your Pretty Links"', 'pretty-link');
|
108 |
-
}
|
109 |
-
|
110 |
-
if( isset($_POST[ $use_public_link_display_page ]) &&
|
111 |
-
!preg_match('/^http.?:\/\/.*\..*[^\/]$/', $_POST[ $public_link_display_page ] ) ) {
|
112 |
-
$errors[] = __('You need to enter a valid Public Link Display URL now that you have selected "Use a custom public link display page"', 'pretty-link');
|
113 |
-
}
|
114 |
-
|
115 |
-
if( !isset($_POST['prettybar_hide_attrib_link']) &&
|
116 |
-
!empty($_POST['prlipro-attrib-url']) &&
|
117 |
-
!preg_match('/^http.?:\/\/.*\..*$/', $_POST['prlipro-attrib-url'] ) ) {
|
118 |
-
$errors[] = __("Pretty Bar Attribution URL must be a correctly formatted URL", 'pretty-link');
|
119 |
-
}
|
120 |
-
|
121 |
-
return $errors;
|
122 |
-
}
|
123 |
-
|
124 |
-
public function update($params) {
|
125 |
-
global $prli_options, $plp_options;
|
126 |
-
|
127 |
-
extract( $this->opt_fields );
|
128 |
-
|
129 |
-
// Read their posted value
|
130 |
-
$plp_options->pages_auto = (int)isset($params[ $pages_auto ]);
|
131 |
-
$plp_options->posts_auto = (int)isset($params[ $posts_auto ]);
|
132 |
-
$plp_options->pages_category = isset($params[ $pages_category ]) && is_numeric($params[ $pages_category ]) ? (int) $params[ $pages_category ] : '';
|
133 |
-
$plp_options->posts_category = isset($params[ $posts_category ]) && is_numeric($params[ $posts_category ]) ? (int) $params[ $posts_category ] : '';
|
134 |
-
|
135 |
-
// This won't be set if the user has no public CPTs in place
|
136 |
-
$plp_options->autocreate = array();
|
137 |
-
|
138 |
-
if (isset($params[$autocreate]) && is_array($params[$autocreate])) {
|
139 |
-
foreach ($params[$autocreate] as $post_type => $fields) {
|
140 |
-
$post_type = sanitize_key($post_type);
|
141 |
-
|
142 |
-
if ($post_type) {
|
143 |
-
$plp_options->autocreate[$post_type] = array(
|
144 |
-
'enabled' => isset($fields['enabled']),
|
145 |
-
'category' => isset($fields['category']) && is_numeric($fields['category']) ? (int) $fields['category'] : '',
|
146 |
-
'socbtns' => isset($fields['socbtns'])
|
147 |
-
);
|
148 |
-
}
|
149 |
-
}
|
150 |
-
}
|
151 |
-
|
152 |
-
//$plp_options->social_buttons = $params[ $social_buttons ];
|
153 |
-
$new_social_buttons = $plp_options->default_social_buttons;
|
154 |
-
foreach( $new_social_buttons as $btn_name => $btn ) {
|
155 |
-
$new_social_buttons[$btn_name]['checked']=false;
|
156 |
-
}
|
157 |
-
|
158 |
-
if(isset($params[$social_buttons]) && is_array($params[$social_buttons])) {
|
159 |
-
foreach( array_reverse( $params[ $social_buttons ] ) as $btn_name => $btn_checked ) {
|
160 |
-
if (isset($new_social_buttons[$btn_name])) {
|
161 |
-
$btn = $new_social_buttons[$btn_name];
|
162 |
-
$btn['checked'] = true;
|
163 |
-
unset($new_social_buttons[$btn_name]);
|
164 |
-
array_unshift($new_social_buttons, $btn);
|
165 |
-
}
|
166 |
-
}
|
167 |
-
}
|
168 |
-
|
169 |
-
$plp_options->social_buttons = array_values($new_social_buttons);
|
170 |
-
$plp_options->social_buttons_placement = isset($params[ $social_buttons_placement ]) && is_string($params[ $social_buttons_placement ]) ? sanitize_key(stripslashes($params[ $social_buttons_placement ])) : '';
|
171 |
-
$plp_options->social_buttons_show_in_feed = (int)isset($params[ $social_buttons_show_in_feed ]);
|
172 |
-
//$plp_options->social_buttons_padding = $params[ $social_buttons_padding ];
|
173 |
-
$plp_options->social_posts_buttons = (int)isset($params[ $social_posts_buttons ]);
|
174 |
-
$plp_options->social_pages_buttons = (int)isset($params[ $social_pages_buttons ]);
|
175 |
-
$plp_options->keyword_replacement_is_on = (int)isset($params[ $keyword_replacement_is_on ]);
|
176 |
-
$plp_options->keyword_links_open_new_window = (int)isset($params[ $keyword_links_open_new_window ]);
|
177 |
-
$plp_options->keyword_links_nofollow = (int)isset($params[ $keyword_links_nofollow ]);
|
178 |
-
$plp_options->keyword_links_sponsored = (int)isset($params[ $keyword_links_sponsored ]);
|
179 |
-
$plp_options->keyword_link_custom_css = isset($params[ $keyword_link_custom_css ]) && is_string($params[ $keyword_link_custom_css ]) ? wp_strip_all_tags(stripslashes($params[ $keyword_link_custom_css ])) : '';
|
180 |
-
$plp_options->keyword_link_hover_custom_css = isset($params[ $keyword_link_hover_custom_css ]) && is_string($params[ $keyword_link_hover_custom_css ]) ? wp_strip_all_tags(stripslashes($params[ $keyword_link_hover_custom_css ])) : '';
|
181 |
-
$plp_options->replace_urls_with_pretty_links = (int)isset($params[ $replace_urls_with_pretty_links ]);
|
182 |
-
|
183 |
-
$plp_options->replace_urls_with_pretty_links_blacklist = isset($params[ $replace_urls_with_pretty_links_blacklist ]) && is_string($params[ $replace_urls_with_pretty_links_blacklist ]) ? sanitize_textarea_field(stripslashes($params[ $replace_urls_with_pretty_links_blacklist ])) : '';
|
184 |
-
$this->filter_domain_blacklist(); //Get rid of user entered garbage to make sure out input is valid
|
185 |
-
|
186 |
-
$plp_options->replace_keywords_in_comments = (int)isset($params[ $replace_keywords_in_comments ]);
|
187 |
-
$plp_options->replace_keywords_in_feeds = (int)isset($params[ $replace_keywords_in_feeds ]);
|
188 |
-
$plp_options->enable_link_to_disclosures = (int)isset($params[ $enable_link_to_disclosures ]);
|
189 |
-
$plp_options->disclosures_link_url = isset($params[ $disclosures_link_url ]) && is_string($params[ $disclosures_link_url ]) ? esc_url_raw(trim(stripslashes($params[ $disclosures_link_url ]))) : '';
|
190 |
-
$plp_options->disclosures_link_text = isset($params[ $disclosures_link_text ]) && is_string($params[ $disclosures_link_text ]) ? sanitize_text_field(stripslashes($params[ $disclosures_link_text ])) : '';
|
191 |
-
$plp_options->disclosures_link_position = isset($params[ $disclosures_link_position ]) && is_string($params[ $disclosures_link_position ]) ? sanitize_key(stripslashes($params[ $disclosures_link_position ])) : '';
|
192 |
-
$plp_options->enable_keyword_link_disclosures = (int)isset($params[$enable_keyword_link_disclosures]);
|
193 |
-
$plp_options->keyword_link_disclosure = isset($params[$keyword_link_disclosure]) && is_string($params[$keyword_link_disclosure]) ? sanitize_text_field(stripslashes($params[$keyword_link_disclosure])): '';
|
194 |
-
$plp_options->set_keyword_thresholds = (int)isset($params[ $set_keyword_thresholds ]);
|
195 |
-
$plp_options->keywords_per_page = isset($params[ $keywords_per_page ]) && is_numeric($params[ $keywords_per_page ]) ? max((int) $params[ $keywords_per_page ], 0) : 3;
|
196 |
-
$plp_options->keyword_links_per_page = isset($params[ $keyword_links_per_page ]) && is_numeric($params[ $keyword_links_per_page ]) ? max((int) $params[ $keyword_links_per_page ], 0) : 2;
|
197 |
-
$plp_options->use_prettylink_url = (int)isset($params[ $use_prettylink_url ]);
|
198 |
-
$plp_options->prettylink_url = isset($params[ $prettylink_url ]) && is_string($params[ $prettylink_url ]) ? esc_url_raw(trim(stripslashes($params[ $prettylink_url ]))) : '';
|
199 |
-
$plp_options->min_role = isset($params[ $minimum_access_role ]) && is_string($params[ $minimum_access_role ]) ? sanitize_key(stripslashes($params[ $minimum_access_role ])) : 'manage_options';
|
200 |
-
$plp_options->allow_public_link_creation = (int)isset($params[ $allow_public_link_creation ]);
|
201 |
-
$plp_options->use_public_link_display_page = (int)isset($params[ $use_public_link_display_page ]);
|
202 |
-
$plp_options->public_link_display_page = isset($params[ $public_link_display_page ]) && is_string($params[ $public_link_display_page ]) ? esc_url_raw(trim(stripslashes($params[ $public_link_display_page ]))) : '';
|
203 |
-
$prli_options->prettybar_image_url = isset($_POST[ $prettybar_image_url ]) && is_string($_POST[ $prettybar_image_url ]) ? esc_url_raw(trim(stripslashes($_POST[ $prettybar_image_url ]))) : '';
|
204 |
-
$prli_options->prettybar_background_image_url = isset($_POST[ $prettybar_background_image_url ]) && is_string($_POST[ $prettybar_background_image_url ]) ? esc_url_raw(trim(stripslashes($_POST[ $prettybar_background_image_url ]))) : '';
|
205 |
-
$prli_options->prettybar_color = isset($_POST[ $prettybar_color ]) && is_string($_POST[ $prettybar_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_color ])) : '';
|
206 |
-
$prli_options->prettybar_text_color = isset($_POST[ $prettybar_text_color ]) && is_string($_POST[ $prettybar_text_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_text_color ])) : '';
|
207 |
-
$prli_options->prettybar_link_color = isset($_POST[ $prettybar_link_color ]) && is_string($_POST[ $prettybar_link_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_link_color ])) : '';
|
208 |
-
$prli_options->prettybar_hover_color = isset($_POST[ $prettybar_hover_color ]) && is_string($_POST[ $prettybar_hover_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_hover_color ])) : '';
|
209 |
-
$prli_options->prettybar_visited_color = isset($_POST[ $prettybar_visited_color ]) && is_string($_POST[ $prettybar_visited_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_visited_color ])) : '';
|
210 |
-
$prli_options->prettybar_show_title = (int)isset($_POST[ $prettybar_show_title ]);
|
211 |
-
$prli_options->prettybar_show_description = (int)isset($_POST[ $prettybar_show_description ]);
|
212 |
-
$prli_options->prettybar_show_share_links = (int)isset($_POST[ $prettybar_show_share_links ]);
|
213 |
-
$prli_options->prettybar_show_target_url_link = (int)isset($_POST[ $prettybar_show_target_url_link ]);
|
214 |
-
$prli_options->prettybar_title_limit = isset($_POST[ $prettybar_title_limit ]) && is_numeric($_POST[ $prettybar_title_limit ]) ? (int) $_POST[ $prettybar_title_limit ] : 25;
|
215 |
-
$prli_options->prettybar_desc_limit = isset($_POST[ $prettybar_desc_limit ]) && is_numeric($_POST[ $prettybar_desc_limit ]) ? (int) $_POST[ $prettybar_desc_limit ] : 30;
|
216 |
-
$prli_options->prettybar_link_limit = isset($_POST[ $prettybar_link_limit ]) && is_numeric($_POST[ $prettybar_link_limit ]) ? (int) $_POST[ $prettybar_link_limit ] : 30;
|
217 |
-
$plp_options->prettybar_hide_attrib_link = (int)isset($params[ $prettybar_hide_attrib_link ]);
|
218 |
-
$plp_options->prettybar_attrib_url = isset($params[ $prettybar_attrib_url ]) && is_string($params[ $prettybar_attrib_url ]) ? esc_url_raw(trim(stripslashes($params[ $prettybar_attrib_url ]))) : '';
|
219 |
-
|
220 |
-
update_option('plp_index_keywords', isset($params['plp_index_keywords']));
|
221 |
-
wp_cache_delete('alloptions', 'options');
|
222 |
-
}
|
223 |
-
|
224 |
-
//Filters the user entered garbage to make sure these are valid domains
|
225 |
-
public function filter_domain_blacklist() {
|
226 |
-
global $plp_options;
|
227 |
-
|
228 |
-
$new_ops = '';
|
229 |
-
$lines = preg_split('/[\r\n]+/', $plp_options->replace_urls_with_pretty_links_blacklist, -1, PREG_SPLIT_NO_EMPTY);
|
230 |
-
|
231 |
-
if(!empty($lines)) {
|
232 |
-
foreach($lines as $line) {
|
233 |
-
if($domain = parse_url($line, PHP_URL_HOST)) {
|
234 |
-
$scheme = parse_url($line, PHP_URL_SCHEME) . "://";
|
235 |
-
$new_ops .= $scheme.$domain."\n";
|
236 |
-
}
|
237 |
-
}
|
238 |
-
}
|
239 |
-
|
240 |
-
$plp_options->replace_urls_with_pretty_links_blacklist = $new_ops;
|
241 |
-
}
|
242 |
-
|
243 |
-
public function store() {
|
244 |
-
global $plp_options;
|
245 |
-
|
246 |
-
// Save the posted value in the database
|
247 |
-
$plp_options->store();
|
248 |
-
}
|
249 |
-
} //End class
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpPostsController.php
DELETED
@@ -1,259 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpPostsController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_filter('the_content', array($this, 'run_autocreate'), 9); //This priority should be lower than social button bars
|
6 |
-
add_action('save_post', array($this,'save_postdata'), 10, 3); // Manual update post
|
7 |
-
add_action('transition_post_status', array($this,'transition_post_status'), 10, 3); // Publishing Scheduled content, etc.
|
8 |
-
add_action('xmlrpc_publish_post', array($this,'xmlrpc_publish_post'), 10, 1); // Publishing Via XML-RPC
|
9 |
-
add_action('wp_enqueue_scripts', array($this,'enqueue_scripts'));
|
10 |
-
add_shortcode('post-pretty-link', array($this,'get_pretty_link'));
|
11 |
-
|
12 |
-
//This trim_empty_replacement_rows can go at some point in the future after we think everyone has upgraded to 2.0.0+
|
13 |
-
//This is an attempt to boost some query performance on keyword/url replacements
|
14 |
-
add_action('admin_init', array($this, 'trim_empty_replacement_rows'));
|
15 |
-
|
16 |
-
add_action('plp_admin_menu', array($this, 'admin_menu'), 10, 1);
|
17 |
-
}
|
18 |
-
|
19 |
-
public function enqueue_scripts() {
|
20 |
-
global $post, $plp_options;
|
21 |
-
|
22 |
-
if(!isset($post)) { return; }
|
23 |
-
|
24 |
-
$post_types = $plp_options->get_post_types();
|
25 |
-
|
26 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
27 |
-
|
28 |
-
if($ac->enabled && $ac->socbtns) {
|
29 |
-
wp_enqueue_style('prli-fontello-animation',
|
30 |
-
PRLI_VENDOR_LIB_URL.'/fontello/css/animation.css',
|
31 |
-
array(), PRLI_VERSION);
|
32 |
-
wp_enqueue_style('prli-fontello-pretty-link',
|
33 |
-
PRLI_VENDOR_LIB_URL.'/fontello/css/pretty-link.css',
|
34 |
-
array('prli-fontello-animation'), PRLI_VERSION);
|
35 |
-
wp_enqueue_style('prlipro-post', PLP_CSS_URL . '/prlipro-post.css');
|
36 |
-
wp_enqueue_style('prlipro-social', PRLI_CSS_URL . '/social_buttons.css', array('prli-fontello-animation','prli-fontello-pretty-link'));
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
public function admin_menu($role) {
|
41 |
-
global $plp_options;
|
42 |
-
|
43 |
-
$post_types = $plp_options->get_post_types();
|
44 |
-
|
45 |
-
foreach($post_types as $post_type) {
|
46 |
-
$ac = $plp_options->autocreate_option($post_type);
|
47 |
-
|
48 |
-
// Show the meta box on post edit pages for auto generated pretty links
|
49 |
-
if($ac->enabled) {
|
50 |
-
add_meta_box('prlipro', esc_html__('Pretty Links Pro', 'pretty-link'), 'PlpPostsHelper::post_sidebar', $post_type, 'side', 'high');
|
51 |
-
}
|
52 |
-
|
53 |
-
if(($ac->enabled && $ac->socbtns) || $plp_options->keyword_replacement_is_on) {
|
54 |
-
add_meta_box('prlipro_options', esc_html__('Pretty Links Pro Options', 'pretty-link'), 'PlpPostsHelper::post_options', $post_type, 'normal');
|
55 |
-
}
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
public function transition_post_status($new_status, $old_status, $post) {
|
60 |
-
if($old_status != $new_status && $new_status == 'publish') {
|
61 |
-
$this->publish_post($post->ID, 'auto');
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
public function xmlrpc_publish_post($post_id) {
|
66 |
-
$this->publish_post($post_id, 'auto');
|
67 |
-
}
|
68 |
-
|
69 |
-
public function publish_post($post_id, $type = 'manual') {
|
70 |
-
$post = get_post($post_id);
|
71 |
-
$this->save_postdata($post_id, $post, false, $type);
|
72 |
-
$permalink = get_permalink($post_id); //Not sure what this is for?
|
73 |
-
}
|
74 |
-
|
75 |
-
public function save_postdata($post_id, $post, $update, $type = 'manual') {
|
76 |
-
global $plp_options, $plp_keyword;
|
77 |
-
|
78 |
-
if(defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
79 |
-
return $post_id;
|
80 |
-
}
|
81 |
-
|
82 |
-
if(defined('DOING_AJAX')) {
|
83 |
-
$type = 'auto';
|
84 |
-
}
|
85 |
-
|
86 |
-
if(!$post_id || !isset($post->ID) || !$post->ID) { return $post_id; }
|
87 |
-
|
88 |
-
if(!current_user_can('edit_post', $post_id) && $type != 'auto') { return $post_id; }
|
89 |
-
|
90 |
-
// Make sure a nonce is set so we don't wipe these options out when the post is being bulk edited
|
91 |
-
if(!wp_verify_nonce((isset($_POST['plp_nonce']))?$_POST['plp_nonce']:'', 'plp_nonce'.wp_salt())) { return $post_id; }
|
92 |
-
|
93 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
94 |
-
$plp_post_options = PlpPostOptions::get_options($post_id);
|
95 |
-
$plp_post_options->requested_slug = isset($_REQUEST['prli_req_slug']) && is_string($_REQUEST['prli_req_slug'])?sanitize_text_field(stripslashes($_REQUEST['prli_req_slug'])):$plp_post_options->requested_slug;
|
96 |
-
|
97 |
-
$plp_post_options->hide_social_buttons = isset($_REQUEST['hide_social_buttons']);
|
98 |
-
$plp_post_options->disable_replacements = isset($_REQUEST['disable_replacements']);
|
99 |
-
|
100 |
-
$plp_post_options->store($post_id);
|
101 |
-
|
102 |
-
$this->auto_create_pretty_link($post_id, $post);
|
103 |
-
|
104 |
-
// Delete all the post keywords for this link to be rebuilt by our wp-cron task
|
105 |
-
$plp_keyword->delete_post_keywords_by_post_id($post_id);
|
106 |
-
|
107 |
-
delete_post_meta($post_id, '_plp_post_keywords_updated_at');
|
108 |
-
delete_post_meta($post_id, '_plp_post_urls_updated_at');
|
109 |
-
}
|
110 |
-
|
111 |
-
public function auto_create_pretty_link($post_id, $post) {
|
112 |
-
global $plp_options, $prli_link, $prli_utils, $plp_options, $prli_link_meta;
|
113 |
-
|
114 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
115 |
-
|
116 |
-
if(!$ac->enabled) { return; }
|
117 |
-
|
118 |
-
if($post && $post->post_status == "publish") {
|
119 |
-
$plp_post_options = PlpPostOptions::get_options($post_id);
|
120 |
-
|
121 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post_id,"_pretty-link",true);
|
122 |
-
|
123 |
-
$new_link = false;
|
124 |
-
// Try to find a pretty link that is using this link already
|
125 |
-
if(!$pretty_link_id) {
|
126 |
-
$new_link = true;
|
127 |
-
$pretty_link_id = $prli_link->find_first_target_url(get_permalink($post_id));
|
128 |
-
}
|
129 |
-
|
130 |
-
$pretty_link = $prli_link->getOne($pretty_link_id);
|
131 |
-
|
132 |
-
if(empty($pretty_link) || !$pretty_link) {
|
133 |
-
$slug_available = $prli_utils->is_slug_available($plp_post_options->requested_slug);
|
134 |
-
|
135 |
-
$slug = (is_wp_error($slug_available) ? '' : $plp_post_options->requested_slug);
|
136 |
-
|
137 |
-
$pl_insert_id = prli_create_pretty_link( get_permalink($post_id),
|
138 |
-
$slug, // slug should be default?
|
139 |
-
!empty($post->post_title) ? addslashes($post->post_title) : __('Untitled', 'pretty-link'),
|
140 |
-
addslashes($post->post_excerpt)
|
141 |
-
);
|
142 |
-
|
143 |
-
$new_pretty_link = $prli_link->getOne($pl_insert_id);
|
144 |
-
|
145 |
-
if(isset($post->ID) && !empty($post->ID) && $post->ID) {
|
146 |
-
PrliUtils::update_prli_post_meta($post->ID,'_pretty-link',$new_pretty_link->id,true);
|
147 |
-
}
|
148 |
-
|
149 |
-
$link_cpt_id = $new_pretty_link->link_cpt_id;
|
150 |
-
}
|
151 |
-
else {
|
152 |
-
prli_update_pretty_link( $pretty_link_id,
|
153 |
-
get_permalink($post_id),
|
154 |
-
$pretty_link->slug,
|
155 |
-
!empty($post->post_title) ? addslashes($post->post_title) : __('Untitled', 'pretty-link'),
|
156 |
-
addslashes($post->post_excerpt)
|
157 |
-
);
|
158 |
-
|
159 |
-
// Still update the post meta
|
160 |
-
if(isset($post_id) && !empty($post_id) && $post_id) {
|
161 |
-
PrliUtils::update_prli_post_meta($post_id,'_pretty-link',$pretty_link_id,true);
|
162 |
-
}
|
163 |
-
|
164 |
-
$link_cpt_id = $pretty_link->link_cpt_id;
|
165 |
-
}
|
166 |
-
|
167 |
-
if ($ac->category) {
|
168 |
-
wp_set_object_terms($link_cpt_id, $ac->category, PlpLinkCategoriesController::$ctax);
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
-
|
173 |
-
// shortcode for displaying the pretty link for the post/page
|
174 |
-
public function get_pretty_link() {
|
175 |
-
global $post, $plp_options, $prli_blogurl, $prli_link, $wp_query, $prli_link_meta;
|
176 |
-
|
177 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
178 |
-
|
179 |
-
// Don't show until published
|
180 |
-
if($post->post_status != 'publish' ||
|
181 |
-
// only show button if enabled and links are being generated
|
182 |
-
((is_single() || is_archive() || $wp_query->is_posts_page) && !$ac->enabled)) {
|
183 |
-
return '';
|
184 |
-
}
|
185 |
-
|
186 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post->ID,"_pretty-link",true);
|
187 |
-
$pretty_link = $prli_link->getOne($pretty_link_id);
|
188 |
-
$shorturl = $prli_blogurl.PrliUtils::get_permalink_pre_slug_uri().$pretty_link->slug;
|
189 |
-
|
190 |
-
return $shorturl;
|
191 |
-
}
|
192 |
-
|
193 |
-
//This trim_empty_replacement_rows can go at some point in the future after we think everyone has upgraded to 2.0.0+
|
194 |
-
//This is an attempt to boost some query performance on keyword/url replacements
|
195 |
-
public function trim_empty_replacement_rows() {
|
196 |
-
global $wpdb, $prli_link_meta, $plp_keyword;
|
197 |
-
|
198 |
-
//This only ever needs to be run once, since I fixed the code that was causing the blank rows in the first place
|
199 |
-
if(!get_option('prli_empty_replacement_rows_cleanup', false)) {
|
200 |
-
$wpdb->query("DELETE FROM {$plp_keyword->table_name} WHERE text IS NULL OR text = ''");
|
201 |
-
$wpdb->query("DELETE FROM {$prli_link_meta->table_name} WHERE meta_key = 'prli-url-replacements' AND (meta_value IS NULL OR meta_value = '')");
|
202 |
-
update_option('prli_empty_replacement_rows_cleanup', true);
|
203 |
-
wp_cache_delete('alloptions', 'options');
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
//Should move this to WP CRON at some point and have this done in batches, instead of one at a time via the_content like it is currently happening
|
208 |
-
public function run_autocreate($content = '') {
|
209 |
-
global $post, $prli_utils, $prli_link, $prli_link_meta, $plp_options;
|
210 |
-
|
211 |
-
//No post object or type or published status?
|
212 |
-
if(!isset($post) || !$post instanceof WP_Post || (int)$post->ID <= 0 || !isset($post->post_type) || $post->post_status != "publish" || defined('REST_REQUEST')) {
|
213 |
-
return $content;
|
214 |
-
}
|
215 |
-
|
216 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
217 |
-
|
218 |
-
if($ac->enabled) {
|
219 |
-
$plp_post_options = PlpPostOptions::get_options($post->ID);
|
220 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post->ID, '_pretty-link', true);
|
221 |
-
|
222 |
-
// Try to find a pretty link that is using this link already
|
223 |
-
if(!$pretty_link_id) {
|
224 |
-
$pretty_link_id = $prli_link->find_first_target_url(get_permalink($post->ID));
|
225 |
-
}
|
226 |
-
|
227 |
-
$pretty_link = $prli_link->getOne($pretty_link_id);
|
228 |
-
|
229 |
-
if(empty($pretty_link) or !$pretty_link) {
|
230 |
-
$slug_available = $prli_utils->is_slug_available($plp_post_options->requested_slug);
|
231 |
-
|
232 |
-
$slug = (is_wp_error($slug_available) ? '' : $plp_post_options->requested_slug);
|
233 |
-
|
234 |
-
$pl_insert_id = prli_create_pretty_link(
|
235 |
-
get_permalink($post->ID),
|
236 |
-
$slug,
|
237 |
-
!empty($post->post_title) ? addslashes($post->post_title) : __('Untitled', 'pretty-link'),
|
238 |
-
addslashes($post->post_excerpt)
|
239 |
-
);
|
240 |
-
$new_pretty_link = $prli_link->getOne($pl_insert_id);
|
241 |
-
|
242 |
-
PrliUtils::update_prli_post_meta($post->ID, '_pretty-link', $new_pretty_link->id, true);
|
243 |
-
$link_cpt_id = $new_pretty_link->link_cpt_id;
|
244 |
-
|
245 |
-
if ($ac->category) {
|
246 |
-
wp_set_object_terms($link_cpt_id, $ac->category, PlpLinkCategoriesController::$ctax);
|
247 |
-
}
|
248 |
-
}
|
249 |
-
}
|
250 |
-
|
251 |
-
return $content;
|
252 |
-
}
|
253 |
-
} //End Class
|
254 |
-
|
255 |
-
// Template Tag for displaying the pretty link for the post/page
|
256 |
-
function the_prettylink() {
|
257 |
-
$ctrl = new PlpPostsController();
|
258 |
-
echo $ctrl->get_pretty_link();
|
259 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpPrettyBarController.php
DELETED
@@ -1,127 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
// PrettyBar stuff here of course
|
4 |
-
class PlpPrettyBarController extends PrliBaseController {
|
5 |
-
public $field_names;
|
6 |
-
|
7 |
-
public function __construct() {
|
8 |
-
$this->field_names = array(
|
9 |
-
'prettybar_image_url' => 'prli_prettybar_image_url',
|
10 |
-
'prettybar_background_image_url' => 'prli_prettybar_background_image_url',
|
11 |
-
'prettybar_color' => 'prli_prettybar_color',
|
12 |
-
'prettybar_text_color' => 'prli_prettybar_text_color',
|
13 |
-
'prettybar_link_color' => 'prli_prettybar_link_color',
|
14 |
-
'prettybar_hover_color' => 'prli_prettybar_hover_color',
|
15 |
-
'prettybar_visited_color' => 'prli_prettybar_visited_color',
|
16 |
-
'prettybar_show_title' => 'prli_prettybar_show_title',
|
17 |
-
'prettybar_show_description' => 'prli_prettybar_show_description',
|
18 |
-
'prettybar_show_share_links' => 'prli_prettybar_show_share_links',
|
19 |
-
'prettybar_show_target_url_link' => 'prli_prettybar_show_target_url_link',
|
20 |
-
'prettybar_title_limit' => 'prli_prettybar_title_limit',
|
21 |
-
'prettybar_desc_limit' => 'prli_prettybar_desc_limit',
|
22 |
-
'prettybar_link_limit' => 'prli_prettybar_link_limit'
|
23 |
-
);
|
24 |
-
}
|
25 |
-
|
26 |
-
public function load_hooks() {
|
27 |
-
add_filter('prli-display-attrib-link', array($this,'display_attrib_link'));
|
28 |
-
add_filter('prli-validate-options', array($this,'validate'));
|
29 |
-
add_action('prli-store-options', array($this,'update'));
|
30 |
-
}
|
31 |
-
|
32 |
-
public function display_attrib_link($link_html) {
|
33 |
-
global $plp_options;
|
34 |
-
|
35 |
-
if( $plp_options->prettybar_hide_attrib_link == 1 ) { return ''; }
|
36 |
-
|
37 |
-
if( !empty($plp_options->prettybar_attrib_url) ) {
|
38 |
-
$link_html = preg_replace("#https://prettylinks.com/plp/pretty-bar/powered-by#",$plp_options->prettybar_attrib_url,$link_html);
|
39 |
-
}
|
40 |
-
|
41 |
-
return $link_html;
|
42 |
-
}
|
43 |
-
|
44 |
-
public function validate($errors) {
|
45 |
-
global $prli_options;
|
46 |
-
|
47 |
-
extract($this->field_names);
|
48 |
-
|
49 |
-
if( !empty($_POST[$prettybar_image_url]) && !preg_match('/^http.?:\/\/.*\..*$/', $_POST[$prettybar_image_url] ) ) {
|
50 |
-
$errors[] = __("Logo Image URL must be a correctly formatted URL", 'pretty-link');
|
51 |
-
}
|
52 |
-
|
53 |
-
if( !empty($_POST[$prettybar_background_image_url]) && !preg_match('/^http.?:\/\/.*\..*$/', $_POST[$prettybar_background_image_url] ) ) {
|
54 |
-
$errors[] = __("Background Image URL must be a correctly formatted URL", 'pretty-link');
|
55 |
-
}
|
56 |
-
|
57 |
-
$color_pattern = "/^#?[0-9a-fA-F]{6}$/";
|
58 |
-
|
59 |
-
if( !empty($_POST[ $prettybar_color ]) && !preg_match( $color_pattern, $_POST[ $prettybar_color ] ) ) {
|
60 |
-
$errors[] = __("PrettyBar Background Color must be an actual RGB Value", 'pretty-link');
|
61 |
-
}
|
62 |
-
|
63 |
-
if( !empty($_POST[ $prettybar_text_color ]) && !preg_match( $color_pattern, $_POST[ $prettybar_text_color ] ) ) {
|
64 |
-
$errors[] = __("PrettyBar Text Color must be an actual RGB Value", 'pretty-link');
|
65 |
-
}
|
66 |
-
|
67 |
-
if( !empty($_POST[ $prettybar_link_color ]) && !preg_match( $color_pattern, $_POST[ $prettybar_link_color ] ) ) {
|
68 |
-
$errors[] = __("PrettyBar Link Color must be an actual RGB Value", 'pretty-link');
|
69 |
-
}
|
70 |
-
|
71 |
-
if( !empty($_POST[ $prettybar_hover_color ]) && !preg_match( $color_pattern, $_POST[ $prettybar_hover_color ] ) ) {
|
72 |
-
$errors[] = __("PrettyBar Hover Color must be an actual RGB Value", 'pretty-link');
|
73 |
-
}
|
74 |
-
|
75 |
-
if( !empty($_POST[ $prettybar_visited_color ]) && !preg_match( $color_pattern, $_POST[ $prettybar_visited_color ] ) ) {
|
76 |
-
$errors[] = __("PrettyBar Hover Color must be an actual RGB Value", 'pretty-link');
|
77 |
-
}
|
78 |
-
|
79 |
-
if( empty($_POST[ $prettybar_title_limit ]) ) {
|
80 |
-
$errors[] = __("PrettyBar Title Character Limit must not be blank", 'pretty-link');
|
81 |
-
}
|
82 |
-
|
83 |
-
if( empty($_POST[ $prettybar_desc_limit ]) ) {
|
84 |
-
$errors[] = __("PrettyBar Description Character Limit must not be blank", 'pretty-link');
|
85 |
-
}
|
86 |
-
|
87 |
-
if( empty($_POST[ $prettybar_link_limit ]) ) {
|
88 |
-
$errors[] = __("PrettyBar Link Character Limit must not be blank", 'pretty-link');
|
89 |
-
}
|
90 |
-
|
91 |
-
if( !empty($_POST[ $prettybar_title_limit ]) && !preg_match( "#^[0-9]*$#", $_POST[ $prettybar_title_limit ] ) ) {
|
92 |
-
$errors[] = __("PrettyBar Title Character Limit must be a number", 'pretty-link');
|
93 |
-
}
|
94 |
-
|
95 |
-
if( !empty($_POST[ $prettybar_desc_limit ]) && !preg_match( "#^[0-9]*$#", $_POST[ $prettybar_desc_limit ] ) ) {
|
96 |
-
$errors[] = __("PrettyBar Description Character Limit must be a number", 'pretty-link');
|
97 |
-
}
|
98 |
-
|
99 |
-
if( !empty($_POST[ $prettybar_link_limit ]) && !preg_match( "#^[0-9]*$#", $_POST[ $prettybar_link_limit ] ) ) {
|
100 |
-
$errors[] = __("PrettyBar Link Character Limit must be a number", 'pretty-link');
|
101 |
-
}
|
102 |
-
|
103 |
-
return $errors;
|
104 |
-
}
|
105 |
-
|
106 |
-
public function update($errors) {
|
107 |
-
global $prli_options;
|
108 |
-
|
109 |
-
extract($this->field_names);
|
110 |
-
|
111 |
-
$prli_options->prettybar_image_url = isset($_POST[ $prettybar_image_url ]) && is_string($_POST[ $prettybar_image_url ]) ? esc_url_raw(trim(stripslashes($_POST[ $prettybar_image_url ]))) : '';
|
112 |
-
$prli_options->prettybar_background_image_url = isset($_POST[ $prettybar_background_image_url ]) && is_string($_POST[ $prettybar_background_image_url ]) ? esc_url_raw(trim(stripslashes($_POST[ $prettybar_background_image_url ]))) : '';
|
113 |
-
$prli_options->prettybar_color = isset($_POST[ $prettybar_color ]) && is_string($_POST[ $prettybar_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_color ])) : '';
|
114 |
-
$prli_options->prettybar_text_color = isset($_POST[ $prettybar_text_color ]) && is_string($_POST[ $prettybar_text_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_text_color ])) : '';
|
115 |
-
$prli_options->prettybar_link_color = isset($_POST[ $prettybar_link_color ]) && is_string($_POST[ $prettybar_link_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_link_color ])) : '';
|
116 |
-
$prli_options->prettybar_hover_color = isset($_POST[ $prettybar_hover_color ]) && is_string($_POST[ $prettybar_hover_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_hover_color ])) : '';
|
117 |
-
$prli_options->prettybar_visited_color = isset($_POST[ $prettybar_visited_color ]) && is_string($_POST[ $prettybar_visited_color ]) ? sanitize_hex_color(stripslashes($_POST[ $prettybar_visited_color ])) : '';
|
118 |
-
$prli_options->prettybar_show_title = (int)isset($_POST[ $prettybar_show_title ]);
|
119 |
-
$prli_options->prettybar_show_description = (int)isset($_POST[ $prettybar_show_description ]);
|
120 |
-
$prli_options->prettybar_show_share_links = (int)isset($_POST[ $prettybar_show_share_links ]);
|
121 |
-
$prli_options->prettybar_show_target_url_link = (int)isset($_POST[ $prettybar_show_target_url_link ]);
|
122 |
-
$prli_options->prettybar_title_limit = isset($_POST[ $prettybar_title_limit ]) && is_numeric($_POST[ $prettybar_title_limit ]) ? (int) $_POST[ $prettybar_title_limit ] : 25;
|
123 |
-
$prli_options->prettybar_desc_limit = isset($_POST[ $prettybar_desc_limit ]) && is_numeric($_POST[ $prettybar_desc_limit ]) ? (int) $_POST[ $prettybar_desc_limit ] : 30;
|
124 |
-
$prli_options->prettybar_link_limit = isset($_POST[ $prettybar_link_limit ]) && is_numeric($_POST[ $prettybar_link_limit ]) ? (int) $_POST[ $prettybar_link_limit ] : 30;
|
125 |
-
}
|
126 |
-
}
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpPublicLinksController.php
DELETED
@@ -1,154 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpPublicLinksController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
global $plp_options;
|
6 |
-
|
7 |
-
if($plp_options->allow_public_link_creation) {
|
8 |
-
add_action( 'widgets_init', array($this, 'register_widget') );
|
9 |
-
|
10 |
-
// Current, actual endpoint
|
11 |
-
add_action( 'wp_ajax_plp-create-public-link', array( $this, 'create' ) );
|
12 |
-
add_action( 'wp_ajax_nopriv_plp-create-public-link', array( $this, 'create' ) );
|
13 |
-
|
14 |
-
}
|
15 |
-
|
16 |
-
add_shortcode('prli_create_form', array($this,'public_create_form'));
|
17 |
-
add_shortcode('prli_create_display', array($this,'public_link_display'));
|
18 |
-
add_shortcode('prli_public_link_url', array($this,'public_link_display'));
|
19 |
-
add_shortcode('prli_public_link_title', array($this,'public_link_title_display'));
|
20 |
-
add_shortcode('prli_public_link_target_url', array($this,'public_link_target_url_display'));
|
21 |
-
add_shortcode('prli_public_link_social_buttons', array($this,'public_link_social_buttons_display'));
|
22 |
-
}
|
23 |
-
|
24 |
-
public function register_widget() {
|
25 |
-
return register_widget('PlpPublicLinksWidget');
|
26 |
-
}
|
27 |
-
|
28 |
-
public function create() {
|
29 |
-
global $plp_options, $prli_options, $prli_link, $prli_blogurl;
|
30 |
-
|
31 |
-
if($plp_options->allow_public_link_creation) {
|
32 |
-
$_POST['slug'] = (isset($_POST['slug']) && is_string($_POST['slug']) && !empty($_POST['slug'])) ? sanitize_text_field(stripslashes($_POST['slug'])) : $prli_link->generateValidSlug();
|
33 |
-
|
34 |
-
$errors = array();
|
35 |
-
|
36 |
-
if (!isset($_POST['_wpnonce']) || !is_string($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'plp-create-public-link')) {
|
37 |
-
$errors = array(__('Security check failed', 'pretty-link'));
|
38 |
-
}
|
39 |
-
|
40 |
-
$errors = array_merge($errors, $prli_link->validate($_POST));
|
41 |
-
|
42 |
-
if( count($errors) > 0 ) {
|
43 |
-
$url_param = ((!empty($url))?'&url='.urlencode(esc_url_raw(trim(stripslashes($_POST['url'])))):'');
|
44 |
-
$referral_url = isset($_POST['referral-url']) && is_string($_POST['referral-url']) ? esc_url_raw(trim(stripslashes($_POST['referral-url']))) : home_url();
|
45 |
-
header("Location: {$referral_url}?errors=" . urlencode(serialize($errors)).$url_param);
|
46 |
-
}
|
47 |
-
else {
|
48 |
-
$redirect_type = isset($_POST['redirect_type']) && is_string($_POST['redirect_type']) ? sanitize_key($_POST['redirect_type']) : '307';
|
49 |
-
$track = isset($_POST['track']) && is_numeric($_POST['track']) ? (int) $_POST['track'] : -1;
|
50 |
-
|
51 |
-
|
52 |
-
unset($_POST['param_forwarding']);
|
53 |
-
$_POST['param_struct'] = '';
|
54 |
-
$_POST['name'] = '';
|
55 |
-
$_POST['description'] = '';
|
56 |
-
|
57 |
-
if($redirect_type == '-1') {
|
58 |
-
$_POST['redirect_type'] = $prli_options->link_redirect_type;
|
59 |
-
}
|
60 |
-
|
61 |
-
if($track == '-1') {
|
62 |
-
if( $prli_options->link_track_me ) {
|
63 |
-
$_POST['track_me'] = 'on';
|
64 |
-
}
|
65 |
-
}
|
66 |
-
else if( $track == '1' ) {
|
67 |
-
$_POST['track_me'] = 'on';
|
68 |
-
}
|
69 |
-
|
70 |
-
if( $prli_options->link_nofollow ) {
|
71 |
-
$_POST['nofollow'] = 'on';
|
72 |
-
}
|
73 |
-
|
74 |
-
if( $prli_options->link_sponsored ) {
|
75 |
-
$_POST['sponsored'] = 'on';
|
76 |
-
}
|
77 |
-
|
78 |
-
$record = $prli_link->create( $_POST );
|
79 |
-
$link = $prli_link->getOne($record);
|
80 |
-
|
81 |
-
$category = isset($_POST['category']) && is_numeric($_POST['category']) ? (int) $_POST['category'] : -1;
|
82 |
-
|
83 |
-
if ($category != -1) {
|
84 |
-
wp_set_object_terms($link->link_cpt_id, $category, PlpLinkCategoriesController::$ctax);
|
85 |
-
}
|
86 |
-
|
87 |
-
if($plp_options->use_public_link_display_page) {
|
88 |
-
header("Location: {$plp_options->public_link_display_page}?slug=".urlencode($link->slug));
|
89 |
-
}
|
90 |
-
else {
|
91 |
-
$pretty_link = prli_get_pretty_link_url($link->id);
|
92 |
-
$target_url = $link->url;
|
93 |
-
$target_url_title = $link->name;
|
94 |
-
$pretty_link_id = $link->id;
|
95 |
-
|
96 |
-
require_once(PRLI_VIEWS_PATH . '/shared/public_link.php');
|
97 |
-
}
|
98 |
-
}
|
99 |
-
}
|
100 |
-
else {
|
101 |
-
wp_redirect($prli_blogurl);
|
102 |
-
}
|
103 |
-
|
104 |
-
exit;
|
105 |
-
}
|
106 |
-
|
107 |
-
/**************** PUBLIC FACING URL CREATION SHORTCODES **********************/
|
108 |
-
public function public_create_form($atts) {
|
109 |
-
extract(shortcode_atts(array(
|
110 |
-
'label' => __('Enter a URL:', 'pretty-link'),
|
111 |
-
'button' => __('Shrink', 'pretty-link'),
|
112 |
-
'redirect_type' => '-1',
|
113 |
-
'track' => '-1',
|
114 |
-
'category' => '-1',
|
115 |
-
), $atts));
|
116 |
-
|
117 |
-
return PlpPublicLinksHelper::display_form($label,$button,$redirect_type,$track,$category);
|
118 |
-
}
|
119 |
-
|
120 |
-
public function public_link_display()
|
121 |
-
{
|
122 |
-
if(isset($_GET['slug']) && is_string($_GET['slug'])) {
|
123 |
-
$slug = sanitize_text_field(stripslashes($_GET['slug']));
|
124 |
-
$link = prli_get_link_from_slug($slug);
|
125 |
-
$url = prli_get_pretty_link_url($link->id);
|
126 |
-
return sprintf('<a href="%1$s">%2$s</a>', esc_url($url), esc_html($url));
|
127 |
-
}
|
128 |
-
}
|
129 |
-
|
130 |
-
public function public_link_title_display() {
|
131 |
-
if(isset($_GET['slug']) && is_string($_GET['slug'])) {
|
132 |
-
$slug = sanitize_text_field(stripslashes($_GET['slug']));
|
133 |
-
$link = prli_get_link_from_slug($slug);
|
134 |
-
return esc_html($link->name);
|
135 |
-
}
|
136 |
-
}
|
137 |
-
|
138 |
-
public function public_link_target_url_display() {
|
139 |
-
if(isset($_GET['slug']) && is_string($_GET['slug'])) {
|
140 |
-
$slug = sanitize_text_field(stripslashes($_GET['slug']));
|
141 |
-
$link = prli_get_link_from_slug($slug);
|
142 |
-
return esc_url($link->url);
|
143 |
-
}
|
144 |
-
}
|
145 |
-
|
146 |
-
public function public_link_social_buttons_display() {
|
147 |
-
if(isset($_GET['slug']) && is_string($_GET['slug'])) {
|
148 |
-
$slug = sanitize_text_field(stripslashes($_GET['slug']));
|
149 |
-
$link = prli_get_link_from_slug($slug);
|
150 |
-
return PlpSocialButtonsHelper::get_social_buttons_bar($link->id);
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpReportsController.php
DELETED
@@ -1,344 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpReportsController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action('prli-link-action', array($this, 'split_test_link'), 10, 1);
|
6 |
-
add_action('plp_admin_menu', array($this, 'admin_menu'), 10, 1);
|
7 |
-
}
|
8 |
-
|
9 |
-
public function admin_menu($role) {
|
10 |
-
$pl_link_cpt = PrliLink::$cpt;
|
11 |
-
|
12 |
-
add_submenu_page(
|
13 |
-
"edit.php?post_type={$pl_link_cpt}",
|
14 |
-
esc_html__('Pretty Links Pro | Reports', 'pretty-link'),
|
15 |
-
esc_html__('Reports', 'pretty-link'),
|
16 |
-
$role, 'plp-reports',
|
17 |
-
array( $this, 'route' )
|
18 |
-
);
|
19 |
-
}
|
20 |
-
|
21 |
-
public function route() {
|
22 |
-
global $plp_report;
|
23 |
-
$params = $plp_report->get_params_array();
|
24 |
-
|
25 |
-
$action = isset($params['action']) ? $params['action'] : null;
|
26 |
-
|
27 |
-
switch($action) {
|
28 |
-
case 'new':
|
29 |
-
$this->new_report($params);
|
30 |
-
break;
|
31 |
-
case 'create':
|
32 |
-
$this->create($params);
|
33 |
-
break;
|
34 |
-
case 'edit':
|
35 |
-
$this->edit($params);
|
36 |
-
break;
|
37 |
-
case 'update':
|
38 |
-
$this->update($params);
|
39 |
-
break;
|
40 |
-
case 'destroy':
|
41 |
-
$this->destroy($params);
|
42 |
-
break;
|
43 |
-
case 'display-custom-report':
|
44 |
-
$this->display_custom_report($params);
|
45 |
-
break;
|
46 |
-
case 'display-split-test-report':
|
47 |
-
$this->display_split_test_report($params);
|
48 |
-
break;
|
49 |
-
case 'list':
|
50 |
-
default:
|
51 |
-
$prli_message = esc_html__('Create a custom link report and analyze your data.', 'pretty-link');
|
52 |
-
$this->display_reports_list($params, $prli_message);
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
public function split_test_link($link_id) {
|
57 |
-
global $prli_link, $prli_link_meta;
|
58 |
-
|
59 |
-
$link = $prli_link->getOne($link_id);
|
60 |
-
|
61 |
-
if( $prli_link_meta->get_link_meta($link_id, 'prli-enable-split-test', true) ) {
|
62 |
-
?><a href="<?php echo esc_url(admin_url("admin.php?page=plp-reports&action=display-split-test-report&id={$link->id}")); ?>" title="<?php echo esc_attr(sprintf( __('View the Split Test Report for %s'), stripslashes($link->name) )); ?>"><i class="pl-list-icon pl-icon-chart-pie"></i></a><?php
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
private function new_report($params) {
|
67 |
-
global $prli_link;
|
68 |
-
|
69 |
-
$links = $prli_link->getAll('',' ORDER BY li.name');
|
70 |
-
$report_links = array();
|
71 |
-
|
72 |
-
require_once(PLP_VIEWS_PATH.'/reports/new.php');
|
73 |
-
}
|
74 |
-
|
75 |
-
private function create($params) {
|
76 |
-
global $prli_link, $plp_report;
|
77 |
-
|
78 |
-
$values = array(
|
79 |
-
'name' => isset($_POST['name']) && is_string($_POST['name']) ? sanitize_text_field(stripslashes($_POST['name'])) : '',
|
80 |
-
'link' => isset($_POST['link']) && is_array($_POST['link']) ? array_map('intval', array_keys($_POST['link'])) : array(),
|
81 |
-
'goal_link_id' => isset($_POST['goal_link_id']) && is_numeric($_POST['goal_link_id']) ? (int) $_POST['goal_link_id'] : 0
|
82 |
-
);
|
83 |
-
|
84 |
-
$errors = $plp_report->validate($values);
|
85 |
-
|
86 |
-
if( count($errors) > 0 ) {
|
87 |
-
$links = $prli_link->getAll('',' ORDER BY li.name');
|
88 |
-
$report_links = array();
|
89 |
-
require_once(PLP_VIEWS_PATH.'/reports/new.php');
|
90 |
-
}
|
91 |
-
else {
|
92 |
-
$insert_id = $plp_report->create( $values );
|
93 |
-
$plp_report->update_report_links($insert_id, $values['link']);
|
94 |
-
$prli_message = esc_html__("Your Pretty Link Report was Successfully Created", 'pretty-link');
|
95 |
-
$this->display_reports_list($params, $prli_message, '', 1);
|
96 |
-
}
|
97 |
-
}
|
98 |
-
|
99 |
-
private function edit($params) {
|
100 |
-
global $prli_link, $plp_report;
|
101 |
-
|
102 |
-
$record = $plp_report->getOne( $params['id'] );
|
103 |
-
$id = $params['id'];
|
104 |
-
$links = $prli_link->getAll('',' ORDER BY li.name');
|
105 |
-
$report_links = $plp_report->get_report_links_array($id);
|
106 |
-
|
107 |
-
require_once(PLP_VIEWS_PATH.'/reports/edit.php');
|
108 |
-
}
|
109 |
-
|
110 |
-
private function update($params) {
|
111 |
-
global $prli_link, $plp_report;
|
112 |
-
|
113 |
-
$values = array(
|
114 |
-
'name' => isset($_POST['name']) && is_string($_POST['name']) ? sanitize_text_field(stripslashes($_POST['name'])) : '',
|
115 |
-
'link' => isset($_POST['link']) && is_array($_POST['link']) ? array_map('intval', array_keys($_POST['link'])) : array(),
|
116 |
-
'goal_link_id' => isset($_POST['goal_link_id']) && is_numeric($_POST['goal_link_id']) ? (int) $_POST['goal_link_id'] : 0
|
117 |
-
);
|
118 |
-
|
119 |
-
$errors = $plp_report->validate($values);
|
120 |
-
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
|
121 |
-
|
122 |
-
if( count($errors) > 0 ) {
|
123 |
-
$links = $prli_link->getAll('',' ORDER BY li.name');
|
124 |
-
$report_links = $plp_report->get_report_links_array($id);
|
125 |
-
require_once(PLP_VIEWS_PATH.'/reports/edit.php');
|
126 |
-
}
|
127 |
-
else {
|
128 |
-
$record = $plp_report->update( $id, $values );
|
129 |
-
$plp_report->update_report_links($id, $values['link']);
|
130 |
-
$prli_message = esc_html__("Your Pretty Link Report was Successfully Updated", 'pretty-link');
|
131 |
-
$this->display_reports_list($params, $prli_message, '', 1);
|
132 |
-
}
|
133 |
-
}
|
134 |
-
|
135 |
-
private function destroy($params) {
|
136 |
-
global $plp_report;
|
137 |
-
|
138 |
-
$plp_report->destroy( $params['id'] );
|
139 |
-
$prli_message = esc_html__('Your Pretty Link Report was Successfully Deleted', 'pretty-link');
|
140 |
-
|
141 |
-
$this->display_reports_list($params, $prli_message, '', 1);
|
142 |
-
}
|
143 |
-
|
144 |
-
private function display_custom_report($params) {
|
145 |
-
global $prli_utils, $plp_report, $prli_link;
|
146 |
-
|
147 |
-
$id = $params['id'];
|
148 |
-
|
149 |
-
$start_timestamp = $prli_utils->get_start_date($params);
|
150 |
-
$end_timestamp = $prli_utils->get_end_date($params);
|
151 |
-
|
152 |
-
$start_timestamp = mktime(0, 0, 0, date('n', $start_timestamp), date('j', $start_timestamp), date('Y', $start_timestamp));
|
153 |
-
$end_timestamp = mktime(0, 0, 0, date('n', $end_timestamp), date('j', $end_timestamp), date('Y', $end_timestamp) );
|
154 |
-
|
155 |
-
$report = $plp_report->getOne($id);
|
156 |
-
|
157 |
-
$links = $plp_report->get_report_links_array($id);
|
158 |
-
$labels = $plp_report->get_labels_by_links($start_timestamp, $end_timestamp, $links);
|
159 |
-
$hits = $plp_report->get_clicks_by_links($start_timestamp, $end_timestamp, $links);
|
160 |
-
$uniques = $plp_report->get_clicks_by_links($start_timestamp, $end_timestamp, $links, true);
|
161 |
-
|
162 |
-
$top_hits = $prli_utils->getTopValue($hits);
|
163 |
-
$top_uniques = $prli_utils->getTopValue($uniques);
|
164 |
-
|
165 |
-
if( !empty($report->goal_link_id) ) {
|
166 |
-
$goal_link = $prli_link->getOne($report->goal_link_id);
|
167 |
-
$conversions = $plp_report->get_conversions_by_links($start_timestamp,$end_timestamp,$links,$report->goal_link_id);
|
168 |
-
|
169 |
-
$conv_rates = array();
|
170 |
-
for($i=0; $i<count($links); $i++) {
|
171 |
-
$conv_rates[] = (($hits[$i] > 0)?sprintf( "%0.2f", (float)($conversions[$i] / $hits[$i] * 100.0) ):'0.00');
|
172 |
-
}
|
173 |
-
|
174 |
-
$top_conversions = $prli_utils->getTopValue(array_values($conversions));
|
175 |
-
$top_conv_rate = $prli_utils->getTopValue(array_values($conv_rates));
|
176 |
-
}
|
177 |
-
else {
|
178 |
-
$goal_link = false;
|
179 |
-
$conversions = $conv_rates = array();
|
180 |
-
$top_conversions = $top_conv_rate = 0;
|
181 |
-
}
|
182 |
-
|
183 |
-
require_once(PLP_VIEWS_PATH.'/reports/custom-report.php');
|
184 |
-
}
|
185 |
-
|
186 |
-
private function display_split_test_report($params) {
|
187 |
-
global $prli_utils, $plp_report, $prli_link, $prli_link_meta;
|
188 |
-
|
189 |
-
$link_id = $params['id'];
|
190 |
-
|
191 |
-
$goal_link_id = $prli_link_meta->get_link_meta($link_id, 'prli-split-test-goal-link', true);
|
192 |
-
|
193 |
-
$link = $prli_link->getOne($link_id);
|
194 |
-
|
195 |
-
$start_timestamp = $prli_utils->get_start_date($params);
|
196 |
-
$end_timestamp = $prli_utils->get_end_date($params);
|
197 |
-
|
198 |
-
$start_timestamp = mktime(0, 0, 0, date('n', $start_timestamp), date('j', $start_timestamp), date('Y', $start_timestamp));
|
199 |
-
$end_timestamp = mktime(0, 0, 0, date('n', $end_timestamp), date('j', $end_timestamp), date('Y', $end_timestamp) );
|
200 |
-
|
201 |
-
$links = $plp_report->get_split_report_links_array($link_id);
|
202 |
-
$labels = $links;
|
203 |
-
$hits_array = $plp_report->get_split_clicks($start_timestamp,$end_timestamp,$link_id);
|
204 |
-
$uniques_array = $plp_report->get_split_clicks($start_timestamp,$end_timestamp,$link_id,true);
|
205 |
-
|
206 |
-
$hits = array();
|
207 |
-
$uniques = array();
|
208 |
-
|
209 |
-
for($i=0;$i<count($links);$i++) {
|
210 |
-
$hits[$i] = ((is_array($hits_array) && isset($hits_array[$links[$i]]) && !empty($hits_array[$links[$i]]))?$hits_array[$links[$i]]:0);
|
211 |
-
$uniques[$i] = ((is_array($uniques_array) && isset($uniques_array[$links[$i]]) && !empty($uniques_array[$links[$i]]))?$uniques_array[$links[$i]]:0);
|
212 |
-
}
|
213 |
-
|
214 |
-
$top_hits = (($hits && is_array($hits))?$prli_utils->getTopValue($hits):0);
|
215 |
-
$top_uniques = (($uniques && is_array($uniques))?$prli_utils->getTopValue($uniques):0);
|
216 |
-
|
217 |
-
if( !empty($goal_link_id) && $goal_link_id ) {
|
218 |
-
$goal_link = $prli_link->getOne($goal_link_id);
|
219 |
-
$conversions_array = $plp_report->get_split_conversions($start_timestamp,$end_timestamp,$link_id,$goal_link_id);
|
220 |
-
|
221 |
-
$conversions = array();
|
222 |
-
for($i=0;$i<count($links);$i++) {
|
223 |
-
$conversions[$i] = ((is_array($conversions_array) && isset($conversions_array[$links[$i]]) && !empty($conversions_array[$links[$i]]))?$conversions_array[$links[$i]]:0);
|
224 |
-
}
|
225 |
-
|
226 |
-
$conv_rates = array();
|
227 |
-
for($i=0; $i<count($links); $i++) {
|
228 |
-
$conv_rates[] = (($uniques[$i] > 0)?sprintf( "%0.2f", (float)($conversions[$i] / $uniques[$i] * 100.0) ):'0.00');
|
229 |
-
}
|
230 |
-
|
231 |
-
$top_conversions = $prli_utils->getTopValue(array_values($conversions));
|
232 |
-
$top_conv_rate = $prli_utils->getTopValue(array_values($conv_rates));
|
233 |
-
}
|
234 |
-
|
235 |
-
require_once(PLP_VIEWS_PATH . '/reports/split-test-report.php');
|
236 |
-
}
|
237 |
-
|
238 |
-
private function display_reports_list( $params,
|
239 |
-
$prli_message,
|
240 |
-
$page_params_ov=false,
|
241 |
-
$current_page_ov=false ) {
|
242 |
-
global $wpdb, $prli_utils, $plp_report, $page_size;
|
243 |
-
|
244 |
-
$report_vars = $this->get_report_sort_vars($params);
|
245 |
-
|
246 |
-
if($current_page_ov) {
|
247 |
-
$current_page = $current_page_ov;
|
248 |
-
}
|
249 |
-
else {
|
250 |
-
$current_page = $params['paged'];
|
251 |
-
}
|
252 |
-
|
253 |
-
$page_params = '&action=list';
|
254 |
-
|
255 |
-
if($page_params_ov) {
|
256 |
-
$page_params .= $page_params_ov;
|
257 |
-
}
|
258 |
-
else {
|
259 |
-
$page_params .= $report_vars['page_params'];
|
260 |
-
}
|
261 |
-
|
262 |
-
$sort_str = $report_vars['sort_str'];
|
263 |
-
$sdir_str = $report_vars['sdir_str'];
|
264 |
-
$search_str = $report_vars['search_str'];
|
265 |
-
|
266 |
-
$record_count = $plp_report->getRecordCount($report_vars['where_clause']);
|
267 |
-
$page_count = $plp_report->getPageCount($page_size,$report_vars['where_clause']);
|
268 |
-
$reports = $plp_report->getPage($current_page,$page_size,$report_vars['where_clause'],$report_vars['order_by']);
|
269 |
-
$page_last_record = $prli_utils->getLastRecordNum($record_count,$current_page,$page_size);
|
270 |
-
$page_first_record = $prli_utils->getFirstRecordNum($record_count,$current_page,$page_size);
|
271 |
-
|
272 |
-
require_once(PLP_VIEWS_PATH . '/reports/list.php');
|
273 |
-
}
|
274 |
-
|
275 |
-
private function get_report_sort_vars($params,$where_clause = '') {
|
276 |
-
$order_by = '';
|
277 |
-
$page_params = '';
|
278 |
-
|
279 |
-
// These will have to work with both get and post
|
280 |
-
$sort_str = $params['sort'];
|
281 |
-
$sdir_str = $params['sdir'];
|
282 |
-
$search_str = $params['search'];
|
283 |
-
|
284 |
-
// Insert search string
|
285 |
-
if(!empty($search_str)) {
|
286 |
-
global $wpdb;
|
287 |
-
$search_params = explode(" ", $search_str);
|
288 |
-
|
289 |
-
foreach($search_params as $search_param) {
|
290 |
-
if(!empty($where_clause)) {
|
291 |
-
$where_clause .= " AND";
|
292 |
-
}
|
293 |
-
|
294 |
-
$search_param = '%' . $wpdb->esc_like($search_param) . '%';
|
295 |
-
|
296 |
-
//goal_link_name doesn't exist any longer
|
297 |
-
$where_clause .= $wpdb->prepare(
|
298 |
-
" (rp.name like %s OR rp.created_at like %s)",
|
299 |
-
$search_param,
|
300 |
-
$search_param
|
301 |
-
);
|
302 |
-
}
|
303 |
-
|
304 |
-
$page_params .="&search=$search_str";
|
305 |
-
}
|
306 |
-
|
307 |
-
// make sure page params stay correct
|
308 |
-
if(!empty($sort_str)) {
|
309 |
-
$page_params .="&sort=$sort_str";
|
310 |
-
}
|
311 |
-
|
312 |
-
if(!empty($sdir_str)) {
|
313 |
-
$page_params .= "&sdir=$sdir_str";
|
314 |
-
}
|
315 |
-
|
316 |
-
// Add order by clause
|
317 |
-
switch($sort_str) {
|
318 |
-
case 'name':
|
319 |
-
case 'goal_link_name':
|
320 |
-
case 'link_count':
|
321 |
-
$order_by .= " ORDER BY {$sort_str}";
|
322 |
-
break;
|
323 |
-
default:
|
324 |
-
$order_by .= ' ORDER BY created_at';
|
325 |
-
}
|
326 |
-
|
327 |
-
// Toggle ascending / descending
|
328 |
-
if((empty($sort_str) and empty($sdir_str)) or $sdir_str == 'desc') {
|
329 |
-
$order_by .= ' DESC';
|
330 |
-
$sdir_str = 'desc';
|
331 |
-
}
|
332 |
-
else {
|
333 |
-
$sdir_str = 'asc';
|
334 |
-
}
|
335 |
-
|
336 |
-
return array( 'order_by' => $order_by,
|
337 |
-
'sort_str' => $sort_str,
|
338 |
-
'sdir_str' => $sdir_str,
|
339 |
-
'search_str' => $search_str,
|
340 |
-
'where_clause' => $where_clause,
|
341 |
-
'page_params' => $page_params );
|
342 |
-
}
|
343 |
-
}
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpSocialButtonsController.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpSocialButtonsController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_filter('the_content', array($this, 'add_social_buttons_to_content'), 1000); //WARNING - This priority must be higher than keyword replacements
|
6 |
-
add_filter('get_the_excerpt', array($this, 'excerpt_remove_social_buttons'), 1);
|
7 |
-
add_shortcode('social_buttons_bar', array($this,'social_buttons_bar'));
|
8 |
-
}
|
9 |
-
|
10 |
-
public function social_buttons_bar() {
|
11 |
-
global $post, $plp_options, $wp_query;
|
12 |
-
|
13 |
-
if(!isset($post) || !isset($post->ID)) { return ''; }
|
14 |
-
|
15 |
-
$plp_post_options = PlpPostOptions::get_options($post->ID);
|
16 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
17 |
-
|
18 |
-
if(get_post_status($post->ID) != 'publish' || // Don't show until published
|
19 |
-
$plp_post_options->hide_social_buttons || // Don't show if post is hidden
|
20 |
-
(is_feed() && !$plp_options->social_buttons_show_in_feed) || // Only show in feed if option checked
|
21 |
-
!$ac->enabled || !$ac->socbtns) // Only show if links enabled and social button
|
22 |
-
{ return ''; }
|
23 |
-
|
24 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post->ID,"_pretty-link",true);
|
25 |
-
|
26 |
-
return PlpSocialButtonsHelper::get_social_buttons_bar($pretty_link_id);
|
27 |
-
}
|
28 |
-
|
29 |
-
// Puts a tweet this button on each post
|
30 |
-
public function add_social_buttons_to_content($content) {
|
31 |
-
global $plp_options;
|
32 |
-
|
33 |
-
//Don't run this more than once
|
34 |
-
static $here;
|
35 |
-
if(isset($here) && $here === true) { return $content; }
|
36 |
-
$here = true;
|
37 |
-
|
38 |
-
if($plp_options->social_buttons_placement == 'none') {
|
39 |
-
return $content;
|
40 |
-
}
|
41 |
-
|
42 |
-
$social_buttons = $this->social_buttons_bar();
|
43 |
-
|
44 |
-
if(!empty($social_buttons)) {
|
45 |
-
if($plp_options->social_buttons_placement == 'bottom') {
|
46 |
-
return "{$content}{$social_buttons}";
|
47 |
-
}
|
48 |
-
else if($plp_options->social_buttons_placement == 'top') {
|
49 |
-
return "{$social_buttons}{$content}";
|
50 |
-
}
|
51 |
-
else if($plp_options->social_buttons_placement == 'top-and-bottom') {
|
52 |
-
return "{$social_buttons}{$content}{$social_buttons}";
|
53 |
-
}
|
54 |
-
}
|
55 |
-
else {
|
56 |
-
return $content;
|
57 |
-
}
|
58 |
-
}
|
59 |
-
|
60 |
-
public function excerpt_remove_social_buttons($excerpt) {
|
61 |
-
if(!is_feed()) { remove_filter('the_content', array($this,'add_social_buttons_to_content')); }
|
62 |
-
return $excerpt;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
// The template tag for social buttons
|
67 |
-
function the_social_buttons_bar() {
|
68 |
-
$ctrl = new PlpSocialButtonsController();
|
69 |
-
echo $ctrl->social_buttons_bar();
|
70 |
-
}
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpToolsController.php
DELETED
@@ -1,18 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpToolsController extends PrliBaseController {
|
4 |
-
public function load_hooks() {
|
5 |
-
add_action( 'prli_admin_tools_nav', array( $this, 'bookmarklet_nav' ) );
|
6 |
-
add_action( 'prli_admin_tools_pages', array( $this, 'bookmarklet_generator' ) );
|
7 |
-
}
|
8 |
-
|
9 |
-
public function bookmarklet_generator() {
|
10 |
-
global $prli_blogurl, $prli_options;
|
11 |
-
require( PLP_VIEWS_PATH . '/tools/generator.php' );
|
12 |
-
}
|
13 |
-
|
14 |
-
public function bookmarklet_nav() {
|
15 |
-
require( PLP_VIEWS_PATH . '/tools/nav.php' );
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/PlpTwitterController.php
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
// DEPRECATED
|
5 |
-
class PlpTwitterController extends PrliBaseController {
|
6 |
-
public function load_hooks() {
|
7 |
-
// Gracefully deprecated shortcode
|
8 |
-
add_shortcode('tweetbadge', array($this,'the_tweetbadge'));
|
9 |
-
}
|
10 |
-
}
|
11 |
-
|
12 |
-
// Template Tag for Tweet Badge
|
13 |
-
function the_tweetbadge() {
|
14 |
-
// No longer supported
|
15 |
-
}
|
16 |
-
|
17 |
-
// Template Tag for Tweet Comments
|
18 |
-
// Gracefully ignore comments if this tag is in use
|
19 |
-
function the_tweet_comments() {
|
20 |
-
// No longer supported
|
21 |
-
}
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/controllers/index.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php /* Silence will fall */ ?>
|
2 |
-
|
|
|
|
pro/app/helpers/PlpLinksHelper.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpLinksHelper {
|
4 |
-
public static function rotation_weight_dropdown($rotation_weight, $select_name="url_rotation_weights[]") {
|
5 |
-
?>
|
6 |
-
<select name="<?php echo esc_attr($select_name); ?>">
|
7 |
-
<?php for($p=0; $p<=100; $p+=1) { ?>
|
8 |
-
<option value="<?php echo esc_attr($p); ?>"<?php selected((int)$p, (int)$rotation_weight); ?>><?php echo esc_html($p); ?>% </option>
|
9 |
-
<?php } ?>
|
10 |
-
</select>
|
11 |
-
<?php
|
12 |
-
}
|
13 |
-
|
14 |
-
public static function rotation_row($rotation, $weight, $select_name="url_rotations[]", $weight_select_name="url_rotation_weights[]") {
|
15 |
-
?>
|
16 |
-
<li>
|
17 |
-
<input type="text" class="regular-text" name="<?php echo esc_attr($select_name); ?>" value="<?php echo esc_attr($rotation); ?>" />
|
18 |
-
<?php esc_html_e('weight:', 'pretty-link'); ?>
|
19 |
-
<?php self::rotation_weight_dropdown($weight); ?>
|
20 |
-
</li>
|
21 |
-
<?php
|
22 |
-
}
|
23 |
-
|
24 |
-
public static function geo_row($geo_url='', $geo_countries='') {
|
25 |
-
require(PLP_VIEWS_PATH.'/links/geo_row.php');
|
26 |
-
}
|
27 |
-
|
28 |
-
public static function tech_row($tech_url='', $tech_device='', $tech_os='', $tech_browser='') {
|
29 |
-
require(PLP_VIEWS_PATH.'/links/tech_row.php');
|
30 |
-
}
|
31 |
-
|
32 |
-
public static function time_row($time_url='', $time_start='', $time_end='') {
|
33 |
-
require(PLP_VIEWS_PATH.'/links/time_row.php');
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpOptionsHelper.php
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) die('You are not allowed to call this page directly.');
|
2 |
-
|
3 |
-
class PlpOptionsHelper {
|
4 |
-
public static function autocreate_post_options($post_type, $option, $category, $socbtns) {
|
5 |
-
// For reverse-compatibility
|
6 |
-
if($post_type=='post' || $post_type=='page') {
|
7 |
-
$option_name = "prli_{$post_type}s_auto";
|
8 |
-
$category_name = "prli_{$post_type}s_category";
|
9 |
-
$socbtns_name = "prli_social_{$post_type}s_buttons";
|
10 |
-
}
|
11 |
-
else {
|
12 |
-
$option_name = "prli_autocreate[{$post_type}][enabled]";
|
13 |
-
$category_name = "prli_autocreate[{$post_type}][category]";
|
14 |
-
$socbtns_name = "prli_autocreate[{$post_type}][socbtns]";
|
15 |
-
}
|
16 |
-
|
17 |
-
$p = get_post_type_object($post_type);
|
18 |
-
|
19 |
-
require(PLP_VIEWS_PATH . '/options/autocreate.php');
|
20 |
-
}
|
21 |
-
|
22 |
-
public static function autocreate_all_cpt_options() {
|
23 |
-
global $plp_options;
|
24 |
-
|
25 |
-
$post_types = $plp_options->get_post_types(false);
|
26 |
-
|
27 |
-
foreach($post_types as $post_type) {
|
28 |
-
$option = !empty($plp_options->autocreate[$post_type]['enabled']);
|
29 |
-
$category = !empty($plp_options->autocreate[$post_type]['category']) ? $plp_options->autocreate[$post_type]['category'] : '';
|
30 |
-
$socbtns = !empty($plp_options->autocreate[$post_type]['socbtns']);
|
31 |
-
|
32 |
-
self::autocreate_post_options($post_type, $option, $category, $socbtns);
|
33 |
-
}
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpPostsHelper.php
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpPostsHelper {
|
4 |
-
public static function post_options($post) {
|
5 |
-
global $plp_options;
|
6 |
-
|
7 |
-
$plp_post_options = PlpPostOptions::get_options($post->ID);
|
8 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
9 |
-
$post_types = $plp_options->get_post_types();
|
10 |
-
|
11 |
-
?>
|
12 |
-
<!-- The NONCE below prevents post meta from being blanked on move to trash -->
|
13 |
-
<input type="hidden" name="plp_nonce" value="<?php echo wp_create_nonce('plp_nonce'.wp_salt()); ?>" />
|
14 |
-
<?php
|
15 |
-
|
16 |
-
if( $ac->socbtns ) {
|
17 |
-
$checked = $plp_post_options->hide_social_buttons;
|
18 |
-
?>
|
19 |
-
<span><input type="checkbox" name="hide_social_buttons" id="hide_social_buttons"<?php checked($checked); ?> /> <?php esc_html_e('Hide Social Buttons on this post.', 'pretty-link'); ?></span><br/>
|
20 |
-
<?php
|
21 |
-
}
|
22 |
-
|
23 |
-
if(in_array($post->post_type, $post_types) && $plp_options->keyword_replacement_is_on ) {
|
24 |
-
$checked = $plp_post_options->disable_replacements;
|
25 |
-
?>
|
26 |
-
<span><input type="checkbox" name="disable_replacements" id="disable_replacements"<?php checked($checked); ?> /> <?php esc_html_e('Disable Keyword Replacements on this post.', 'pretty-link'); ?></span><br/>
|
27 |
-
<?php
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
public static function post_sidebar($post) {
|
32 |
-
global $prli_blogurl, $plp_options, $prli_link, $prli_link_meta;
|
33 |
-
|
34 |
-
$plp_post_options = PlpPostOptions::get_options($post->ID);
|
35 |
-
$ac = $plp_options->autocreate_option($post->post_type);
|
36 |
-
|
37 |
-
do_action('prlipro_sidebar_top');
|
38 |
-
|
39 |
-
// Make sure the prli process routines are called on submit
|
40 |
-
?><input type="hidden" name="prli_process_tweet_form" id="prli_process_tweet_form" value="Y" /><?php
|
41 |
-
|
42 |
-
if($post->post_status != 'publish') {
|
43 |
-
?>
|
44 |
-
<div><?php esc_html_e('A Pretty Link will be created on Publish', 'pretty-link'); ?></div>
|
45 |
-
<div>
|
46 |
-
<strong><?php echo esc_url($prli_blogurl . PrliUtils::get_permalink_pre_slug_uri()); ?></strong>
|
47 |
-
<input type="text" style="width: 100px;" name="prli_req_slug" id="prli_req_slug" value="<?php echo esc_attr((!empty($plp_post_options->requested_slug))?$plp_post_options->requested_slug:$prli_link->generateValidSlug()); ?>" />
|
48 |
-
</div>
|
49 |
-
<?php
|
50 |
-
}
|
51 |
-
else {
|
52 |
-
$pretty_link_id = PrliUtils::get_prli_post_meta($post->ID,"_pretty-link",true);
|
53 |
-
$pretty_link = $prli_link->getOne($pretty_link_id, OBJECT, true);
|
54 |
-
|
55 |
-
if(!empty($pretty_link) && $pretty_link) {
|
56 |
-
$pretty_link_url = $prli_blogurl.PrliUtils::get_permalink_pre_slug_uri().$pretty_link->slug;
|
57 |
-
|
58 |
-
?>
|
59 |
-
<p>
|
60 |
-
<span style="font-size: 24px;"><?php echo esc_html((empty($pretty_link->clicks) || $pretty_link->clicks===false)?0:$pretty_link->clicks); ?></span>
|
61 |
-
<?php esc_html_e('Clicks', 'pretty-link'); ?>
|
62 |
-
<span style="font-size: 24px;"><?php echo esc_html((empty($pretty_link->uniques) || $pretty_link->uniques===false)?0:$pretty_link->uniques); ?></span>
|
63 |
-
<?php esc_html_e('Uniques', 'pretty-link'); ?>
|
64 |
-
</p>
|
65 |
-
<p>
|
66 |
-
<?php esc_html_e('Pretty Link:', 'pretty-link'); ?><br/>
|
67 |
-
<strong><?php echo esc_url($pretty_link_url); ?></strong><br/>
|
68 |
-
<a href="<?php echo esc_url(admin_url("post.php?post={$pretty_link->link_cpt_id}&action=edit")); ?>"><?php esc_html_e('edit', 'pretty-link'); ?></a>
|
69 |
-
|
|
70 |
-
<a href="<?php echo esc_url($pretty_link_url); ?>" target="_blank" title="<?php esc_attr_e('Visit Pretty Link:', 'pretty-link'); echo esc_html($pretty_link_url); esc_html_e('in a New Window', 'pretty-link'); ?>"><?php esc_html_e('visit', 'pretty-link'); ?></a>
|
71 |
-
</p>
|
72 |
-
<?php
|
73 |
-
}
|
74 |
-
else {
|
75 |
-
?>
|
76 |
-
<p><?php esc_html_e('A Pretty Link hasn\'t been generated for this entry yet. Click "Update Post" to generate.', 'pretty-link'); ?></p>
|
77 |
-
<p><strong><?php echo esc_url($prli_blogurl . PrliUtils::get_permalink_pre_slug_uri()); ?></strong><input type="text" style="width: 100px;" name="prli_req_slug" id="prli_req_slug" value="<?php echo esc_attr((!empty($plp_post_options->requested_slug))?$plp_post_options->requested_slug:$prli_link->generateValidSlug()); ?>" />
|
78 |
-
</p>
|
79 |
-
<?php
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
83 |
-
}
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpPrettyBarHelper.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
// PrettyBar stuff here of course
|
4 |
-
class PlpPrettyBarHelper {
|
5 |
-
public static function render_prettybar($slug) {
|
6 |
-
global $prli_blogurl, $prli_link, $prli_options, $prli_blogname, $prli_blogdescription, $target_url;
|
7 |
-
|
8 |
-
if($link = $prli_link->getOneFromSlug( $slug )) {
|
9 |
-
$bar_image = $prli_options->prettybar_image_url;
|
10 |
-
$bar_background_image = $prli_options->prettybar_background_image_url;
|
11 |
-
$bar_color = $prli_options->prettybar_color;
|
12 |
-
$bar_text_color = $prli_options->prettybar_text_color;
|
13 |
-
$bar_link_color = $prli_options->prettybar_link_color;
|
14 |
-
$bar_visited_color = $prli_options->prettybar_visited_color;
|
15 |
-
$bar_hover_color = $prli_options->prettybar_hover_color;
|
16 |
-
$bar_show_title = $prli_options->prettybar_show_title;
|
17 |
-
$bar_show_description = $prli_options->prettybar_show_description;
|
18 |
-
$bar_show_share_links = $prli_options->prettybar_show_share_links;
|
19 |
-
$bar_show_target_url_link = $prli_options->prettybar_show_target_url_link;
|
20 |
-
$bar_title_limit = (int)$prli_options->prettybar_title_limit;
|
21 |
-
$bar_desc_limit = (int)$prli_options->prettybar_desc_limit;
|
22 |
-
$bar_link_limit = (int)$prli_options->prettybar_link_limit;
|
23 |
-
|
24 |
-
$target_url = $link->url;
|
25 |
-
|
26 |
-
$shortened_title = stripslashes(substr($prli_blogname,0,$bar_title_limit));
|
27 |
-
$shortened_desc = stripslashes(substr($prli_blogdescription,0,$bar_desc_limit));
|
28 |
-
$shortened_link = stripslashes(substr($target_url,0,$bar_link_limit));
|
29 |
-
|
30 |
-
if(strlen($prli_blogname) > $bar_title_limit) {
|
31 |
-
$shortened_title .= "...";
|
32 |
-
}
|
33 |
-
|
34 |
-
if(strlen($prli_blogdescription) > $bar_desc_limit) {
|
35 |
-
$shortened_desc .= "...";
|
36 |
-
}
|
37 |
-
|
38 |
-
if(strlen($target_url) > $bar_link_limit) {
|
39 |
-
$shortened_link .= "...";
|
40 |
-
}
|
41 |
-
|
42 |
-
wp_register_style('fontello-animation', PRLI_VENDOR_LIB_URL.'/fontello/css/animation.css', array(), PRLI_VERSION);
|
43 |
-
wp_register_style('fontello-pretty-link', PRLI_VENDOR_LIB_URL.'/fontello/css/pretty-link.css', array(), PRLI_VERSION);
|
44 |
-
wp_register_style('prli-prettybar', PLP_CSS_URL.'/prettybar.css', array(), PRLI_VERSION);
|
45 |
-
|
46 |
-
$css = '';
|
47 |
-
|
48 |
-
if(!empty($bar_background_image) && $bar_background_image) {
|
49 |
-
$css .= sprintf('html, body { background-image: url(%s); background-repeat: repeat-x; }', esc_url($bar_background_image));
|
50 |
-
} else {
|
51 |
-
$css .= sprintf('html, body { background-color: %s; }', esc_html($bar_color));
|
52 |
-
}
|
53 |
-
|
54 |
-
$css .= sprintf('html, body { color: %s; }', esc_html($bar_text_color));
|
55 |
-
$css .= sprintf('a { color: %s; }', esc_html($bar_link_color));
|
56 |
-
$css .= sprintf('a:visited { color: %s; }', esc_html($bar_visited_color));
|
57 |
-
$css .= sprintf('a:hover { color: %s; }', esc_html($bar_hover_color));
|
58 |
-
|
59 |
-
wp_add_inline_style('prli-prettybar', $css);
|
60 |
-
|
61 |
-
require(PLP_VIEWS_PATH . '/links/prettybar.php');
|
62 |
-
}
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpPublicLinksHelper.php
DELETED
@@ -1,19 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpPublicLinksHelper {
|
5 |
-
public static function display_form($label=null, $button=null, $redirect_type=null, $track=null, $category=null) {
|
6 |
-
$label = is_null($label)?__('Enter a URL:', 'pretty-link'):$label;
|
7 |
-
$button = is_null($button)?__('Shrink', 'pretty-link'):$button;
|
8 |
-
$track = is_null($track)?'-1':$track;
|
9 |
-
$category = is_null($category)?'-1':$category;
|
10 |
-
$redirect_type = is_null($redirect_type)?'-1':$redirect_type;
|
11 |
-
|
12 |
-
ob_start();
|
13 |
-
require(PLP_VIEWS_PATH . '/public/form.php');
|
14 |
-
$formhtml = ob_get_clean();
|
15 |
-
|
16 |
-
return $formhtml;
|
17 |
-
}
|
18 |
-
}
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpSocialButtonsHelper.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpSocialButtonsHelper {
|
5 |
-
public static function get_social_buttons_bar($pretty_link_id) {
|
6 |
-
global $prli_blogurl, $plp_options, $prli_link, $prli_link_meta;
|
7 |
-
|
8 |
-
$pretty_link = $prli_link->getOne($pretty_link_id);
|
9 |
-
|
10 |
-
if(is_object($pretty_link)) {
|
11 |
-
$shorturl = apply_filters(
|
12 |
-
'prli_social_bar_url',
|
13 |
-
$prli_blogurl.PrliUtils::get_permalink_pre_slug_uri().$pretty_link->slug,
|
14 |
-
$pretty_link_id
|
15 |
-
);
|
16 |
-
}
|
17 |
-
else {
|
18 |
-
return '';
|
19 |
-
}
|
20 |
-
|
21 |
-
// If there's no short url then don't show the badge
|
22 |
-
if(empty($shorturl)) { return ''; }
|
23 |
-
|
24 |
-
$tweet_message = PlpTwitterHelper::get_twitter_status_message($shorturl,$pretty_link->name);
|
25 |
-
$tweet_message = urlencode(trim(strip_tags($tweet_message)));
|
26 |
-
|
27 |
-
$encoded_url = urlencode($shorturl);
|
28 |
-
$encoded_title = urlencode($pretty_link->name);
|
29 |
-
|
30 |
-
$patterns = array( '/\{\{encoded_url\}\}/', '/\{\{encoded_title\}\}/', '/\{\{tweet_message\}\}/' );
|
31 |
-
$replacements = compact( 'encoded_url', 'encoded_title', 'tweet_message' );
|
32 |
-
|
33 |
-
$show_bar = false;
|
34 |
-
|
35 |
-
$social_buttons = apply_filters('prli_social_bar_obj', $plp_options->social_buttons, $pretty_link, $shorturl, $replacements);
|
36 |
-
|
37 |
-
ob_start();
|
38 |
-
?>
|
39 |
-
<ul class="prli-social-buttons">
|
40 |
-
<?php
|
41 |
-
|
42 |
-
foreach($social_buttons as $b) {
|
43 |
-
if( $b['checked'] ) {
|
44 |
-
$show_bar = true; // if we have even one button, we show the social bar
|
45 |
-
$button_url = preg_replace( $patterns, $replacements, $b['url'] );
|
46 |
-
?>
|
47 |
-
<li>
|
48 |
-
<a class="pl-social-<?php echo esc_attr($b['slug']); ?>-button" href="<?php echo esc_url($button_url); ?>" rel="nofollow" target="_blank" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');return false;">
|
49 |
-
<i class="<?php echo esc_attr($b['icon']); ?>"> </i>
|
50 |
-
</a>
|
51 |
-
</li>
|
52 |
-
<?php
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
?>
|
57 |
-
</ul>
|
58 |
-
<?php
|
59 |
-
|
60 |
-
$social_buttons = $show_bar ? ob_get_clean() : '';
|
61 |
-
|
62 |
-
return apply_filters('prli_social_bar_html', $social_buttons, $pretty_link, $shorturl, $replacements);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/PlpTwitterHelper.php
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpTwitterHelper {
|
5 |
-
public static function get_twitter_status_message($pretty_link_url, $pretty_link_name, $tweet_format="{%title%} {%url%}") {
|
6 |
-
global $plp_options;
|
7 |
-
|
8 |
-
//ADDED BY PAUL 1.5.5 - fix for $29.99 being in post title
|
9 |
-
$pretty_link_name = str_replace("$", "%24", $pretty_link_name);
|
10 |
-
|
11 |
-
$tweet_message = preg_replace("#\{\%title\%\}#", stripslashes($pretty_link_name), $tweet_format);
|
12 |
-
$tweet_message = preg_replace("#\{\%url\%\}#", $pretty_link_url, $tweet_message);
|
13 |
-
|
14 |
-
// 120 to leave room for retweeting a 140 char tweet
|
15 |
-
if(strlen($tweet_message) > 120) {
|
16 |
-
$non_title_size = strlen($tweet_message) - strlen($pretty_link_name);
|
17 |
-
$title_size = 120 - $non_title_size;
|
18 |
-
$link_title = substr($pretty_link_name, 0, $title_size);
|
19 |
-
$tweet_message = preg_replace("#\{\%title\%\}#", stripslashes($link_title), $tweet_format);
|
20 |
-
$tweet_message = preg_replace("#\{\%url\%\}#", $pretty_link_url, $tweet_message);
|
21 |
-
}
|
22 |
-
|
23 |
-
return $tweet_message;
|
24 |
-
}
|
25 |
-
}
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/helpers/index.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php /* Silence will fall */ ?>
|
2 |
-
|
|
|
|
pro/app/index.php
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
<?php /* Silence will fall */ ?>
|
2 |
-
|
|
|
|
pro/app/models/PlpKeyword.php
DELETED
@@ -1,724 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpKeyword {
|
5 |
-
public $table_name, $post_keywords_table_name;
|
6 |
-
|
7 |
-
public function __construct() {
|
8 |
-
global $wpdb;
|
9 |
-
$this->table_name = "{$wpdb->prefix}prli_keywords";
|
10 |
-
$this->post_keywords_table_name = "{$wpdb->prefix}prli_post_keywords";
|
11 |
-
}
|
12 |
-
|
13 |
-
public function create($keyword,$link_id) {
|
14 |
-
global $wpdb;
|
15 |
-
|
16 |
-
$query_str = "
|
17 |
-
INSERT INTO {$this->table_name}
|
18 |
-
(text, link_id, created_at)
|
19 |
-
VALUES
|
20 |
-
(%s,%d,NOW())
|
21 |
-
";
|
22 |
-
|
23 |
-
$query = $wpdb->prepare(
|
24 |
-
$query_str,
|
25 |
-
$keyword,
|
26 |
-
$link_id
|
27 |
-
);
|
28 |
-
|
29 |
-
$query_results = $wpdb->query($query);
|
30 |
-
|
31 |
-
if($query_results) {
|
32 |
-
return $wpdb->insert_id;
|
33 |
-
}
|
34 |
-
else {
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
public function get_removed_keywords($link_id, $keywords) {
|
40 |
-
global $wpdb;
|
41 |
-
|
42 |
-
$keywords = array_map(
|
43 |
-
function($kw) {
|
44 |
-
return trim($kw);
|
45 |
-
},
|
46 |
-
$keywords
|
47 |
-
|
48 |
-
);
|
49 |
-
|
50 |
-
$q = $wpdb->prepare("
|
51 |
-
SELECT kw.*
|
52 |
-
FROM {$this->table_name} AS kw
|
53 |
-
WHERE kw.link_id=%d
|
54 |
-
",
|
55 |
-
$link_id
|
56 |
-
);
|
57 |
-
$kws = $wpdb->get_results($q);
|
58 |
-
|
59 |
-
$removed_ids = array();
|
60 |
-
if(is_array($kws) && !empty($kws)) {
|
61 |
-
foreach($kws as $kw) {
|
62 |
-
if(!in_array($kw->text, $keywords)) {
|
63 |
-
$removed_ids[] = $kw->id;
|
64 |
-
}
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
return $removed_ids;
|
69 |
-
}
|
70 |
-
|
71 |
-
public function delete_removed_keywords($link_id, $keywords) {
|
72 |
-
global $wpdb;
|
73 |
-
|
74 |
-
$keywords = explode(',',$keywords);
|
75 |
-
|
76 |
-
$removed_ids = $this->get_removed_keywords($link_id, $keywords);
|
77 |
-
|
78 |
-
if(!empty($removed_ids)) {
|
79 |
-
$idstr = implode(',', $removed_ids);
|
80 |
-
|
81 |
-
// Clear the index of these keywords
|
82 |
-
$q = "
|
83 |
-
DELETE FROM {$this->post_keywords_table_name}
|
84 |
-
WHERE keyword_id IN ({$idstr})
|
85 |
-
";
|
86 |
-
$wpdb->query($q);
|
87 |
-
|
88 |
-
// Clear the keywords themselves
|
89 |
-
$q = "
|
90 |
-
DELETE FROM {$this->table_name}
|
91 |
-
WHERE id IN ({$idstr})
|
92 |
-
";
|
93 |
-
$wpdb->query($q);
|
94 |
-
}
|
95 |
-
}
|
96 |
-
|
97 |
-
public function get_added_keywords($link_id, $keywords) {
|
98 |
-
global $wpdb;
|
99 |
-
|
100 |
-
$keywords = array_map(
|
101 |
-
function($kw) {
|
102 |
-
return trim($kw);
|
103 |
-
},
|
104 |
-
$keywords
|
105 |
-
);
|
106 |
-
|
107 |
-
$q = $wpdb->prepare("
|
108 |
-
SELECT text
|
109 |
-
FROM {$this->table_name} AS kw
|
110 |
-
WHERE kw.link_id=%d
|
111 |
-
",
|
112 |
-
$link_id
|
113 |
-
);
|
114 |
-
$kws = $wpdb->get_col($q);
|
115 |
-
|
116 |
-
return array_diff($keywords, $kws);
|
117 |
-
}
|
118 |
-
|
119 |
-
public function create_added_keywords($link_id, $keywords) {
|
120 |
-
$keywords = explode(',',$keywords);
|
121 |
-
|
122 |
-
$added_keywords = $this->get_added_keywords($link_id, $keywords);
|
123 |
-
|
124 |
-
// Create the new keywords
|
125 |
-
foreach($added_keywords as $added_keyword) {
|
126 |
-
if(!empty($added_keyword)) { //Don't save an empty keyword
|
127 |
-
$this->create(trim($added_keyword), $link_id);
|
128 |
-
}
|
129 |
-
}
|
130 |
-
}
|
131 |
-
|
132 |
-
public function updateLinkKeywords($link_id,$keywords) {
|
133 |
-
// Get rid of the old keywords
|
134 |
-
//$this->destroyByLinkId($link_id);
|
135 |
-
|
136 |
-
$this->delete_removed_keywords($link_id, $keywords);
|
137 |
-
$this->create_added_keywords($link_id, $keywords);
|
138 |
-
}
|
139 |
-
|
140 |
-
public function destroy( $id ) {
|
141 |
-
global $wpdb;
|
142 |
-
$query_str = "DELETE FROM {$this->table_name} WHERE id=%d";
|
143 |
-
$query = $wpdb->prepare($query_str,$id);
|
144 |
-
return $wpdb->query($query);
|
145 |
-
}
|
146 |
-
|
147 |
-
public function destroyByLinkId( $link_id ) {
|
148 |
-
global $wpdb;
|
149 |
-
$query_str = "DELETE FROM {$this->table_name} WHERE link_id=%d";
|
150 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
151 |
-
return $wpdb->query($query);
|
152 |
-
}
|
153 |
-
|
154 |
-
public function getOne( $id, $return_type = OBJECT ) {
|
155 |
-
global $wpdb;
|
156 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE id=%d";
|
157 |
-
$query = $wpdb->prepare($query_str,$id);
|
158 |
-
return $wpdb->get_row($query, $return_type);
|
159 |
-
}
|
160 |
-
|
161 |
-
public function getAllByLinkId( $link_id, $return_type = OBJECT ) {
|
162 |
-
global $wpdb;
|
163 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE link_id=%d ORDER BY text";
|
164 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
165 |
-
return $wpdb->get_results($query, $return_type);
|
166 |
-
}
|
167 |
-
|
168 |
-
public function getTextByLinkId( $link_id ) {
|
169 |
-
$keywords = $this->getAllByLinkId( $link_id );
|
170 |
-
|
171 |
-
$keywords_array = array();
|
172 |
-
foreach($keywords as $keyword)
|
173 |
-
$keywords_array[] = stripslashes(htmlspecialchars($keyword->text));
|
174 |
-
|
175 |
-
return implode( ', ', $keywords_array );
|
176 |
-
}
|
177 |
-
|
178 |
-
public function getAllUniqueKeywordsText() {
|
179 |
-
global $wpdb;
|
180 |
-
$query = "SELECT DISTINCT text FROM {$this->table_name}";
|
181 |
-
return $wpdb->get_col($query, 0);
|
182 |
-
}
|
183 |
-
|
184 |
-
public function getAll($where = '', $return_type = OBJECT) {
|
185 |
-
global $wpdb, $prli_utils;
|
186 |
-
$query_str = "SELECT * FROM {$this->table_name}" . $prli_utils->prepend_and_or_where(' WHERE', $where) . " ORDER BY text";
|
187 |
-
return $wpdb->get_results($query_str, $return_type);
|
188 |
-
}
|
189 |
-
|
190 |
-
// Returns an array of links that have this keyword
|
191 |
-
public function getLinksByKeyword($keyword) {
|
192 |
-
global $wpdb;
|
193 |
-
$query_str = "SELECT link_id FROM {$this->table_name} WHERE text=%s";
|
194 |
-
$query = $wpdb->prepare($query_str,$keyword);
|
195 |
-
return $wpdb->get_col($query,0);
|
196 |
-
}
|
197 |
-
|
198 |
-
public function request_url_matches_url($url) {
|
199 |
-
$url_pattern = $url;
|
200 |
-
$url_pattern = preg_replace('!^https?!','^https?',$url_pattern); // http / https
|
201 |
-
$url_pattern = preg_replace('!\/\\?!','/?\\?',$url_pattern); // optional trailing slash
|
202 |
-
$url_pattern = preg_replace('!\/$!','/?',$url_pattern); // optional trailing slash
|
203 |
-
|
204 |
-
$request_url = PrliUtils::full_request_url();
|
205 |
-
|
206 |
-
return preg_match('!' . preg_quote($url_pattern, '!') . '!', $request_url);
|
207 |
-
}
|
208 |
-
|
209 |
-
private function format_keywords_array($keywords) {
|
210 |
-
$links_array = array();
|
211 |
-
|
212 |
-
if(!is_null($keywords)) {
|
213 |
-
foreach($keywords as $keyword) {
|
214 |
-
// Filter out keywords that have a url matching the current uri
|
215 |
-
if(!$this->request_url_matches_url($keyword->link_url)) {
|
216 |
-
if(!isset($links_array[$keyword->keyword])) {
|
217 |
-
$links_array[$keyword->keyword] = array();
|
218 |
-
}
|
219 |
-
|
220 |
-
$links_array[$keyword->keyword][] = (object)array('url' => $keyword->url, 'title' => stripslashes($keyword->title));
|
221 |
-
}
|
222 |
-
}
|
223 |
-
}
|
224 |
-
|
225 |
-
return $links_array;
|
226 |
-
}
|
227 |
-
|
228 |
-
/** This will get all of the keywords to urls for the given post.
|
229 |
-
* This is also where our smart-caching will come into play.
|
230 |
-
*/
|
231 |
-
public function get_post_keywords_lookup($post_id) {
|
232 |
-
static $kws;
|
233 |
-
|
234 |
-
if(!isset($kws)) {
|
235 |
-
$kws = array();
|
236 |
-
}
|
237 |
-
|
238 |
-
if(!isset($kws[$post_id])) {
|
239 |
-
$index_keywords = get_option('plp_index_keywords', false);
|
240 |
-
if(empty($index_keywords)) { return $this->getKeywordToLinksArray($post_id); }
|
241 |
-
|
242 |
-
global $wpdb, $prli_link, $prli_blogurl;
|
243 |
-
|
244 |
-
$q = "
|
245 |
-
SELECT kw.text as keyword,
|
246 |
-
li.name as title,
|
247 |
-
li.url as link_url,
|
248 |
-
li.id as link_id,
|
249 |
-
CONCAT(%s,li.slug) AS url
|
250 |
-
FROM {$prli_link->table_name} li
|
251 |
-
JOIN {$this->table_name} kw
|
252 |
-
ON li.id=kw.link_id
|
253 |
-
JOIN {$this->post_keywords_table_name} AS pkw
|
254 |
-
ON kw.id = pkw.keyword_id
|
255 |
-
WHERE pkw.post_id=%d
|
256 |
-
AND kw.text <> %s
|
257 |
-
AND li.link_status='enabled'
|
258 |
-
ORDER BY CHAR_LENGTH(kw.text) DESC,
|
259 |
-
kw.text ASC
|
260 |
-
";
|
261 |
-
|
262 |
-
$struct = PrliUtils::get_permalink_pre_slug_uri();
|
263 |
-
$q = $wpdb->prepare($q, $prli_blogurl.$struct, $post_id, '');
|
264 |
-
|
265 |
-
$keywords = $wpdb->get_results($q);
|
266 |
-
|
267 |
-
$kws[$post_id] = $this->format_keywords_array($keywords);
|
268 |
-
}
|
269 |
-
|
270 |
-
return $kws[$post_id];
|
271 |
-
}
|
272 |
-
|
273 |
-
public function getKeywordToLinksArray($post_id = false) {
|
274 |
-
static $kws;
|
275 |
-
|
276 |
-
if(!isset($kws)) {
|
277 |
-
global $wpdb, $prli_link, $plp_keyword, $prli_blogurl;
|
278 |
-
|
279 |
-
//Don't return keywords that link back to the current post
|
280 |
-
if($post_id) {
|
281 |
-
$post_url_path = parse_url(get_permalink($post_id), PHP_URL_PATH);
|
282 |
-
$post_url_path = '%' . $wpdb->esc_like($post_url_path);
|
283 |
-
$and_str = $wpdb->prepare("AND li.url NOT LIKE %s", $post_url_path);
|
284 |
-
} else {
|
285 |
-
$and_str = '';
|
286 |
-
}
|
287 |
-
|
288 |
-
$struct = PrliUtils::get_permalink_pre_slug_uri();
|
289 |
-
$query = "
|
290 |
-
SELECT kw.text as keyword,
|
291 |
-
li.name as title,
|
292 |
-
li.url as link_url,
|
293 |
-
li.id as link_id,
|
294 |
-
CONCAT(%s,li.slug) AS url
|
295 |
-
FROM {$prli_link->table_name} li
|
296 |
-
JOIN {$plp_keyword->table_name} kw
|
297 |
-
ON li.id=kw.link_id
|
298 |
-
WHERE kw.text <> %s
|
299 |
-
AND li.link_status='enabled'
|
300 |
-
{$and_str}
|
301 |
-
ORDER BY CHAR_LENGTH(kw.text) DESC,
|
302 |
-
kw.text ASC
|
303 |
-
";
|
304 |
-
|
305 |
-
$query = $wpdb->prepare($query, $prli_blogurl.$struct, '');
|
306 |
-
$keywords = $wpdb->get_results($query);
|
307 |
-
|
308 |
-
$kws = $this->format_keywords_array($keywords);
|
309 |
-
}
|
310 |
-
|
311 |
-
return $kws;
|
312 |
-
}
|
313 |
-
|
314 |
-
public function post_has_post_keywords($post_id) {
|
315 |
-
global $wpdb;
|
316 |
-
|
317 |
-
$q = "
|
318 |
-
SELECT COUNT(*)
|
319 |
-
FROM {$this->post_keywords_table_name}
|
320 |
-
WHERE post_id=%d
|
321 |
-
";
|
322 |
-
$q = $wpdb->prepare($q, $post_id);
|
323 |
-
$count = (int)$wpdb->get_var($q);
|
324 |
-
|
325 |
-
return ($count > 0);
|
326 |
-
}
|
327 |
-
|
328 |
-
public function link_has_post_keywords($link_id) {
|
329 |
-
global $wpdb;
|
330 |
-
|
331 |
-
$q = "
|
332 |
-
SELECT COUNT(*)
|
333 |
-
FROM {$this->post_keywords_table_name} AS pkw
|
334 |
-
WHERE pkw.keyword_id IN (
|
335 |
-
SELECT kw.id
|
336 |
-
FROM {$this->table_name} AS kw
|
337 |
-
WHERE kw.link_id=%d
|
338 |
-
)
|
339 |
-
";
|
340 |
-
$q = $wpdb->prepare($q, $link_id);
|
341 |
-
$count = (int)$wpdb->get_var($q);
|
342 |
-
|
343 |
-
return ($count > 0);
|
344 |
-
}
|
345 |
-
|
346 |
-
public function delete_post_keywords_by_post_id($post_id) {
|
347 |
-
global $wpdb;
|
348 |
-
|
349 |
-
$q = "
|
350 |
-
DELETE FROM {$this->post_keywords_table_name}
|
351 |
-
WHERE post_id=%d
|
352 |
-
";
|
353 |
-
$q = $wpdb->prepare($q, $post_id);
|
354 |
-
|
355 |
-
return $wpdb->query($q);
|
356 |
-
}
|
357 |
-
|
358 |
-
public function delete_post_keywords_by_link_id($link_id) {
|
359 |
-
global $wpdb, $prli_link_meta;
|
360 |
-
|
361 |
-
// Delete ALL postmeta so we can start updating for this link
|
362 |
-
//delete_post_meta($post_id, '_plp_post_keywords_updated_at');
|
363 |
-
|
364 |
-
$q = "
|
365 |
-
DELETE FROM {$this->post_keywords_table_name} AS pkw
|
366 |
-
WHERE pkw.keyword_id IN (
|
367 |
-
SELECT kw.id
|
368 |
-
FROM {$this->table_name} AS kw
|
369 |
-
WHERE kw.link_id=%d
|
370 |
-
)
|
371 |
-
";
|
372 |
-
$q = $wpdb->prepare($q, $link_id);
|
373 |
-
|
374 |
-
return $wpdb->query($q);
|
375 |
-
}
|
376 |
-
|
377 |
-
// ENSURE NO LINKS WITH NULL updated_at
|
378 |
-
// SET any links with null as updated_at to current time
|
379 |
-
public function update_links_with_null_updated_at () {
|
380 |
-
global $wpdb, $prli_link;
|
381 |
-
|
382 |
-
$now = date('Y-m-d H:i:s');
|
383 |
-
|
384 |
-
$q = "
|
385 |
-
UPDATE {$prli_link->table_name}
|
386 |
-
SET updated_at=%s
|
387 |
-
WHERE updated_at IS NULL
|
388 |
-
";
|
389 |
-
$q = $wpdb->prepare($q, $now);
|
390 |
-
|
391 |
-
return $wpdb->query($q);
|
392 |
-
}
|
393 |
-
|
394 |
-
// SELECT posts where updated_at < than max link updated_at
|
395 |
-
public function get_indexable_posts ($max_count=100) {
|
396 |
-
global $wpdb, $plp_options, $prli_link;
|
397 |
-
|
398 |
-
$this->update_links_with_null_updated_at();
|
399 |
-
|
400 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
401 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
402 |
-
|
403 |
-
$q = "
|
404 |
-
SELECT max(kw.created_at)
|
405 |
-
FROM {$this->table_name} AS kw
|
406 |
-
";
|
407 |
-
$max_updated_at = $wpdb->get_var($q);
|
408 |
-
|
409 |
-
// Order to get oldest / null entries updated first
|
410 |
-
$q = $wpdb->prepare("
|
411 |
-
SELECT ID
|
412 |
-
FROM {$wpdb->posts} AS p
|
413 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
414 |
-
ON p.ID=pm.post_id
|
415 |
-
AND pm.meta_key='_plp_post_keywords_updated_at'
|
416 |
-
WHERE p.post_status = 'publish'
|
417 |
-
AND p.post_type IN ({$valid_types})
|
418 |
-
AND (
|
419 |
-
pm.meta_value IS NULL
|
420 |
-
OR pm.meta_value < %s
|
421 |
-
)
|
422 |
-
ORDER BY pm.meta_value ASC,p.post_date DESC
|
423 |
-
LIMIT %d
|
424 |
-
",
|
425 |
-
$max_updated_at,
|
426 |
-
$max_count
|
427 |
-
);
|
428 |
-
$posts = $wpdb->get_col($q);
|
429 |
-
|
430 |
-
return $posts;
|
431 |
-
}
|
432 |
-
|
433 |
-
// SELECT posts where updated_at < than max link updated_at
|
434 |
-
public function get_indexable_comments ($max_count=100) {
|
435 |
-
global $wpdb, $plp_options, $prli_link;
|
436 |
-
|
437 |
-
$this->update_links_with_null_updated_at();
|
438 |
-
|
439 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
440 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
441 |
-
|
442 |
-
$q = "
|
443 |
-
SELECT max(kw.created_at)
|
444 |
-
FROM {$this->table_name} AS kw
|
445 |
-
";
|
446 |
-
$max_updated_at = $wpdb->get_var($q);
|
447 |
-
|
448 |
-
// Order to get oldest / null entries updated first
|
449 |
-
$q = $wpdb->prepare("
|
450 |
-
SELECT c.comment_ID
|
451 |
-
FROM {$wpdb->comments} AS c
|
452 |
-
INNER JOIN {$wpdb->posts} AS p
|
453 |
-
ON c.comment_post_ID=p.ID
|
454 |
-
AND p.post_status = 'publish'
|
455 |
-
AND p.post_type IN ({$valid_types})
|
456 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
457 |
-
ON c.comment_ID=cm.comment_id
|
458 |
-
AND cm.meta_key='_plp_comment_keywords_updated_at'
|
459 |
-
WHERE c.comment_approved=1
|
460 |
-
AND (
|
461 |
-
cm.meta_value IS NULL
|
462 |
-
OR cm.meta_value < %s
|
463 |
-
)
|
464 |
-
ORDER BY cm.meta_value ASC,c.comment_date DESC
|
465 |
-
LIMIT 100
|
466 |
-
",
|
467 |
-
$max_updated_at
|
468 |
-
);
|
469 |
-
$comments = $wpdb->get_col($q);
|
470 |
-
|
471 |
-
return $comments;
|
472 |
-
}
|
473 |
-
|
474 |
-
private function get_post_grouped_keywords ($post_id) {
|
475 |
-
static $kws;
|
476 |
-
|
477 |
-
if(!isset($kws)) {
|
478 |
-
$kws = array();
|
479 |
-
}
|
480 |
-
|
481 |
-
if(!isset($kws[$post_id])) {
|
482 |
-
global $wpdb, $prli_link, $plp_options;
|
483 |
-
|
484 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
485 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
486 |
-
|
487 |
-
$q = "
|
488 |
-
SELECT * FROM (
|
489 |
-
SELECT kw.text, MIN(kw.id) AS id
|
490 |
-
FROM {$this->table_name} AS kw
|
491 |
-
JOIN {$wpdb->posts} AS p
|
492 |
-
ON p.ID=%d
|
493 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
494 |
-
ON pm.post_id=p.ID
|
495 |
-
AND pm.meta_key='_plp_post_keywords_updated_at'
|
496 |
-
WHERE p.post_status='publish'
|
497 |
-
AND p.post_type IN ({$valid_types})
|
498 |
-
AND (
|
499 |
-
pm.meta_value IS NULL
|
500 |
-
OR pm.meta_value < kw.created_at
|
501 |
-
)
|
502 |
-
GROUP BY kw.text
|
503 |
-
) as k
|
504 |
-
ORDER BY CHAR_LENGTH(k.text) DESC, k.text ASC
|
505 |
-
";
|
506 |
-
$q = $wpdb->prepare($q, $post_id);
|
507 |
-
|
508 |
-
$kws[$post_id] = $wpdb->get_results($q);
|
509 |
-
}
|
510 |
-
|
511 |
-
return $kws[$post_id];
|
512 |
-
}
|
513 |
-
|
514 |
-
private function get_comment_grouped_keywords ($comment_id) {
|
515 |
-
static $kws;
|
516 |
-
|
517 |
-
if(!isset($kws)) {
|
518 |
-
$kws = array();
|
519 |
-
}
|
520 |
-
|
521 |
-
if(!isset($kws[$comment_id])) {
|
522 |
-
global $wpdb, $prli_link, $plp_options;
|
523 |
-
|
524 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
525 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
526 |
-
|
527 |
-
$q = "
|
528 |
-
SELECT * FROM (
|
529 |
-
SELECT kw.text, MIN(kw.id) AS id
|
530 |
-
FROM {$this->table_name} AS kw
|
531 |
-
JOIN {$wpdb->comments} AS c
|
532 |
-
ON c.comment_ID=%d
|
533 |
-
JOIN {$wpdb->posts} AS p
|
534 |
-
ON p.ID=c.comment_post_ID
|
535 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
536 |
-
ON cm.comment_id=c.comment_ID
|
537 |
-
AND cm.meta_key='_plp_comment_keywords_updated_at'
|
538 |
-
WHERE c.comment_approved=1
|
539 |
-
AND p.post_status='publish'
|
540 |
-
AND p.post_type IN ({$valid_types})
|
541 |
-
AND (
|
542 |
-
cm.meta_value IS NULL
|
543 |
-
OR cm.meta_value < kw.created_at
|
544 |
-
)
|
545 |
-
GROUP BY kw.text
|
546 |
-
) as k
|
547 |
-
ORDER BY CHAR_LENGTH(k.text) DESC, k.text ASC
|
548 |
-
";
|
549 |
-
$q = $wpdb->prepare($q, $comment_id);
|
550 |
-
|
551 |
-
$kws[$comment_id] = $wpdb->get_results($q);
|
552 |
-
}
|
553 |
-
|
554 |
-
return $kws[$comment_id];
|
555 |
-
}
|
556 |
-
|
557 |
-
// Figure out keywords applicable to this post and index them appropriately
|
558 |
-
public function index_post ($post_id) {
|
559 |
-
global $plp_options;
|
560 |
-
$kws = $this->get_post_grouped_keywords($post_id);
|
561 |
-
$post_content = strip_tags(PrliUtils::get_post_content($post_id));
|
562 |
-
$this->index_content($post_id, $kws, $post_content);
|
563 |
-
update_post_meta($post_id, '_plp_post_keywords_updated_at', PrliUtils::now());
|
564 |
-
}
|
565 |
-
|
566 |
-
public function index_comment ($comment_id) {
|
567 |
-
global $plp_options;
|
568 |
-
$kws = $this->get_comment_grouped_keywords($comment_id);
|
569 |
-
$comment_content = strip_tags(get_comment_text($comment_id));
|
570 |
-
$comment = get_comment($comment_id);
|
571 |
-
$this->index_content($comment->comment_post_ID, $kws, $comment_content);
|
572 |
-
update_comment_meta($comment_id, '_plp_comment_keywords_updated_at', PrliUtils::now());
|
573 |
-
}
|
574 |
-
|
575 |
-
private function index_content ($post_id, &$kws, &$content) {
|
576 |
-
$kw_ids = array();
|
577 |
-
foreach($kws as $kw) {
|
578 |
-
if(preg_match('/\b'.preg_quote($kw->text).'\b/i', $content)) {
|
579 |
-
$kw_ids[] = $kw->id;
|
580 |
-
}
|
581 |
-
}
|
582 |
-
|
583 |
-
// Add all keywords in one swath
|
584 |
-
return $this->add_post_keywords($post_id, $kw_ids);
|
585 |
-
}
|
586 |
-
|
587 |
-
public function get_post_keywords_by_post_id ($post_id) {
|
588 |
-
global $wpdb;
|
589 |
-
|
590 |
-
$q = "
|
591 |
-
SELECT pkw.keyword_id
|
592 |
-
FROM {$this->post_keywords_table_name} AS pkw
|
593 |
-
WHERE pkw.post_id=%d
|
594 |
-
";
|
595 |
-
$q = $wpdb->prepare($q, $post_id);
|
596 |
-
|
597 |
-
return $wpdb->get_col($q);
|
598 |
-
}
|
599 |
-
|
600 |
-
public function add_post_keywords ($post_id, $keyword_ids) {
|
601 |
-
global $wpdb;
|
602 |
-
|
603 |
-
if(empty($keyword_ids)) { return false; }
|
604 |
-
|
605 |
-
// We got a unique index folks so we just ignore dups yo
|
606 |
-
// But we just want to grab one random keyword to insert here
|
607 |
-
$q = "
|
608 |
-
INSERT IGNORE INTO {$this->post_keywords_table_name}
|
609 |
-
(post_id, keyword_id)
|
610 |
-
VALUES
|
611 |
-
";
|
612 |
-
|
613 |
-
$vals = array();
|
614 |
-
foreach($keyword_ids as $keyword_id) {
|
615 |
-
// Not sure how this would ever be un-true but let's make sure it doesn't happen
|
616 |
-
if($keyword_id > 0 && $post_id > 0) {
|
617 |
-
$vals[] = $wpdb->prepare("(%d, %d)", $post_id, $keyword_id);
|
618 |
-
}
|
619 |
-
}
|
620 |
-
|
621 |
-
// No values to insert? Let's bail.
|
622 |
-
if(empty($vals)) { return false; }
|
623 |
-
|
624 |
-
$q .= implode(',',$vals);
|
625 |
-
|
626 |
-
return $wpdb->query($q);
|
627 |
-
}
|
628 |
-
|
629 |
-
// How many posts out of all are indexed
|
630 |
-
public function posts_indexed () {
|
631 |
-
global $wpdb, $prli_link, $plp_options;
|
632 |
-
|
633 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
634 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
635 |
-
|
636 |
-
$q = "
|
637 |
-
SELECT max(kw.created_at)
|
638 |
-
FROM {$this->table_name} AS kw
|
639 |
-
";
|
640 |
-
$max_updated_at = $wpdb->get_var($q);
|
641 |
-
|
642 |
-
// Num un-indexed posts
|
643 |
-
$q = $wpdb->prepare("
|
644 |
-
SELECT COUNT(*)
|
645 |
-
FROM {$wpdb->posts} AS p
|
646 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
647 |
-
ON p.ID=pm.post_id
|
648 |
-
AND pm.meta_key='_plp_post_keywords_updated_at'
|
649 |
-
WHERE p.post_status = 'publish'
|
650 |
-
AND p.post_type IN ({$valid_types})
|
651 |
-
AND (
|
652 |
-
pm.meta_value IS NULL
|
653 |
-
OR pm.meta_value < %s
|
654 |
-
)
|
655 |
-
ORDER BY pm.meta_value
|
656 |
-
",
|
657 |
-
$max_updated_at
|
658 |
-
);
|
659 |
-
$unindexed = $wpdb->get_var($q);
|
660 |
-
|
661 |
-
$q = "
|
662 |
-
SELECT COUNT(*)
|
663 |
-
FROM {$wpdb->posts} AS p
|
664 |
-
WHERE p.post_status = 'publish'
|
665 |
-
AND p.post_type IN ({$valid_types})
|
666 |
-
";
|
667 |
-
$total = $wpdb->get_var($q);
|
668 |
-
|
669 |
-
$indexed = ($total - $unindexed);
|
670 |
-
|
671 |
-
return (object)compact('total', 'indexed', 'unindexed');
|
672 |
-
}
|
673 |
-
|
674 |
-
// How many comments out of all are indexed
|
675 |
-
public function comments_indexed () {
|
676 |
-
global $wpdb, $prli_link, $plp_options;
|
677 |
-
|
678 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
679 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
680 |
-
|
681 |
-
$q = "
|
682 |
-
SELECT max(kw.created_at)
|
683 |
-
FROM {$this->table_name} AS kw
|
684 |
-
";
|
685 |
-
$max_updated_at = $wpdb->get_var($q);
|
686 |
-
|
687 |
-
// Num un-indexed posts
|
688 |
-
$q = $wpdb->prepare("
|
689 |
-
SELECT COUNT(*)
|
690 |
-
FROM {$wpdb->comments} AS c
|
691 |
-
INNER JOIN {$wpdb->posts} AS p
|
692 |
-
ON c.comment_post_ID=p.ID
|
693 |
-
AND p.post_status = 'publish'
|
694 |
-
AND p.post_type IN ({$valid_types})
|
695 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
696 |
-
ON c.comment_ID=cm.comment_id
|
697 |
-
AND cm.meta_key='_plp_comment_keywords_updated_at'
|
698 |
-
WHERE c.comment_approved=1
|
699 |
-
AND (
|
700 |
-
cm.meta_value IS NULL
|
701 |
-
OR cm.meta_value < %s
|
702 |
-
)
|
703 |
-
ORDER BY cm.meta_value
|
704 |
-
",
|
705 |
-
$max_updated_at
|
706 |
-
);
|
707 |
-
$unindexed = $wpdb->get_var($q);
|
708 |
-
|
709 |
-
$q = "
|
710 |
-
SELECT COUNT(*)
|
711 |
-
FROM {$wpdb->comments} AS c
|
712 |
-
INNER JOIN {$wpdb->posts} AS p
|
713 |
-
ON c.comment_post_ID=p.ID
|
714 |
-
AND p.post_status = 'publish'
|
715 |
-
AND p.post_type IN ({$valid_types})
|
716 |
-
WHERE c.comment_approved=1
|
717 |
-
";
|
718 |
-
$total = $wpdb->get_var($q);
|
719 |
-
|
720 |
-
$indexed = ($total - $unindexed);
|
721 |
-
|
722 |
-
return (object)compact('total', 'indexed', 'unindexed');
|
723 |
-
}
|
724 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpLinkRotation.php
DELETED
@@ -1,186 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH'))
|
3 |
-
die('You are not allowed to call this page directly.');
|
4 |
-
|
5 |
-
class PlpLinkRotation {
|
6 |
-
public $table_name;
|
7 |
-
public $cr_table_name;
|
8 |
-
|
9 |
-
public function __construct() {
|
10 |
-
global $wpdb;
|
11 |
-
$this->table_name = "{$wpdb->prefix}prli_link_rotations";
|
12 |
-
$this->cr_table_name = "{$wpdb->prefix}prli_clicks_rotations";
|
13 |
-
}
|
14 |
-
|
15 |
-
public function create( $url, $weight, $r_index, $link_id ) {
|
16 |
-
global $wpdb;
|
17 |
-
|
18 |
-
$query_str = "INSERT INTO {$this->table_name} " .
|
19 |
-
'(url,' .
|
20 |
-
'weight,' .
|
21 |
-
'r_index,' .
|
22 |
-
'link_id,' .
|
23 |
-
'created_at) ' .
|
24 |
-
'VALUES ' .
|
25 |
-
'(%s,%d,%d,%d,NOW())';
|
26 |
-
|
27 |
-
$query = $wpdb->prepare( $query_str,
|
28 |
-
$url,
|
29 |
-
$weight,
|
30 |
-
$r_index,
|
31 |
-
$link_id );
|
32 |
-
|
33 |
-
$query_results = $wpdb->query($query);
|
34 |
-
|
35 |
-
if($query_results)
|
36 |
-
return $wpdb->insert_id;
|
37 |
-
else
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
|
41 |
-
public function update( $url, $weight, $r_index, $link_id ) {
|
42 |
-
global $wpdb;
|
43 |
-
|
44 |
-
$query_str = "UPDATE {$this->table_name} SET " .
|
45 |
-
'url=%s, ' .
|
46 |
-
'weight=%d ' .
|
47 |
-
'WHERE ' .
|
48 |
-
'link_id=%d AND ' .
|
49 |
-
'r_index=%d';
|
50 |
-
|
51 |
-
$query = $wpdb->prepare( $query_str,
|
52 |
-
$url,
|
53 |
-
$weight,
|
54 |
-
$link_id,
|
55 |
-
$r_index );
|
56 |
-
|
57 |
-
$query_results = $wpdb->query($query);
|
58 |
-
|
59 |
-
return $query_results;
|
60 |
-
}
|
61 |
-
|
62 |
-
public function record_click( $click_id, $link_id, $url ) {
|
63 |
-
global $wpdb;
|
64 |
-
|
65 |
-
$query_str = "INSERT INTO {$this->cr_table_name} " .
|
66 |
-
'(click_id,' .
|
67 |
-
'link_id,' .
|
68 |
-
'url) ' .
|
69 |
-
'VALUES ' .
|
70 |
-
'(%d,%d,%s)';
|
71 |
-
|
72 |
-
$query = $wpdb->prepare( $query_str,
|
73 |
-
$click_id,
|
74 |
-
$link_id,
|
75 |
-
$url );
|
76 |
-
|
77 |
-
$query_results = $wpdb->query($query);
|
78 |
-
|
79 |
-
if($query_results)
|
80 |
-
return $wpdb->insert_id;
|
81 |
-
else
|
82 |
-
return false;
|
83 |
-
}
|
84 |
-
|
85 |
-
public function updateLinkRotations($link_id,$link_rotations,$link_weights) {
|
86 |
-
$existing_rotations = $this->getAllByLinkId( $link_id );
|
87 |
-
|
88 |
-
$max_count = ((count($existing_rotations) > count($link_rotations))?count($existing_rotations):count($link_rotations));
|
89 |
-
for($i=0;$i<$max_count;$i++)
|
90 |
-
{
|
91 |
-
if(isset($existing_rotations[$i]) and isset($link_rotations[$i]))
|
92 |
-
{
|
93 |
-
if(empty($link_rotations[$i]) or preg_match("#^\s*$#",$link_rotations[$i]))
|
94 |
-
$this->destroy($link_id,$i);
|
95 |
-
else
|
96 |
-
$this->update(trim($link_rotations[$i]), trim($link_weights[$i]), $i, $link_id);
|
97 |
-
}
|
98 |
-
else if(isset($link_rotations[$i]) and !preg_match("#^\s*$#",$link_rotations[$i]))
|
99 |
-
$this->create(trim($link_rotations[$i]), trim($link_weights[$i]), $i, $link_id);
|
100 |
-
else if(isset($existing_rotations[$i]))
|
101 |
-
$this->destroy($link_id,$i);
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
-
public function destroy( $link_id, $r_index ) {
|
106 |
-
global $wpdb;
|
107 |
-
$query_str = "DELETE FROM {$this->table_name} WHERE link_id=%d AND r_index=%d";
|
108 |
-
$query = $wpdb->prepare($query_str,$link_id,$r_index);
|
109 |
-
return $wpdb->query($query);
|
110 |
-
}
|
111 |
-
|
112 |
-
public function destroyByLinkId( $link_id ) {
|
113 |
-
global $wpdb;
|
114 |
-
$query_str = "DELETE FROM {$this->table_name} WHERE link_id=%d";
|
115 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
116 |
-
return $wpdb->query($query);
|
117 |
-
}
|
118 |
-
|
119 |
-
public function getOne( $id, $return_type = OBJECT ) {
|
120 |
-
global $wpdb;
|
121 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE id=%d";
|
122 |
-
$query = $wpdb->prepare($query_str,$id);
|
123 |
-
return $wpdb->get_row($query, $return_type);
|
124 |
-
}
|
125 |
-
|
126 |
-
public function getAllByLinkId( $link_id, $return_type = OBJECT ) {
|
127 |
-
global $wpdb;
|
128 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE link_id=%d ORDER BY r_index";
|
129 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
130 |
-
return $wpdb->get_results($query, $return_type);
|
131 |
-
}
|
132 |
-
|
133 |
-
public function getAll($where = '', $return_type = OBJECT) {
|
134 |
-
global $wpdb, $prli_utils;
|
135 |
-
$query_str = "SELECT * FROM {$this->table_name}" . $prli_utils->prepend_and_or_where(' WHERE', $where) . " ORDER BY link_id,r_index";
|
136 |
-
return $wpdb->get_results($query_str, $return_type);
|
137 |
-
}
|
138 |
-
|
139 |
-
public function get_rotations($link_id) {
|
140 |
-
global $wpdb;
|
141 |
-
$query_str = "SELECT url FROM {$this->table_name} WHERE link_id=%d ORDER BY r_index";
|
142 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
143 |
-
return $wpdb->get_col($query, 0);
|
144 |
-
}
|
145 |
-
|
146 |
-
public function get_weights($link_id) {
|
147 |
-
global $wpdb;
|
148 |
-
$query_str = "SELECT weight FROM {$this->table_name} WHERE link_id=%d ORDER BY r_index";
|
149 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
150 |
-
return $wpdb->get_col($query, 0);
|
151 |
-
}
|
152 |
-
|
153 |
-
public function get_target_url($link_id) {
|
154 |
-
global $prli_link, $prli_link_meta;
|
155 |
-
|
156 |
-
$link = $prli_link->getOne($link_id);
|
157 |
-
|
158 |
-
$rotation_urls = $this->get_rotations($link_id);
|
159 |
-
$rotation_urls[] = $link->url;
|
160 |
-
|
161 |
-
$weights = $this->get_weights($link_id);
|
162 |
-
$weights[] = $prli_link_meta->get_link_meta($link_id,'prli-target-url-weight',true);
|
163 |
-
|
164 |
-
$index = PlpUtils::w_rand($weights);
|
165 |
-
|
166 |
-
// Just double check that we aren't returning an empty URL ...
|
167 |
-
// At the very least we can return the target url.
|
168 |
-
$target_url = (empty($rotation_urls[$index])?$link->url:$rotation_urls[$index]);
|
169 |
-
|
170 |
-
return $target_url;
|
171 |
-
}
|
172 |
-
|
173 |
-
public function there_are_rotations_for_this_link($link_id) {
|
174 |
-
global $wpdb;
|
175 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE link_id=%d";
|
176 |
-
$query = $wpdb->prepare($query_str,$link_id);
|
177 |
-
$url_rotations = $wpdb->get_results($query);
|
178 |
-
|
179 |
-
foreach($url_rotations as $rot) {
|
180 |
-
if(!preg_match('#^/s*?#',$rot->url))
|
181 |
-
return true; // short circuit when we find the first rotation
|
182 |
-
}
|
183 |
-
|
184 |
-
return false;
|
185 |
-
}
|
186 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpOptions.php
DELETED
@@ -1,407 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) die('You are not allowed to call this page directly.');
|
3 |
-
|
4 |
-
class PlpOptions {
|
5 |
-
public $pages_auto;
|
6 |
-
public $posts_auto;
|
7 |
-
public $pages_category;
|
8 |
-
public $posts_category;
|
9 |
-
public $autocreate;
|
10 |
-
|
11 |
-
public $default_social_buttons;
|
12 |
-
public $social_buttons;
|
13 |
-
public $social_buttons_placement;
|
14 |
-
public $social_buttons_show_in_feed;
|
15 |
-
public $social_buttons_padding;
|
16 |
-
public $social_posts_buttons;
|
17 |
-
public $social_pages_buttons;
|
18 |
-
|
19 |
-
public $keyword_replacement_is_on;
|
20 |
-
public $keywords_per_page;
|
21 |
-
public $keyword_links_per_page;
|
22 |
-
public $keyword_links_open_new_window;
|
23 |
-
public $keyword_links_nofollow;
|
24 |
-
public $keyword_links_sponsored;
|
25 |
-
public $keyword_link_custom_css;
|
26 |
-
public $keyword_link_hover_custom_css;
|
27 |
-
public $set_keyword_thresholds;
|
28 |
-
public $keyword_enable_content_cache; // DEPRECATED
|
29 |
-
public $replace_urls_with_pretty_links;
|
30 |
-
public $replace_urls_with_pretty_links_blacklist;
|
31 |
-
public $replace_keywords_in_comments;
|
32 |
-
public $replace_keywords_in_feeds;
|
33 |
-
public $enable_link_to_disclosures;
|
34 |
-
public $disclosures_link_url;
|
35 |
-
public $disclosures_link_text;
|
36 |
-
public $disclosures_link_position;
|
37 |
-
public $enable_keyword_link_disclosures;
|
38 |
-
public $keyword_link_disclosure;
|
39 |
-
|
40 |
-
public $use_prettylink_url;
|
41 |
-
public $prettylink_url;
|
42 |
-
|
43 |
-
public $min_role;
|
44 |
-
|
45 |
-
public $allow_public_link_creation;
|
46 |
-
public $use_public_link_display_page;
|
47 |
-
public $public_link_display_page;
|
48 |
-
|
49 |
-
public $prettybar_hide_attrib_link;
|
50 |
-
public $prettybar_attrib_url;
|
51 |
-
|
52 |
-
public $google_tracking;
|
53 |
-
public $google_tracking_str;
|
54 |
-
|
55 |
-
public $generate_qr_codes_str;
|
56 |
-
public $generate_qr_codes;
|
57 |
-
|
58 |
-
public $qr_code_links_str;
|
59 |
-
public $qr_code_links;
|
60 |
-
|
61 |
-
public $global_head_scripts_str;
|
62 |
-
public $global_head_scripts;
|
63 |
-
|
64 |
-
//Use a base slug prefix on all new links like out/ or go/ etc.
|
65 |
-
public $base_slug_prefix_str;
|
66 |
-
public $base_slug_prefix;
|
67 |
-
|
68 |
-
//The number of characters to use in random slug generation.
|
69 |
-
public $num_slug_chars_str;
|
70 |
-
public $num_slug_chars;
|
71 |
-
|
72 |
-
public function __construct($options_array=array()) {
|
73 |
-
// Set values from array
|
74 |
-
foreach($options_array as $key => $value) {
|
75 |
-
$this->{$key} = $value;
|
76 |
-
}
|
77 |
-
|
78 |
-
$this->set_default_options();
|
79 |
-
}
|
80 |
-
|
81 |
-
public function set_default_options() {
|
82 |
-
if(!isset($this->pages_auto))
|
83 |
-
$this->pages_auto = 0;
|
84 |
-
|
85 |
-
if(!isset($this->posts_auto))
|
86 |
-
$this->posts_auto = 0;
|
87 |
-
|
88 |
-
if(!isset($this->pages_category))
|
89 |
-
$this->pages_category= '';
|
90 |
-
|
91 |
-
if(!isset($this->posts_category))
|
92 |
-
$this->posts_category = '';
|
93 |
-
|
94 |
-
if(!isset($this->autocreate)) {
|
95 |
-
$this->autocreate = array();
|
96 |
-
}
|
97 |
-
|
98 |
-
$this->default_social_buttons = array(
|
99 |
-
'facebook' => array(
|
100 |
-
'label' => __('Facebook', 'pretty-link'),
|
101 |
-
'checked' => false,
|
102 |
-
'slug' => 'facebook',
|
103 |
-
'icon' => 'pl-icon-facebook',
|
104 |
-
'url' => 'http://www.facebook.com/sharer.php?u={{encoded_url}}&t={{encoded_title}}'
|
105 |
-
),
|
106 |
-
'twitter' => array(
|
107 |
-
'label' => __('Twitter', 'pretty-link'),
|
108 |
-
'checked' => false,
|
109 |
-
'slug' => 'twitter',
|
110 |
-
'icon' => 'pl-icon-twitter',
|
111 |
-
'url' => 'https://twitter.com/intent/tweet?text={{tweet_message}}'
|
112 |
-
),
|
113 |
-
'gplus' => array(
|
114 |
-
'label' => __('Google+', 'pretty-link'),
|
115 |
-
'checked' => false,
|
116 |
-
'slug' => 'gplus',
|
117 |
-
'icon' => 'pl-icon-gplus',
|
118 |
-
'url' => 'https://plus.google.com/share?url={{encoded_url}}'
|
119 |
-
),
|
120 |
-
'pinterest' => array(
|
121 |
-
'label' => __('Pinterest', 'pretty-link'),
|
122 |
-
'checked' => false,
|
123 |
-
'slug' => 'pinterest',
|
124 |
-
'icon' => 'pl-icon-pinterest',
|
125 |
-
'url' => 'http://pinterest.com/pin/create/button/?url={{encoded_url}}&description={{encoded_title}}"'
|
126 |
-
),
|
127 |
-
'linkedin' => array(
|
128 |
-
'label' => __('LinkedIn', 'pretty-link'),
|
129 |
-
'checked' => false,
|
130 |
-
'slug' => 'linkedin',
|
131 |
-
'icon' => 'pl-icon-linkedin',
|
132 |
-
'url' => 'http://www.linkedin.com/shareArticle?mini=true&url={{encoded_url}}&title={{encoded_title}}'
|
133 |
-
),
|
134 |
-
'reddit' => array(
|
135 |
-
'label' => __('Reddit', 'pretty-link'),
|
136 |
-
'checked' => false,
|
137 |
-
'slug' => 'reddit',
|
138 |
-
'icon' => 'pl-icon-reddit',
|
139 |
-
'url' => 'http://reddit.com/submit?url={{encoded_url}}&title={{encoded_title}}'
|
140 |
-
),
|
141 |
-
'stumbleupon' => array(
|
142 |
-
'label' => __('StumbleUpon', 'pretty-link'),
|
143 |
-
'checked' => false,
|
144 |
-
'slug' => 'stumbleupon',
|
145 |
-
'icon' => 'pl-icon-stumbleupon',
|
146 |
-
'url' => 'http://www.stumbleupon.com/submit?url={{encoded_url}}&title={{encoded_title}}'
|
147 |
-
),
|
148 |
-
'digg' => array(
|
149 |
-
'label' => __('Digg', 'pretty-link'),
|
150 |
-
'checked' => false,
|
151 |
-
'slug' => 'digg',
|
152 |
-
'icon' => 'pl-icon-digg',
|
153 |
-
'url' => 'http://digg.com/submit?phase=2&url={{encoded_url}}&title={{encoded_title}}'
|
154 |
-
),
|
155 |
-
'email' => array(
|
156 |
-
'label' => __('Email', 'pretty-link'),
|
157 |
-
'checked' => false,
|
158 |
-
'slug' => 'email',
|
159 |
-
'icon' => 'pl-icon-email',
|
160 |
-
'url' => 'mailto:?subject={{encoded_title}}&body={{encoded_title}}%20{{encoded_url}}'
|
161 |
-
)
|
162 |
-
);
|
163 |
-
|
164 |
-
if(!isset($this->social_buttons)) {
|
165 |
-
$this->social_buttons = array_values( $this->default_social_buttons );
|
166 |
-
}
|
167 |
-
else {
|
168 |
-
// If it's the old-style array then refactor it
|
169 |
-
if( isset($this->social_buttons['facebook']) ) {
|
170 |
-
$new_social_buttons = array_values( $this->default_social_buttons );
|
171 |
-
|
172 |
-
foreach( $new_social_buttons as $i => $values ) {
|
173 |
-
if( isset( $this->social_buttons[$values['slug']] ) ) {
|
174 |
-
$new_social_buttons[$i]['checked'] = ($values==='on');
|
175 |
-
}
|
176 |
-
}
|
177 |
-
|
178 |
-
$this->social_buttons = $new_social_buttons;
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
if(!isset($this->social_buttons_placement))
|
183 |
-
$this->social_buttons_placement = 'bottom';
|
184 |
-
|
185 |
-
if(!isset($this->social_buttons_show_in_feed))
|
186 |
-
$this->social_buttons_show_in_feed = 0;
|
187 |
-
|
188 |
-
if(!isset($this->social_buttons_padding))
|
189 |
-
$this->social_buttons_padding = '10';
|
190 |
-
|
191 |
-
if(!isset($this->social_posts_buttons))
|
192 |
-
$this->social_posts_buttons = 0;
|
193 |
-
|
194 |
-
if(!isset($this->social_pages_buttons))
|
195 |
-
$this->social_pages_buttons = 0;
|
196 |
-
|
197 |
-
if(!isset($this->keyword_replacement_is_on))
|
198 |
-
$this->keyword_replacement_is_on = 1;
|
199 |
-
|
200 |
-
if(!isset($this->keywords_per_page))
|
201 |
-
$this->keywords_per_page = 3;
|
202 |
-
|
203 |
-
if(!isset($this->keyword_links_per_page))
|
204 |
-
$this->keyword_links_per_page = 2;
|
205 |
-
|
206 |
-
if(!isset($this->keyword_links_open_new_window))
|
207 |
-
$this->keyword_links_open_new_window = 0;
|
208 |
-
|
209 |
-
if(!isset($this->keyword_links_nofollow))
|
210 |
-
$this->keyword_links_nofollow = 0;
|
211 |
-
|
212 |
-
if(!isset($this->keyword_links_sponsored))
|
213 |
-
$this->keyword_links_sponsored = 0;
|
214 |
-
|
215 |
-
if(!isset($this->keyword_link_custom_css))
|
216 |
-
$this->keyword_link_custom_css = '';
|
217 |
-
|
218 |
-
if(!isset($this->keyword_link_hover_custom_css))
|
219 |
-
$this->keyword_link_hover_custom_css = '';
|
220 |
-
|
221 |
-
if(!isset($this->set_keyword_thresholds))
|
222 |
-
$this->set_keyword_thresholds = 0;
|
223 |
-
|
224 |
-
// DEPRECATED
|
225 |
-
$this->keyword_enable_content_cache = 0;
|
226 |
-
|
227 |
-
if(!isset($this->replace_urls_with_pretty_links))
|
228 |
-
$this->replace_urls_with_pretty_links = 0;
|
229 |
-
if(!isset($this->replace_urls_with_pretty_links_blacklist))
|
230 |
-
$this->replace_urls_with_pretty_links_blacklist = '';
|
231 |
-
if(!isset($this->replace_keywords_in_comments))
|
232 |
-
$this->replace_keywords_in_comments = 0;
|
233 |
-
if(!isset($this->replace_keywords_in_feeds))
|
234 |
-
$this->replace_keywords_in_feeds = 0;
|
235 |
-
if(!isset($this->enable_link_to_disclosures)) {
|
236 |
-
$this->enable_link_to_disclosures = 0;
|
237 |
-
}
|
238 |
-
if(!isset($this->disclosures_link_url)) {
|
239 |
-
$this->disclosures_link_url = '';
|
240 |
-
}
|
241 |
-
if(!isset($this->disclosures_link_text)) {
|
242 |
-
$this->disclosures_link_text = __('Affiliate Link Disclosures','pretty-link');
|
243 |
-
}
|
244 |
-
if(!isset($this->disclosures_link_position)) {
|
245 |
-
$this->disclosures_link_position = 'bottom';
|
246 |
-
}
|
247 |
-
if(!isset($this->enable_keyword_link_disclosures)) {
|
248 |
-
$this->enable_keyword_link_disclosures = 0;
|
249 |
-
}
|
250 |
-
if(!isset($this->keyword_link_disclosure)) {
|
251 |
-
$this->keyword_link_disclosure = __('(aff)', 'pretty-link');
|
252 |
-
}
|
253 |
-
|
254 |
-
if(!isset($this->use_prettylink_url))
|
255 |
-
$this->use_prettylink_url = 0;
|
256 |
-
|
257 |
-
if(!isset($this->prettylink_url))
|
258 |
-
$this->prettylink_url = '';
|
259 |
-
|
260 |
-
//manage_options = ADMIN
|
261 |
-
//delete_pages = EDITOR
|
262 |
-
//publish_posts = AUTHOR
|
263 |
-
//edit_posts = CONTRIBUTOR
|
264 |
-
//read = SUBSCRIBER
|
265 |
-
if(!isset($this->min_role) || $this->min_role == 'add_users') {
|
266 |
-
$this->min_role = 'manage_options';
|
267 |
-
}
|
268 |
-
|
269 |
-
if(!isset($this->allow_public_link_creation))
|
270 |
-
$this->allow_public_link_creation = 0;
|
271 |
-
|
272 |
-
if(!isset($this->use_public_link_display_page))
|
273 |
-
$this->use_public_link_display_page = 0;
|
274 |
-
|
275 |
-
if(!isset($this->public_link_display_page))
|
276 |
-
$this->public_link_display_page = '';
|
277 |
-
|
278 |
-
if(!isset($this->prettybar_hide_attrib_link))
|
279 |
-
$this->prettybar_hide_attrib_link = 0;
|
280 |
-
|
281 |
-
if(!isset($this->prettybar_attrib_url))
|
282 |
-
$this->prettybar_attrib_url = '';
|
283 |
-
|
284 |
-
$this->google_tracking_str = 'prlipro-google-tracking';
|
285 |
-
if(!isset($this->google_tracking))
|
286 |
-
$this->google_tracking = 0;
|
287 |
-
|
288 |
-
$this->generate_qr_codes_str = 'prlipro-generate-qr-codes';
|
289 |
-
if(!isset($this->generate_qr_codes))
|
290 |
-
$this->generate_qr_codes = 0;
|
291 |
-
|
292 |
-
$this->qr_code_links_str = 'prlipro-code-links';
|
293 |
-
$this->qr_code_links = 0;
|
294 |
-
/* TODO: We're going to just comment this out for now
|
295 |
-
if(!isset($this->qr_code_links))
|
296 |
-
$this->qr_code_links = 0;
|
297 |
-
*/
|
298 |
-
|
299 |
-
$this->global_head_scripts_str = 'prlipro-global-head-scripts';
|
300 |
-
if(!isset($this->global_head_scripts) || empty($this->global_head_scripts))
|
301 |
-
$this->global_head_scripts = '';
|
302 |
-
|
303 |
-
$this->base_slug_prefix_str = 'prlipro-base-slug-prefix';
|
304 |
-
if(!isset($this->base_slug_prefix))
|
305 |
-
$this->base_slug_prefix = '';
|
306 |
-
|
307 |
-
$this->num_slug_chars_str = 'prlipro-num-slug-chars';
|
308 |
-
if(!isset($this->num_slug_chars))
|
309 |
-
$this->num_slug_chars = 4;
|
310 |
-
}
|
311 |
-
|
312 |
-
public function store() {
|
313 |
-
$storage_array = (array)$this;
|
314 |
-
update_option( 'prlipro_options', $storage_array );
|
315 |
-
wp_cache_delete('alloptions', 'options');
|
316 |
-
}
|
317 |
-
|
318 |
-
public function autocreate_option($post_type='post') {
|
319 |
-
$opt = array(
|
320 |
-
'enabled' => false,
|
321 |
-
'category' => '',
|
322 |
-
'socbtns' => false
|
323 |
-
);
|
324 |
-
|
325 |
-
if($post_type=='post') {
|
326 |
-
$opt['enabled'] = !empty($this->posts_auto);
|
327 |
-
$opt['category'] = $this->posts_category;
|
328 |
-
$opt['socbtns'] = !empty($this->social_posts_buttons);
|
329 |
-
}
|
330 |
-
else if($post_type=='page') {
|
331 |
-
$opt['enabled'] = !empty($this->pages_auto);
|
332 |
-
$opt['category'] = $this->pages_category;
|
333 |
-
$opt['socbtns'] = !empty($this->social_pages_buttons);
|
334 |
-
}
|
335 |
-
else {
|
336 |
-
if(isset($this->autocreate[$post_type])) {
|
337 |
-
$ac = $this->autocreate[$post_type];
|
338 |
-
$opt['enabled'] = isset($ac['enabled']) && !empty($ac['enabled']);
|
339 |
-
$opt['category'] = isset($ac['category']) ? $ac['category'] : '';
|
340 |
-
$opt['socbtns'] = isset($ac['socbtns']) && !empty($ac['socbtns']);
|
341 |
-
}
|
342 |
-
}
|
343 |
-
|
344 |
-
return (object)$opt;
|
345 |
-
}
|
346 |
-
|
347 |
-
public function autocreate_options() {
|
348 |
-
$opts = array();
|
349 |
-
$post_types = $this->get_post_types();
|
350 |
-
|
351 |
-
foreach($post_types as $post_type) {
|
352 |
-
$opts[$post_type] = $this->autocreate_option($post_type);
|
353 |
-
}
|
354 |
-
|
355 |
-
return (object)$opts;
|
356 |
-
}
|
357 |
-
|
358 |
-
public function autocreate_valid_types() {
|
359 |
-
$valid_opts = array();
|
360 |
-
$opts = $this->autocreate_options();
|
361 |
-
|
362 |
-
foreach($opts as $post_type => $opt) {
|
363 |
-
if($opt->enabled) {
|
364 |
-
$valid_opts[] = $post_type;
|
365 |
-
}
|
366 |
-
}
|
367 |
-
|
368 |
-
return $valid_opts;
|
369 |
-
}
|
370 |
-
|
371 |
-
public function get_post_types($include_page_and_post=true) {
|
372 |
-
$post_types = get_post_types(array('_builtin'=>false,'public'=>true),'names','and');
|
373 |
-
|
374 |
-
if($include_page_and_post) {
|
375 |
-
$post_types['post'] = 'post';
|
376 |
-
$post_types['page'] = 'page';
|
377 |
-
}
|
378 |
-
|
379 |
-
return $post_types;
|
380 |
-
}
|
381 |
-
|
382 |
-
public static function get_options() {
|
383 |
-
$plp_options = get_option('prlipro_options');
|
384 |
-
|
385 |
-
if($plp_options) {
|
386 |
-
if(is_string($plp_options)) {
|
387 |
-
$plp_options = unserialize($plp_options);
|
388 |
-
}
|
389 |
-
|
390 |
-
if(is_object($plp_options) && is_a($plp_options,'PlpOptions')) {
|
391 |
-
$plp_options->set_default_options();
|
392 |
-
$plp_options->store(); // store will convert this back into an array
|
393 |
-
}
|
394 |
-
else if(is_array($plp_options)) {
|
395 |
-
$plp_options = new PlpOptions($plp_options);
|
396 |
-
}
|
397 |
-
else {
|
398 |
-
$plp_options = new PlpOptions();
|
399 |
-
}
|
400 |
-
}
|
401 |
-
else {
|
402 |
-
$plp_options = new PlpOptions();
|
403 |
-
}
|
404 |
-
|
405 |
-
return $plp_options;
|
406 |
-
}
|
407 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpPostOptions.php
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?php if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
2 |
-
|
3 |
-
class PlpPostOptions {
|
4 |
-
public $requested_slug;
|
5 |
-
|
6 |
-
public $hide_social_buttons;
|
7 |
-
public $disable_replacements;
|
8 |
-
|
9 |
-
public function __construct($options_array = array()) {
|
10 |
-
// Set values from array
|
11 |
-
foreach($options_array as $key => $value)
|
12 |
-
$this->{$key} = $value;
|
13 |
-
|
14 |
-
$this->set_default_options();
|
15 |
-
}
|
16 |
-
|
17 |
-
public function set_default_options() {
|
18 |
-
if(!isset($this->requested_slug))
|
19 |
-
$this->requested_slug = '';
|
20 |
-
|
21 |
-
if(!isset($this->hide_social_buttons))
|
22 |
-
$this->hide_social_buttons = 0;
|
23 |
-
|
24 |
-
if(!isset($this->disable_replacements))
|
25 |
-
$this->disable_replacements = 0;
|
26 |
-
}
|
27 |
-
|
28 |
-
public function validate() {
|
29 |
-
global $prli_utils;
|
30 |
-
$errors = array();
|
31 |
-
|
32 |
-
if(!empty($this->requested_slug)) {
|
33 |
-
$slug_available = $prli_utils->is_slug_available($this->requested_slug);
|
34 |
-
if(is_wp_error($slug_available)) {
|
35 |
-
$errors[] = $slug_available->get_error_message();
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
return $errors;
|
40 |
-
}
|
41 |
-
|
42 |
-
// Just here as an alias for reverse compatibility
|
43 |
-
public function get_stored_object($post_id) {
|
44 |
-
return PlpOptions::get_options($post_id);
|
45 |
-
}
|
46 |
-
|
47 |
-
public function store($post_id) {
|
48 |
-
if(!empty($post_id) and $post_id) {
|
49 |
-
$storage_array = (array)$this;
|
50 |
-
PrliUtils::update_prli_post_meta($post_id, '_prlipro-post-options', $storage_array);
|
51 |
-
}
|
52 |
-
}
|
53 |
-
|
54 |
-
public static function get_options($post_id) {
|
55 |
-
if(!empty($post_id) and $post_id) {
|
56 |
-
$plp_post_options = PrliUtils::get_prli_post_meta($post_id,"_prlipro-post-options",true);
|
57 |
-
|
58 |
-
if($plp_post_options) {
|
59 |
-
if(is_string($plp_post_options))
|
60 |
-
$plp_post_options = unserialize($plp_post_options);
|
61 |
-
|
62 |
-
if(is_a($plp_post_options,'PlpPostOptions')) {
|
63 |
-
$plp_post_options->set_default_options();
|
64 |
-
$plp_post_options->store($post_id); // store will convert this back into an array
|
65 |
-
}
|
66 |
-
else if(is_array($plp_post_options))
|
67 |
-
$plp_post_options = new PlpPostOptions($plp_post_options);
|
68 |
-
else
|
69 |
-
$plp_post_options = new PlpPostOptions();
|
70 |
-
}
|
71 |
-
else
|
72 |
-
$plp_post_options = new PlpPostOptions();
|
73 |
-
}
|
74 |
-
else
|
75 |
-
$plp_post_options = new PlpPostOptions();
|
76 |
-
|
77 |
-
return $plp_post_options;
|
78 |
-
}
|
79 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpReport.php
DELETED
@@ -1,497 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpReport
|
5 |
-
{
|
6 |
-
public $table_name;
|
7 |
-
public $links_table_name;
|
8 |
-
|
9 |
-
public function __construct() {
|
10 |
-
global $wpdb;
|
11 |
-
$this->table_name = "{$wpdb->prefix}prli_reports";
|
12 |
-
$this->links_table_name = "{$wpdb->prefix}prli_report_links";
|
13 |
-
}
|
14 |
-
|
15 |
-
public function create( $values ) {
|
16 |
-
global $wpdb;
|
17 |
-
|
18 |
-
$goal_link_id = isset($values['goal_link_id']) ? $values['goal_link_id'] : 0;
|
19 |
-
$query_str = "INSERT INTO {$this->table_name} ".
|
20 |
-
'(name,goal_link_id,created_at) ' .
|
21 |
-
'VALUES (%s,%d,NOW())';
|
22 |
-
$query = $wpdb->prepare( $query_str, $values['name'], $goal_link_id );
|
23 |
-
$query_results = $wpdb->query($query);
|
24 |
-
return $wpdb->insert_id;
|
25 |
-
}
|
26 |
-
|
27 |
-
public function update( $id, $values ) {
|
28 |
-
global $wpdb;
|
29 |
-
|
30 |
-
$goal_link_id = isset($values['goal_link_id']) ? $values['goal_link_id'] : 0;
|
31 |
-
$query_str = "UPDATE {$this->table_name} " .
|
32 |
-
'SET name=%s, goal_link_id=%d ' .
|
33 |
-
'WHERE id=%d';
|
34 |
-
$query = $wpdb->prepare($query_str,$values['name'],$goal_link_id,$id);
|
35 |
-
$query_results = $wpdb->query($query);
|
36 |
-
return $query_results;
|
37 |
-
}
|
38 |
-
|
39 |
-
public function get_report_links($report_id, $return_type = OBJECT) {
|
40 |
-
global $wpdb;
|
41 |
-
$query_str = "SELECT * FROM {$this->links_table_name} WHERE report_id=%d";
|
42 |
-
$query = $wpdb->prepare($query_str, $report_id);
|
43 |
-
return $wpdb->get_results($query, $return_type);
|
44 |
-
}
|
45 |
-
|
46 |
-
public function get_report_links_array($report_id) {
|
47 |
-
global $wpdb;
|
48 |
-
$links_table = $wpdb->prefix . 'prli_links';
|
49 |
-
$query_str = "SELECT link_id FROM {$this->links_table_name} LEFT JOIN {$links_table} links ON link_id = links.id WHERE report_id=%d AND link_status='enabled'";
|
50 |
-
$query = $wpdb->prepare($query_str, $report_id);
|
51 |
-
return $wpdb->get_col($query,0);
|
52 |
-
}
|
53 |
-
|
54 |
-
public function update_report_links($report_id, $link_ids) {
|
55 |
-
global $wpdb;
|
56 |
-
|
57 |
-
// Delete all records associated with this report
|
58 |
-
$query_str = "DELETE FROM {$this->links_table_name} WHERE report_id=%d";
|
59 |
-
$query = $wpdb->prepare($query_str, $report_id);
|
60 |
-
$wpdb->query($query);
|
61 |
-
|
62 |
-
// Rebuild link IDs from the array of link_ids
|
63 |
-
foreach($link_ids as $link_id) {
|
64 |
-
$query_str = "INSERT INTO {$this->links_table_name} ".
|
65 |
-
'(report_id,'.
|
66 |
-
'link_id,'.
|
67 |
-
'created_at) ' .
|
68 |
-
'VALUES (%d,%d,NOW())';
|
69 |
-
$query = $wpdb->prepare( $query_str, $report_id, $link_id );
|
70 |
-
$query_results = $wpdb->query($query);
|
71 |
-
}
|
72 |
-
}
|
73 |
-
|
74 |
-
public function destroy( $id ) {
|
75 |
-
global $wpdb;
|
76 |
-
$query_str = "DELETE FROM {$this->table_name} WHERE id=%d";
|
77 |
-
$query = $wpdb->prepare($query_str, $id);
|
78 |
-
return $wpdb->query($query);
|
79 |
-
}
|
80 |
-
|
81 |
-
public function getOne( $id ) {
|
82 |
-
global $wpdb;
|
83 |
-
$query_str = "SELECT * FROM {$this->table_name} WHERE id=%d";
|
84 |
-
$query = $wpdb->prepare($query_str, $id);
|
85 |
-
return $wpdb->get_row($query);
|
86 |
-
}
|
87 |
-
|
88 |
-
public function getAll( $where = '', $order_by = '', $return_type = OBJECT ) {
|
89 |
-
global $wpdb, $prli_utils;
|
90 |
-
$query = "SELECT rp.*, " .
|
91 |
-
"li.name as goal_link_name, " .
|
92 |
-
"(SELECT COUNT(*) " .
|
93 |
-
"FROM {$this->links_table_name} rpl " .
|
94 |
-
"WHERE rpl.report_id = rp.id) as link_count " .
|
95 |
-
"FROM {$this->table_name} rp " .
|
96 |
-
"LEFT OUTER JOIN {$prli_link->table_name} li ON li.id = rp.goal_link_id AND li.link_status='enabled'" .
|
97 |
-
$prli_utils->prepend_and_or_where(' WHERE', $where) . $order_by;
|
98 |
-
return $wpdb->get_results($query, $return_type);
|
99 |
-
}
|
100 |
-
|
101 |
-
// Pagination Methods
|
102 |
-
public function getRecordCount($where='') {
|
103 |
-
global $wpdb, $prli_utils;
|
104 |
-
$query = "SELECT COUNT(*) FROM {$this->table_name} rp" . $prli_utils->prepend_and_or_where(' WHERE', $where);
|
105 |
-
return $wpdb->get_var($query);
|
106 |
-
}
|
107 |
-
|
108 |
-
public function getPageCount($p_size, $where="") {
|
109 |
-
return ceil((int)$this->getRecordCount($where) / (int)$p_size);
|
110 |
-
}
|
111 |
-
|
112 |
-
public function getPage($current_p,$p_size, $where = "", $order_by = '') {
|
113 |
-
global $wpdb, $prli_link, $prli_utils, $prli_link;
|
114 |
-
$end_index = $current_p * $p_size;
|
115 |
-
$start_index = $end_index - $p_size;
|
116 |
-
$query = "SELECT rp.*, " .
|
117 |
-
"li.name as goal_link_name, " .
|
118 |
-
"(SELECT COUNT(*) " .
|
119 |
-
"FROM {$this->links_table_name} rpl " .
|
120 |
-
"WHERE rpl.report_id = rp.id) as link_count " .
|
121 |
-
"FROM {$this->table_name} rp " .
|
122 |
-
"LEFT OUTER JOIN {$prli_link->table_name} li ON li.id = rp.goal_link_id AND li.link_status='enabled'" .
|
123 |
-
$prli_utils->prepend_and_or_where(' WHERE', $where) . "{$order_by} " .
|
124 |
-
"LIMIT {$start_index},{$p_size}";
|
125 |
-
$results = $wpdb->get_results($query);
|
126 |
-
return $results;
|
127 |
-
}
|
128 |
-
|
129 |
-
// Set defaults and grab get or post of each possible param
|
130 |
-
public function get_params_array() {
|
131 |
-
$values = array(
|
132 |
-
'action' => sanitize_key(stripslashes(isset($_GET['action'])?$_GET['action']:(isset($_POST['action'])?$_POST['action']:''))),
|
133 |
-
'id' => (isset($_GET['id'])?(int)$_GET['id']:(isset($_POST['id'])?(int)$_POST['id']:'')),
|
134 |
-
'sdate' => sanitize_text_field(stripslashes(isset($_GET['sdate'])?$_GET['sdate']:(isset($_POST['sdate'])?$_POST['sdate']:''))),
|
135 |
-
'edate' => sanitize_text_field(stripslashes(isset($_GET['edate'])?$_GET['edate']:(isset($_POST['edate'])?$_POST['edate']:''))),
|
136 |
-
'paged' => (isset($_GET['paged'])?(int)$_GET['paged']:(isset($_POST['paged'])?(int)$_POST['paged']:1)),
|
137 |
-
'search' => sanitize_text_field(stripslashes(isset($_GET['search'])?$_GET['search']:(isset($_POST['search'])?$_POST['search']:''))),
|
138 |
-
'sort' => sanitize_key(stripslashes(isset($_GET['sort'])?$_GET['sort']:(isset($_POST['sort'])?$_POST['sort']:''))),
|
139 |
-
'sdir' => sanitize_key(stripslashes(isset($_GET['sdir'])?$_GET['sdir']:(isset($_POST['sdir'])?$_POST['sdir']:'')))
|
140 |
-
);
|
141 |
-
|
142 |
-
return $values;
|
143 |
-
}
|
144 |
-
|
145 |
-
public function validate( $values ) {
|
146 |
-
global $wpdb, $prli_utils;
|
147 |
-
|
148 |
-
$errors = array();
|
149 |
-
if( empty($values['name']) ) {
|
150 |
-
$errors[] = __("Report must have a name.", 'pretty-link');
|
151 |
-
}
|
152 |
-
|
153 |
-
if( empty($values['link']) ) {
|
154 |
-
$errors[] = __("At least one link must be selected for analysis.", 'pretty-link');
|
155 |
-
}
|
156 |
-
|
157 |
-
return $errors;
|
158 |
-
}
|
159 |
-
|
160 |
-
public function get_labels_by_links($start_timestamp,$end_timestamp,$links,$uniques = false) {
|
161 |
-
global $wpdb, $prli_click, $prli_blogurl, $prli_link, $prli_utils;
|
162 |
-
|
163 |
-
if (!count($links)) {
|
164 |
-
return array();
|
165 |
-
}
|
166 |
-
|
167 |
-
$query_str = "
|
168 |
-
SELECT li.name as label
|
169 |
-
FROM {$prli_link->table_name} AS li
|
170 |
-
WHERE li.id IN (".implode(',',$links).")
|
171 |
-
AND li.link_status='enabled'
|
172 |
-
ORDER BY li.name
|
173 |
-
";
|
174 |
-
$records = $wpdb->get_results($query_str);
|
175 |
-
|
176 |
-
$link_labels = array();
|
177 |
-
foreach($records as $record) {
|
178 |
-
$link_labels[] = $record->label;
|
179 |
-
}
|
180 |
-
|
181 |
-
return $link_labels;
|
182 |
-
}
|
183 |
-
|
184 |
-
public function get_clicks_by_links($start_timestamp,$end_timestamp,$links,$uniques = false) {
|
185 |
-
global $wpdb, $prli_click, $prli_blogurl, $prli_link, $prli_utils;
|
186 |
-
|
187 |
-
if (!count($links)) {
|
188 |
-
return array();
|
189 |
-
}
|
190 |
-
|
191 |
-
$query_str = "SELECT li.id as id, " .
|
192 |
-
"(SELECT COUNT(*) FROM {$prli_click->table_name} cl " .
|
193 |
-
"WHERE cl.link_id = li.id" . $prli_click->get_exclude_where_clause( ' AND' ) . " " .
|
194 |
-
(($uniques)?'AND cl.first_click=1 ':'') .
|
195 |
-
"AND cl.created_at BETWEEN %s AND %s) as clicks " .
|
196 |
-
"FROM {$prli_link->table_name} li " .
|
197 |
-
"WHERE li.id IN (".implode(',',$links).") " .
|
198 |
-
"AND li.link_status='enabled' " .
|
199 |
-
"ORDER BY li.name";
|
200 |
-
$query = $wpdb->prepare( $query_str, date("Y-n-j 00:00:00",$start_timestamp), date("Y-n-j 23:59:59",$end_timestamp) );
|
201 |
-
$records = $wpdb->get_results($query);
|
202 |
-
|
203 |
-
$link_clicks = array();
|
204 |
-
foreach($records as $record) {
|
205 |
-
$link_clicks[] = $record->clicks;
|
206 |
-
}
|
207 |
-
|
208 |
-
return $link_clicks;
|
209 |
-
}
|
210 |
-
|
211 |
-
public function get_conversions_by_links($start_timestamp,$end_timestamp,$links,$goal_link_id) {
|
212 |
-
global $wpdb, $prli_click, $prli_blogurl, $prli_link, $prli_utils;
|
213 |
-
|
214 |
-
$sdate = date("Y-n-j 00:00:00",$start_timestamp);
|
215 |
-
$edate = date("Y-n-j 23:59:59",$end_timestamp);
|
216 |
-
|
217 |
-
$query_str = "SELECT li.id as id, " .
|
218 |
-
"(SELECT COUNT(DISTINCT cl.vuid) FROM {$prli_click->table_name} cl " .
|
219 |
-
"WHERE cl.link_id = li.id" . $prli_click->get_exclude_where_clause( ' AND' ) . " " .
|
220 |
-
"AND cl.vuid IN (SELECT DISTINCT cl2.vuid " .
|
221 |
-
"FROM {$prli_click->table_name} cl2 " .
|
222 |
-
"WHERE cl2.link_id=%d " .
|
223 |
-
"AND cl.created_at < cl2.created_at " .
|
224 |
-
"AND cl2.created_at BETWEEN %s AND %s" .
|
225 |
-
$prli_click->get_exclude_where_clause( ' AND' ) . ") " .
|
226 |
-
"AND cl.created_at BETWEEN %s AND %s" .
|
227 |
-
") as conversions " .
|
228 |
-
"FROM {$prli_link->table_name} li " .
|
229 |
-
"WHERE li.id IN (".implode(',',$links).") " .
|
230 |
-
"AND li.link_status='enabled' " .
|
231 |
-
"ORDER BY li.name";
|
232 |
-
|
233 |
-
$query = $wpdb->prepare( $query_str, $goal_link_id, $sdate, $edate, $sdate, $edate );
|
234 |
-
$records = $wpdb->get_results($query);
|
235 |
-
|
236 |
-
$link_conversions = array();
|
237 |
-
foreach($records as $record) {
|
238 |
-
$link_conversions[] = $record->conversions;
|
239 |
-
}
|
240 |
-
|
241 |
-
return $link_conversions;
|
242 |
-
}
|
243 |
-
|
244 |
-
public function get_chart_height($report_id,$line_height = 30) {
|
245 |
-
$links = $this->get_report_links_array($report_id);
|
246 |
-
return $line_height * count($links);
|
247 |
-
}
|
248 |
-
|
249 |
-
public function setupClicksByLinkBarGraph($start_timestamp, $end_timestamp, $report_id, $title_only = false) {
|
250 |
-
global $wpdb, $prli_utils, $prli_link, $prli_click;
|
251 |
-
|
252 |
-
$report = $this->getOne($report_id);
|
253 |
-
$links = $this->get_report_links_array($report_id);
|
254 |
-
$labels_array = $this->get_labels_by_links($start_timestamp, $end_timestamp, $links);
|
255 |
-
$clicks_array = $this->get_clicks_by_links($start_timestamp, $end_timestamp, $links);
|
256 |
-
$uniques_array = $this->get_clicks_by_links($start_timestamp, $end_timestamp, $links, true);
|
257 |
-
|
258 |
-
if($title_only) {
|
259 |
-
return __("Pretty Links Pro: Clicks for", 'pretty-link').' '.stripslashes($report->name).' '.__('report between', 'pretty-link').' '.date("Y-n-j",$start_timestamp).' '.__('and', 'pretty-link').' '.date("Y-n-j", $end_timestamp);
|
260 |
-
}
|
261 |
-
|
262 |
-
//Setup conversions
|
263 |
-
if(!empty($report->goal_link_id)) {
|
264 |
-
$conversions_array = $this->get_conversions_by_links($start_timestamp, $end_timestamp, $links, $report->goal_link_id);
|
265 |
-
|
266 |
-
$chart_data = array('cols' => array(array("label" => __('Link', 'pretty-link'), 'type' => 'string'), array("label" => __('All Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Unique Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Conversions', 'pretty-link'), 'type' => 'number')));
|
267 |
-
|
268 |
-
foreach($labels_array as $key => $value) {
|
269 |
-
$label = substr(addslashes($value),0,40);
|
270 |
-
|
271 |
-
$chart_data['rows'][] = array('c' => array(array('v' => $label, 'f' => null), array('v' => (int)$clicks_array[$key], 'f' => null), array('v' => (int)$uniques_array[$key], 'f' => null), array('v' => (int)$conversions_array[$key], 'f' => null)));
|
272 |
-
}
|
273 |
-
}
|
274 |
-
else { //Setup the clicks w/out conversions
|
275 |
-
$chart_data = array('cols' => array(array("label" => __('Link', 'pretty-link'), 'type' => 'string'), array("label" => __('All Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Unique Clicks', 'pretty-link'), 'type' => 'number')));
|
276 |
-
|
277 |
-
foreach($labels_array as $key => $value) {
|
278 |
-
$label = substr(addslashes($value),0,40);
|
279 |
-
|
280 |
-
$chart_data['rows'][] = array('c' => array(array('v' => $label, 'f' => null), array('v' => (int)$clicks_array[$key], 'f' => null), array('v' => (int)$uniques_array[$key], 'f' => null)));
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
return $chart_data;
|
285 |
-
}
|
286 |
-
|
287 |
-
// SPLIT TEST REPORT FUNCTIONS
|
288 |
-
public function get_split_report_links_array($link_id) {
|
289 |
-
global $prli_link,$plp_link_rotation;
|
290 |
-
|
291 |
-
$link = $prli_link->getOne($link_id);
|
292 |
-
|
293 |
-
$rotation_urls = $plp_link_rotation->get_rotations($link_id);
|
294 |
-
|
295 |
-
if($rotation_urls and is_array($rotation_urls)) {
|
296 |
-
array_unshift($rotation_urls,$link->url);
|
297 |
-
}
|
298 |
-
else {
|
299 |
-
$rotation_urls = array($link->url);
|
300 |
-
}
|
301 |
-
|
302 |
-
$new_rotation_urls = array();
|
303 |
-
foreach($rotation_urls as $rotation_url) {
|
304 |
-
if(!empty($rotation_url)) {
|
305 |
-
$new_rotation_urls[] = $rotation_url;
|
306 |
-
}
|
307 |
-
}
|
308 |
-
|
309 |
-
return $new_rotation_urls;
|
310 |
-
}
|
311 |
-
|
312 |
-
public function get_split_labels($link_id) {
|
313 |
-
$urls = $this->get_split_report_links_array($link_id);
|
314 |
-
|
315 |
-
$new_urls = array();
|
316 |
-
foreach($urls as $url) {
|
317 |
-
$new_urls[] = substr($url,0,40);
|
318 |
-
}
|
319 |
-
|
320 |
-
return $new_urls;
|
321 |
-
}
|
322 |
-
|
323 |
-
public function get_split_clicks($start_timestamp,$end_timestamp,$link_id,$uniques=false) {
|
324 |
-
global $wpdb, $prli_click, $plp_link_rotation;
|
325 |
-
$query_str = "SELECT cr.url as url, COUNT(".(($uniques)?'DISTINCT cl.vuid':'cl.id').") as clicks FROM {$prli_click->table_name} cl " .
|
326 |
-
"JOIN {$plp_link_rotation->cr_table_name} cr ON cl.id=cr.click_id " .
|
327 |
-
"WHERE cl.link_id=%d" .
|
328 |
-
$prli_click->get_exclude_where_clause( ' AND' ) . " " .
|
329 |
-
"AND cl.created_at BETWEEN %s AND %s " .
|
330 |
-
"GROUP BY cr.url";
|
331 |
-
$query = $wpdb->prepare( $query_str, $link_id, date("Y-n-j 00:00:00",$start_timestamp), date("Y-n-j 23:59:59",$end_timestamp) );
|
332 |
-
$records = $wpdb->get_results($query, ARRAY_A);
|
333 |
-
|
334 |
-
if($records and is_array($records)) {
|
335 |
-
$link_records = array();
|
336 |
-
foreach($records as $record) {
|
337 |
-
$link_records[$record['url']] = $record['clicks'];
|
338 |
-
}
|
339 |
-
|
340 |
-
return $link_records;
|
341 |
-
}
|
342 |
-
else {
|
343 |
-
return false;
|
344 |
-
}
|
345 |
-
}
|
346 |
-
|
347 |
-
public function get_split_conversions($start_timestamp,$end_timestamp,$link_id,$goal_link_id) {
|
348 |
-
global $wpdb, $prli_click, $plp_link_rotation;
|
349 |
-
|
350 |
-
$sdate = date("Y-n-j 00:00:00",$start_timestamp);
|
351 |
-
$edate = date("Y-n-j 23:59:59",$end_timestamp);
|
352 |
-
|
353 |
-
$query_str = "SELECT cr.url as url, COUNT(DISTINCT cl.vuid) as conversions " .
|
354 |
-
"FROM {$prli_click->table_name} cl " .
|
355 |
-
"JOIN {$plp_link_rotation->cr_table_name} cr ON cl.id=cr.click_id " .
|
356 |
-
"WHERE cl.link_id=%d" . $prli_click->get_exclude_where_clause( ' AND' ) . " " .
|
357 |
-
"AND cl.vuid IN (SELECT DISTINCT cl2.vuid " .
|
358 |
-
"FROM {$prli_click->table_name} cl2 " .
|
359 |
-
"WHERE cl2.link_id=%d " .
|
360 |
-
"AND cl.created_at < cl2.created_at " .
|
361 |
-
$prli_click->get_exclude_where_clause( ' AND','cl2' ) . ") " .
|
362 |
-
"AND cl.created_at BETWEEN %s AND %s " .
|
363 |
-
"GROUP BY cr.url";
|
364 |
-
|
365 |
-
$query = $wpdb->prepare( $query_str, $link_id, $goal_link_id, $sdate, $edate );
|
366 |
-
$records = $wpdb->get_results($query, ARRAY_A);
|
367 |
-
|
368 |
-
if($records and is_array($records)) {
|
369 |
-
$link_records = array();
|
370 |
-
foreach($records as $record) {
|
371 |
-
$link_records[$record['url']] = $record['conversions'];
|
372 |
-
}
|
373 |
-
|
374 |
-
return $link_records;
|
375 |
-
}
|
376 |
-
else {
|
377 |
-
return false;
|
378 |
-
}
|
379 |
-
}
|
380 |
-
|
381 |
-
public function split_test_chart_data($start_timestamp, $end_timestamp, $link_id, $title_only = false) {
|
382 |
-
global $wpdb, $prli_utils, $prli_link, $prli_link_meta, $prli_click;
|
383 |
-
|
384 |
-
$link = $prli_link->getOne($link_id);
|
385 |
-
$links = $this->get_split_report_links_array($link_id);
|
386 |
-
$goal_link_id = $prli_link_meta->get_link_meta($link_id, 'prli-split-test-goal-link', true);
|
387 |
-
|
388 |
-
$labels_array = $links;
|
389 |
-
$hits_array = $this->get_split_clicks($start_timestamp, $end_timestamp, $link_id);
|
390 |
-
$uniques_array = $this->get_split_clicks($start_timestamp, $end_timestamp, $link_id, true);
|
391 |
-
|
392 |
-
$hits = array();
|
393 |
-
$uniques = array();
|
394 |
-
for($i=0;$i<count($links);$i++) {
|
395 |
-
$hits[$i] = ((is_array($hits_array) and isset($hits_array[$links[$i]]) and !empty($hits_array[$links[$i]]))?$hits_array[$links[$i]]:0);
|
396 |
-
$uniques[$i] = ((is_array($uniques_array) and isset($uniques_array[$links[$i]]) and !empty($uniques_array[$links[$i]]))?$uniques_array[$links[$i]]:0);
|
397 |
-
}
|
398 |
-
|
399 |
-
if($title_only) {
|
400 |
-
return __("Pretty Links Pro: Split Report for", 'pretty-link')." ".stripslashes($link->name)." ".__("between", 'pretty-link')." ".date("Y-n-j",$start_timestamp).' '.__('and', 'pretty-link').' '.date("Y-n-j", $end_timestamp);
|
401 |
-
}
|
402 |
-
|
403 |
-
//Setup conversions
|
404 |
-
if(!empty($goal_link_id) and $goal_link_id) {
|
405 |
-
$conversions_array = $this->get_split_conversions($start_timestamp, $end_timestamp, $link_id, $goal_link_id);
|
406 |
-
$conversions = array();
|
407 |
-
|
408 |
-
for($i = 0; $i < count($links); $i++) {
|
409 |
-
$conversions[$i] = ((is_array($conversions_array) and isset($conversions_array[$links[$i]]) and !empty($conversions_array[$links[$i]]))?$conversions_array[$links[$i]]:0);
|
410 |
-
}
|
411 |
-
|
412 |
-
$chart_data = array('cols' => array(array("label" => __('Rotation', 'pretty-link'), 'type' => 'string'), array("label" => __('All Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Unique Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Conversions', 'pretty-link'), 'type' => 'number')));
|
413 |
-
|
414 |
-
foreach($labels_array as $key => $value) {
|
415 |
-
$chart_data['rows'][] = array('c' => array(array('v' => $value, 'f' => null), array('v' => (int)$hits[$key], 'f' => null), array('v' => (int)$uniques[$key], 'f' => null), array('v' => (int)$conversions[$key], 'f' => null)));
|
416 |
-
}
|
417 |
-
}
|
418 |
-
else { //Setup the clicks w/out conversions
|
419 |
-
$chart_data = array('cols' => array(array("label" => __('Rotation', 'pretty-link'), 'type' => 'string'), array("label" => __('All Clicks', 'pretty-link'), 'type' => 'number'), array("label" => __('Unique Clicks', 'pretty-link'), 'type' => 'number')));
|
420 |
-
|
421 |
-
foreach($labels_array as $key => $value) {
|
422 |
-
$chart_data['rows'][] = array('c' => array(array('v' => $value, 'f' => null), array('v' => (int)$hits[$key], 'f' => null), array('v' => (int)$uniques[$key], 'f' => null)));
|
423 |
-
}
|
424 |
-
}
|
425 |
-
|
426 |
-
return $chart_data;
|
427 |
-
}
|
428 |
-
|
429 |
-
private function common_report_vars() {
|
430 |
-
global $prli_siteurl, $prli_utils;
|
431 |
-
|
432 |
-
$params = $this->get_params_array();
|
433 |
-
$first_click = $prli_utils->getFirstClickDate();
|
434 |
-
|
435 |
-
// Adjust for the first click
|
436 |
-
if(isset($first_click)) {
|
437 |
-
$min_date = (int)((time()-$first_click)/60/60/24);
|
438 |
-
|
439 |
-
if($min_date < 30) {
|
440 |
-
$start_timestamp = $prli_utils->get_start_date($params,$min_date);
|
441 |
-
}
|
442 |
-
else {
|
443 |
-
$start_timestamp = $prli_utils->get_start_date($params,30);
|
444 |
-
}
|
445 |
-
|
446 |
-
$end_timestamp = $prli_utils->get_end_date($params);
|
447 |
-
}
|
448 |
-
else {
|
449 |
-
$min_date = 0;
|
450 |
-
$start_timestamp = time();
|
451 |
-
$end_timestamp = time();
|
452 |
-
}
|
453 |
-
|
454 |
-
return array(
|
455 |
-
'id' => $params['id'],
|
456 |
-
'first_click' => $first_click,
|
457 |
-
'min_date' => ($min_date * -1),
|
458 |
-
'start_timestamp' => $start_timestamp,
|
459 |
-
'end_timestamp' => $end_timestamp
|
460 |
-
);
|
461 |
-
}
|
462 |
-
|
463 |
-
/* Add header to prli-custom-report page */
|
464 |
-
public function custom_report_vars() {
|
465 |
-
$vars = $this->common_report_vars();
|
466 |
-
|
467 |
-
extract($vars);
|
468 |
-
|
469 |
-
$report = $this->getOne($id);
|
470 |
-
$data = $this->setupClicksByLinkBarGraph($start_timestamp, $end_timestamp, $id);
|
471 |
-
$title = $this->setupClicksByLinkBarGraph($start_timestamp, $end_timestamp, $id, true);
|
472 |
-
|
473 |
-
return array_merge(
|
474 |
-
compact( 'title', 'data', 'report' ),
|
475 |
-
$vars
|
476 |
-
);
|
477 |
-
}
|
478 |
-
|
479 |
-
/* Add header to prli-split-test-report page */
|
480 |
-
public function split_test_report_vars() {
|
481 |
-
global $prli_link;
|
482 |
-
|
483 |
-
$vars = $this->common_report_vars();
|
484 |
-
|
485 |
-
extract($vars);
|
486 |
-
|
487 |
-
$link = $prli_link->getOne($id);
|
488 |
-
$data = $this->split_test_chart_data($start_timestamp, $end_timestamp, $id);
|
489 |
-
$title = $this->split_test_chart_data($start_timestamp, $end_timestamp, $id, true);
|
490 |
-
|
491 |
-
return array_merge(
|
492 |
-
compact( 'title', 'data', 'link' ),
|
493 |
-
$vars
|
494 |
-
);
|
495 |
-
}
|
496 |
-
}
|
497 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpUrlReplacement.php
DELETED
@@ -1,409 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpUrlReplacement {
|
5 |
-
public $post_urls_table_name;
|
6 |
-
|
7 |
-
public function __construct() {
|
8 |
-
global $wpdb;
|
9 |
-
$this->post_urls_table_name = "{$wpdb->prefix}prli_post_urls";
|
10 |
-
}
|
11 |
-
|
12 |
-
/** This will get all of the keywords to urls for the given post.
|
13 |
-
* This is also where our smart-caching will come into play.
|
14 |
-
*/
|
15 |
-
public function get_post_urls_lookup($post_id) {
|
16 |
-
static $urls;
|
17 |
-
|
18 |
-
if(!isset($urls)) {
|
19 |
-
$urls = array();
|
20 |
-
}
|
21 |
-
|
22 |
-
if(!isset($urls[$post_id])) {
|
23 |
-
$index_keywords = get_option('plp_index_keywords', false);
|
24 |
-
if(empty($index_keywords)) { return $this->getURLToLinksArray(); }
|
25 |
-
|
26 |
-
global $wpdb, $prli_blogurl, $prli_link, $prli_link_meta;
|
27 |
-
|
28 |
-
$q = "
|
29 |
-
SELECT plm.meta_value AS replacement_url,
|
30 |
-
CONCAT(%s,li.slug) AS url
|
31 |
-
FROM {$prli_link->table_name} AS li
|
32 |
-
JOIN {$prli_link_meta->table_name} AS plm
|
33 |
-
ON li.id=plm.link_id
|
34 |
-
AND plm.meta_key='prli-url-replacements'
|
35 |
-
JOIN {$this->post_urls_table_name} AS pu
|
36 |
-
ON plm.id = pu.url_id
|
37 |
-
WHERE pu.post_id=%d
|
38 |
-
AND plm.meta_value <> %s
|
39 |
-
AND li.link_status='enabled'
|
40 |
-
";
|
41 |
-
|
42 |
-
$struct = PrliUtils::get_permalink_pre_slug_uri();
|
43 |
-
$q = $wpdb->prepare($q, $prli_blogurl.$struct, $post_id, '');
|
44 |
-
|
45 |
-
$replacement_urls = $wpdb->get_results($q);
|
46 |
-
|
47 |
-
$urls[$post_id] = $this->format_urls_array($replacement_urls);
|
48 |
-
}
|
49 |
-
|
50 |
-
return $urls[$post_id];
|
51 |
-
}
|
52 |
-
|
53 |
-
public function getURLToLinksArray() {
|
54 |
-
static $urls;
|
55 |
-
|
56 |
-
if(!isset($urls)) {
|
57 |
-
global $wpdb, $prli_blogurl, $prli_link, $prli_link_meta;
|
58 |
-
|
59 |
-
$struct = PrliUtils::get_permalink_pre_slug_uri();
|
60 |
-
$query = "
|
61 |
-
SELECT plm.meta_value as replacement_url,
|
62 |
-
CONCAT(%s,li.slug) AS url
|
63 |
-
FROM {$prli_link->table_name} li
|
64 |
-
JOIN {$prli_link_meta->table_name} plm
|
65 |
-
ON li.id = plm.link_id
|
66 |
-
WHERE plm.meta_key='prli-url-replacements'
|
67 |
-
AND plm.meta_value <> %s
|
68 |
-
AND li.link_status='enabled'
|
69 |
-
";
|
70 |
-
|
71 |
-
$query = $wpdb->prepare($query, $prli_blogurl . $struct, '');
|
72 |
-
$replacement_urls = $wpdb->get_results($query);
|
73 |
-
|
74 |
-
$urls = $this->format_urls_array($replacement_urls);
|
75 |
-
}
|
76 |
-
|
77 |
-
return $urls;
|
78 |
-
}
|
79 |
-
|
80 |
-
private function format_urls_array($replacement_urls) {
|
81 |
-
if(!is_array($replacement_urls) || empty($replacement_urls)) { return array(); }
|
82 |
-
|
83 |
-
$links_array = array();
|
84 |
-
|
85 |
-
foreach($replacement_urls as $replacement_url) {
|
86 |
-
if(isset($links_array[$replacement_url->replacement_url])) {
|
87 |
-
$links_array[$replacement_url->replacement_url][] = $replacement_url->url;
|
88 |
-
}
|
89 |
-
else {
|
90 |
-
$links_array[$replacement_url->replacement_url] = array($replacement_url->url);
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
return $links_array;
|
95 |
-
}
|
96 |
-
|
97 |
-
private function get_post_grouped_urls ($post_id) {
|
98 |
-
global $wpdb, $plp_options, $prli_link, $prli_link_meta;
|
99 |
-
|
100 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
101 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
102 |
-
|
103 |
-
$q = "
|
104 |
-
SELECT * FROM (
|
105 |
-
SELECT plm.meta_value AS url,
|
106 |
-
MIN(plm.id) AS id
|
107 |
-
FROM {$prli_link_meta->table_name} AS plm
|
108 |
-
JOIN {$wpdb->posts} AS p
|
109 |
-
ON p.ID=%d
|
110 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
111 |
-
ON pm.post_id=p.ID
|
112 |
-
AND pm.meta_key='_plp_post_urls_updated_at'
|
113 |
-
WHERE plm.meta_key='prli-url-replacements'
|
114 |
-
AND p.post_status='publish'
|
115 |
-
AND p.post_type IN ({$valid_types})
|
116 |
-
AND (
|
117 |
-
pm.meta_value IS NULL
|
118 |
-
OR pm.meta_value < plm.created_at
|
119 |
-
)
|
120 |
-
GROUP BY plm.meta_value
|
121 |
-
) AS u
|
122 |
-
ORDER BY CHAR_LENGTH(u.url) DESC, u.url ASC
|
123 |
-
";
|
124 |
-
$q = $wpdb->prepare($q, $post_id);
|
125 |
-
|
126 |
-
$urls = $wpdb->get_results($q);
|
127 |
-
|
128 |
-
return $urls;
|
129 |
-
}
|
130 |
-
|
131 |
-
private function get_comment_grouped_urls ($comment_id) {
|
132 |
-
global $wpdb, $plp_options, $prli_link, $prli_link_meta;
|
133 |
-
|
134 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
135 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
136 |
-
|
137 |
-
$q = "
|
138 |
-
SELECT * FROM (
|
139 |
-
SELECT plm.meta_value AS url,
|
140 |
-
MIN(plm.id) AS id
|
141 |
-
FROM {$prli_link_meta->table_name} AS plm
|
142 |
-
JOIN {$wpdb->comments} AS c
|
143 |
-
ON c.comment_ID=%d
|
144 |
-
JOIN {$wpdb->posts} AS p
|
145 |
-
ON p.ID=c.comment_post_ID
|
146 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
147 |
-
ON cm.comment_id=c.comment_ID
|
148 |
-
AND cm.meta_key='_plp_comment_urls_updated_at'
|
149 |
-
WHERE plm.meta_key='prli-url-replacements'
|
150 |
-
AND c.comment_approved=1
|
151 |
-
AND p.post_status='publish'
|
152 |
-
AND p.post_type IN ({$valid_types})
|
153 |
-
AND (
|
154 |
-
cm.meta_value IS NULL
|
155 |
-
OR cm.meta_value < plm.created_at
|
156 |
-
)
|
157 |
-
GROUP BY plm.meta_value
|
158 |
-
) AS u
|
159 |
-
ORDER BY CHAR_LENGTH(u.url) DESC, u.url ASC
|
160 |
-
";
|
161 |
-
$q = $wpdb->prepare($q, $comment_id);
|
162 |
-
|
163 |
-
$urls = $wpdb->get_results($q);
|
164 |
-
|
165 |
-
return $urls;
|
166 |
-
}
|
167 |
-
|
168 |
-
public function index_post ($post_id) {
|
169 |
-
global $plp_options;
|
170 |
-
$urls = $this->get_post_grouped_urls($post_id);
|
171 |
-
$post_content = PrliUtils::get_post_content($post_id);
|
172 |
-
$this->index_content($post_id, $urls, $post_content);
|
173 |
-
update_post_meta($post_id, '_plp_post_urls_updated_at', PrliUtils::now());
|
174 |
-
}
|
175 |
-
|
176 |
-
public function index_comment ($comment_id) {
|
177 |
-
global $plp_options;
|
178 |
-
$urls = $this->get_comment_grouped_urls($comment_id);
|
179 |
-
$comment_content = get_comment_text($comment_id);
|
180 |
-
$comment = get_comment($comment_id);
|
181 |
-
$this->index_content($comment->comment_post_ID, $urls, $comment_content);
|
182 |
-
update_comment_meta($comment_id, '_plp_comment_urls_updated_at', PrliUtils::now());
|
183 |
-
}
|
184 |
-
|
185 |
-
private function index_content ($post_id, &$urls, &$content) {
|
186 |
-
$url_ids = array();
|
187 |
-
|
188 |
-
foreach($urls as $url) {
|
189 |
-
if(preg_match('!\b'.preg_quote($url->url,'!').'\b!i', $content)) {
|
190 |
-
$url_ids[] = $url->id;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
// Add all keywords in one swath
|
195 |
-
return $this->add_post_urls($post_id, $url_ids);
|
196 |
-
}
|
197 |
-
|
198 |
-
private function add_post_urls ($post_id, $url_ids) {
|
199 |
-
global $wpdb;
|
200 |
-
|
201 |
-
if(empty($url_ids)) { return false; }
|
202 |
-
|
203 |
-
// We got a unique index folks so we just ignore dups yo
|
204 |
-
// But we just want to grab one random url to insert here
|
205 |
-
$q = "
|
206 |
-
INSERT IGNORE INTO {$this->post_urls_table_name}
|
207 |
-
(post_id, url_id)
|
208 |
-
VALUES
|
209 |
-
";
|
210 |
-
|
211 |
-
$vals = array();
|
212 |
-
foreach($url_ids as $url_id) {
|
213 |
-
// Not sure how this would ever be un-true but let's make sure it doesn't happen
|
214 |
-
if($url_id > 0 && $post_id > 0) {
|
215 |
-
$vals[] = $wpdb->prepare("(%d, %d)", $post_id, $url_id);
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
// No values to insert? Let's bail.
|
220 |
-
if(empty($vals)) { return false; }
|
221 |
-
|
222 |
-
$q .= implode(',',$vals);
|
223 |
-
|
224 |
-
return $wpdb->query($q);
|
225 |
-
}
|
226 |
-
|
227 |
-
// SELECT posts where updated_at < than max link updated_at
|
228 |
-
public function get_indexable_posts ($max_count=100) {
|
229 |
-
global $wpdb, $plp_options, $prli_link, $prli_link_meta, $plp_keyword;
|
230 |
-
|
231 |
-
$plp_keyword->update_links_with_null_updated_at();
|
232 |
-
|
233 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
234 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
235 |
-
|
236 |
-
$q = "
|
237 |
-
SELECT max(plm.created_at)
|
238 |
-
FROM {$prli_link_meta->table_name} AS plm
|
239 |
-
WHERE plm.meta_key='prli-url-replacements'
|
240 |
-
";
|
241 |
-
$max_updated_at = $wpdb->get_var($q);
|
242 |
-
|
243 |
-
// Order to get oldest / null entries updated first
|
244 |
-
$q = $wpdb->prepare("
|
245 |
-
SELECT ID
|
246 |
-
FROM {$wpdb->posts} AS p
|
247 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
248 |
-
ON p.ID=pm.post_id
|
249 |
-
AND pm.meta_key='_plp_post_urls_updated_at'
|
250 |
-
WHERE p.post_status = 'publish'
|
251 |
-
AND p.post_type IN ({$valid_types})
|
252 |
-
AND (
|
253 |
-
pm.meta_value IS NULL
|
254 |
-
OR pm.meta_value < %s
|
255 |
-
)
|
256 |
-
ORDER BY pm.meta_value ASC,
|
257 |
-
p.post_date DESC
|
258 |
-
LIMIT %d
|
259 |
-
",
|
260 |
-
$max_updated_at,
|
261 |
-
$max_count
|
262 |
-
);
|
263 |
-
$posts = $wpdb->get_col($q);
|
264 |
-
|
265 |
-
return $posts;
|
266 |
-
}
|
267 |
-
|
268 |
-
// SELECT posts where updated_at < than max link updated_at
|
269 |
-
public function get_indexable_comments ($max_count=100) {
|
270 |
-
global $wpdb, $plp_options, $prli_link, $prli_link_meta, $plp_keyword;
|
271 |
-
|
272 |
-
$plp_keyword->update_links_with_null_updated_at();
|
273 |
-
|
274 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
275 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
276 |
-
|
277 |
-
$q = "
|
278 |
-
SELECT max(plm.created_at)
|
279 |
-
FROM {$prli_link_meta->table_name} AS plm
|
280 |
-
WHERE plm.meta_key='prli-url-replacements'
|
281 |
-
";
|
282 |
-
$max_updated_at = $wpdb->get_var($q);
|
283 |
-
|
284 |
-
// Order to get oldest / null entries updated first
|
285 |
-
$q = $wpdb->prepare("
|
286 |
-
SELECT c.comment_ID
|
287 |
-
FROM {$wpdb->comments} AS c
|
288 |
-
INNER JOIN {$wpdb->posts} AS p
|
289 |
-
ON c.comment_post_ID=p.ID
|
290 |
-
AND p.post_status = 'publish'
|
291 |
-
AND p.post_type IN ({$valid_types})
|
292 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
293 |
-
ON c.comment_ID=cm.comment_id
|
294 |
-
AND cm.meta_key='_plp_comment_urls_updated_at'
|
295 |
-
WHERE c.comment_approved=1
|
296 |
-
AND (
|
297 |
-
cm.meta_value IS NULL
|
298 |
-
OR cm.meta_value < %s
|
299 |
-
)
|
300 |
-
ORDER BY cm.meta_value ASC,c.comment_date DESC
|
301 |
-
LIMIT %d
|
302 |
-
",
|
303 |
-
$max_updated_at,
|
304 |
-
$max_count
|
305 |
-
);
|
306 |
-
$comments = $wpdb->get_col($q);
|
307 |
-
|
308 |
-
return $comments;
|
309 |
-
}
|
310 |
-
|
311 |
-
// How many posts out of all are indexed
|
312 |
-
public function posts_indexed () {
|
313 |
-
global $wpdb, $prli_link, $plp_options, $prli_link_meta;
|
314 |
-
|
315 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
316 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
317 |
-
|
318 |
-
$q = "
|
319 |
-
SELECT max(plm.created_at)
|
320 |
-
FROM {$prli_link_meta->table_name} AS plm
|
321 |
-
WHERE plm.meta_key='prli-url-replacements'
|
322 |
-
";
|
323 |
-
$max_updated_at = $wpdb->get_var($q);
|
324 |
-
|
325 |
-
// Num un-indexed posts
|
326 |
-
$q = $wpdb->prepare("
|
327 |
-
SELECT COUNT(*)
|
328 |
-
FROM {$wpdb->posts} AS p
|
329 |
-
LEFT JOIN {$wpdb->postmeta} AS pm
|
330 |
-
ON p.ID=pm.post_id
|
331 |
-
AND pm.meta_key='_plp_post_urls_updated_at'
|
332 |
-
WHERE p.post_status = 'publish'
|
333 |
-
AND p.post_type IN ({$valid_types})
|
334 |
-
AND (
|
335 |
-
pm.meta_value IS NULL
|
336 |
-
OR pm.meta_value < %s
|
337 |
-
)
|
338 |
-
ORDER BY pm.meta_value
|
339 |
-
",
|
340 |
-
$max_updated_at
|
341 |
-
);
|
342 |
-
$unindexed = $wpdb->get_var($q);
|
343 |
-
|
344 |
-
$q = "
|
345 |
-
SELECT COUNT(*)
|
346 |
-
FROM {$wpdb->posts} AS p
|
347 |
-
WHERE p.post_status = 'publish'
|
348 |
-
AND p.post_type IN ({$valid_types})
|
349 |
-
";
|
350 |
-
$total = $wpdb->get_var($q);
|
351 |
-
|
352 |
-
$indexed = ($total - $unindexed);
|
353 |
-
|
354 |
-
return (object)compact('total', 'indexed', 'unindexed');
|
355 |
-
}
|
356 |
-
|
357 |
-
// How many comments out of all are indexed
|
358 |
-
public function comments_indexed () {
|
359 |
-
global $wpdb, $prli_link, $plp_options, $prli_link_meta;
|
360 |
-
|
361 |
-
$valid_types = $plp_options->autocreate_valid_types();
|
362 |
-
$valid_types = "'".implode("', '", $valid_types)."'";
|
363 |
-
|
364 |
-
$q = "
|
365 |
-
SELECT max(plm.created_at)
|
366 |
-
FROM {$prli_link_meta->table_name} AS plm
|
367 |
-
WHERE plm.meta_key='prli-url-replacements'
|
368 |
-
";
|
369 |
-
$max_updated_at = $wpdb->get_var($q);
|
370 |
-
|
371 |
-
// Num un-indexed posts
|
372 |
-
$q = $wpdb->prepare("
|
373 |
-
SELECT COUNT(*)
|
374 |
-
FROM {$wpdb->comments} AS c
|
375 |
-
INNER JOIN {$wpdb->posts} AS p
|
376 |
-
ON c.comment_post_ID=p.ID
|
377 |
-
AND p.post_status = 'publish'
|
378 |
-
AND p.post_type IN ({$valid_types})
|
379 |
-
LEFT JOIN {$wpdb->commentmeta} AS cm
|
380 |
-
ON c.comment_ID=cm.comment_id
|
381 |
-
AND cm.meta_key='_plp_comment_urls_updated_at'
|
382 |
-
WHERE c.comment_approved=1
|
383 |
-
AND (
|
384 |
-
cm.meta_value IS NULL
|
385 |
-
OR cm.meta_value < %s
|
386 |
-
)
|
387 |
-
ORDER BY cm.meta_value
|
388 |
-
",
|
389 |
-
$max_updated_at
|
390 |
-
);
|
391 |
-
$unindexed = $wpdb->get_var($q);
|
392 |
-
|
393 |
-
$q = "
|
394 |
-
SELECT COUNT(*)
|
395 |
-
FROM {$wpdb->comments} AS c
|
396 |
-
INNER JOIN {$wpdb->posts} AS p
|
397 |
-
ON c.comment_post_ID=p.ID
|
398 |
-
AND p.post_status = 'publish'
|
399 |
-
AND p.post_type IN ({$valid_types})
|
400 |
-
WHERE c.comment_approved=1
|
401 |
-
";
|
402 |
-
$total = $wpdb->get_var($q);
|
403 |
-
|
404 |
-
$indexed = ($total - $unindexed);
|
405 |
-
|
406 |
-
return (object)compact('total', 'indexed', 'unindexed');
|
407 |
-
}
|
408 |
-
}
|
409 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pro/app/models/PlpUtils.php
DELETED
@@ -1,276 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
if(!defined('ABSPATH')) { die('You are not allowed to call this page directly.'); }
|
3 |
-
|
4 |
-
class PlpUtils {
|
5 |
-
public static function sort_by_stringlen($word_array,$dir = 'ASC')
|
6 |
-
{
|
7 |
-
if( $dir == "ASC" ) {
|
8 |
-
uasort($word_array, 'PlpUtils::compare_stringlen_asc');
|
9 |
-
}
|
10 |
-
else if( $dir == "DESC" ) {
|
11 |
-
uasort($word_array, 'PlpUtils::compare_stringlen_desc');
|
12 |
-
}
|
13 |
-
|
14 |
-
return $word_array;
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* This function expects an array of weights in integer
|
19 |
-
* form [ 35, 25, 15, 50 ] that add up to 100.
|
20 |
-
*/
|
21 |
-
public static function w_rand($weights) {
|
22 |
-
$r = mt_rand(1,1000);
|
23 |
-
$offset = 0;
|
24 |
-
foreach ($weights as $k => $w) {
|
25 |
-
$offset += $w*10;
|
26 |
-
if ($r <= $offset) { return $k; }
|
27 |
-
}
|
28 |
-
}
|
29 |
-
|
30 |
-
public static function ga_installed() {
|
31 |
-
if(!function_exists('is_plugin_active')) {
|
32 |
-
require(ABSPATH . '/wp-admin/includes/plugin.php');
|
33 |
-
}
|
34 |
-
|
35 |
-
if(is_plugin_active('google-analyticator/google-analyticator.php')) {
|
36 |
-
return array('name' => __('Google Analyticator', 'pretty-link'), 'slug' => 'google-analyticator');
|
37 |
-
}
|
38 |
-
// DEPRECATED support on Jan 2020
|
39 |
-
// else if(is_plugin_active('google-analytics-for-wordpress/googleanalytics.php')) {
|
40 |
-
// return array('name' => __('Google Analytics by MonsterInsights', 'pretty-link'), 'slug' => 'google-analytics-for-wordpress');
|
41 |
-
// }
|
42 |
-
// else if(is_plugin_active('googleanalytics/googleanalytics.php')) {
|
43 |
-
// return array('name' => __('Google Analytics', 'pretty-link'), 'slug' => 'google-analytics');
|
44 |
-
// }
|
45 |
-
else {
|
46 |
-
return false;
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
public static function ga_tracking_code($ga_plugin_slug) {
|
51 |
-
ob_start();
|
52 |
-
|
53 |
-
if($ga_plugin_slug == 'google-analyticator' && function_exists('add_google_analytics')) {
|
54 |
-
add_google_analytics();
|
55 |
-
}
|
56 |
-
// DEPRECATED support on Jan 2020
|
57 |
-
// elseif($ga_plugin_slug == 'google-analytics-for-wordpress' && class_exists('Yoast_GA_JS') && class_exists('Yoast_GA_Options') && class_exists('Yoast_GA_Universal')) {
|
58 |
-
// //Working as of vs 5.4.9 of the GA plugin by MonsterInsights -- they keep changing this though :(
|
59 |
-
// $yoast_ops = Yoast_GA_Options::instance()->options;
|
60 |
-
|
61 |
-
// if(isset($yoast_ops->options['enable_universal']) && $yoast_ops->options['enable_universal'] == 1) {
|
62 |
-
// $tracking = new Yoast_GA_Universal;
|
63 |
-
// } else {
|
64 |
-
// $tracking = new Yoast_GA_JS;
|
65 |
-
// }
|
66 |
-
|
67 |
-
// $tracking->tracking();
|
68 |
-
// }
|
69 |
-
// elseif($ga_plugin_slug == 'google-analytics' && class_exists('Ga_Frontend')) {
|
70 |
-
// Ga_Frontend::googleanalytics();
|
71 |
-
// }
|
72 |
-
|
73 |
-
return ob_get_clean();
|
74 |
-
}
|
75 |
-
|
76 |
-
// Utility functions not part of this class //
|
77 |
-
public static function compare_stringlen_asc($val_1, $val_2) {
|
78 |
-
// initialize the return value to zero
|
79 |
-
$retVal = 0;
|
80 |
-
|
81 |
-
// compare lengths
|
82 |
-
$firstVal = strlen($val_1);
|
83 |
-
$secondVal = strlen($val_2);
|
84 |
-
|
85 |
-
if($firstVal > $secondVal) {
|
86 |
-
$retVal = 1;
|
87 |
-
}
|
88 |
-
else if($firstVal < $secondVal) {
|
89 |
-
$retVal = -1;
|
90 |
-
}
|
91 |
-
|
92 |
-
return $retVal;
|
93 |
-
}
|
94 |
-
|
95 |
-
public static function compare_stringlen_desc($val_1, $val_2) {
|
96 |
-
// initialize the return value to zero
|
97 |
-
$retVal = 0;
|
98 |
-
|
99 |
-
// compare lengths
|
100 |
-
$firstVal = strlen($val_1);
|
101 |
-
$secondVal = strlen($val_2);
|
102 |
-
|
103 |
-
if($firstVal > $secondVal) {
|
104 |
-
$retVal = -1;
|
105 |
-
}
|
106 |
-
else if($firstVal < $secondVal) {
|
107 |
-
$retVal = 1;
|
108 |
-
}
|
109 |
-
|
110 |
-
return $retVal;
|
111 |
-
}
|
112 |
-
|
113 |
-
public static function locate_by_ip($ip=null, $source='caseproof') {
|
114 |
-
global $prli_utils;
|
115 |
-
$ip = (is_null($ip)?$prli_utils->get_current_client_ip():$ip);
|
116 |
-
|
117 |
-
if(!self::is_ip($ip)) { return false; }
|
118 |
-
|
119 |
-
$lockey = 'pl_locate_by_ip_' . md5($ip.$source);
|
120 |
-
$loc = get_transient($lockey);
|
121 |
-
|
122 |
-
if(false===$loc) {
|
123 |
-
if($source=='caseproof') {
|
124 |
-
$url = "https://cspf-locate.herokuapp.com?ip={$ip}";
|
125 |
-
$cindex = 'country_code';
|
126 |
-
}
|
127 |
-
elseif($source=='freegeoip') {
|
128 |
-
$url = "https://freegeoip.net/json/{$ip}";
|
129 |
-
$cindex = 'country_code';
|
130 |
-
}
|
131 |
-
else { // geoplugin
|
132 |
-
$url = "http://www.geoplugin.net/json.gp?ip={$ip}";
|
133 |
-
$cindex = 'geoplugin_countryCode';
|
134 |
-
}
|
135 |
-
|
136 |
-
$res = wp_remote_get($url);
|
137 |
-
if(is_wp_error($res)) { return ''; }
|
138 |
-
$obj = json_decode($res['body']);
|
139 |
-
$country = (isset($obj->{$cindex})?$obj->{$cindex}:'');
|
140 |
-
|
141 |
-
$loc = (object)compact('country');
|
142 |
-
set_transient($lockey,$loc,DAY_IN_SECONDS);
|
143 |
-
}
|
144 |
-
|
145 |
-
return $loc;
|
146 |
-
}
|
147 |
-
|
148 |
-
public static function is_ip($ip, $version='any') {
|
149 |
-
$ipv4_pattern = '#^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$#i';
|
150 |
-
$ipv6_pattern = '/^(((?=.*(::))(?!.*\3.+\3))\3?|([\dA-F]{1,4}(\3|:\b|$)|\2))(?4){5}((?4){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})\z/i';
|
151 |
-
|
152 |
-
return (
|
153 |
-
($version==4 && preg_match($ipv4_pattern,$ip)) ||
|
154 |
-
($version==6 && preg_match($ipv6_pattern,$ip)) ||
|
155 |
-
($version=='any' && (preg_match($ipv4_pattern,$ip) || preg_match($ipv6_pattern,$ip)))
|
156 |
-
);
|
157 |
-
}
|
158 |
-
|
159 |
-
public static function country_by_ip($ip=null, $source='geoplugin') {
|
160 |
-
return (($loc = self::locate_by_ip()) ? $loc->country : '' );
|
161 |
-
}
|
162 |
-
|
163 |
-
public static function base36_encode($base10) {
|
164 |
-
return base_convert($base10, 10, 36);
|
165 |
-
}
|
166 |
-
|
167 |
-
public static function base36_decode($base36) {
|
168 |
-
return base_convert($base36, 36, 10);
|
169 |
-
}
|
170 |
-
|
171 |
-
public static function is_link_expired($link_id) {
|
172 |
-
global $prli_link, $prli_link_meta;
|
173 |
-
|
174 |
-
$expire_enabled = $prli_link_meta->get_link_meta($link_id, 'enable_expire', true);
|
175 |
-
|
176 |
-
if(!empty($expire_enabled)) {
|
177 |
-
$expire_type = $prli_link_meta->get_link_meta($link_id, 'expire_type', true);
|
178 |
-
$expired = false;
|
179 |
-
|
180 |
-
if($expire_type=='date') {
|
181 |
-
$expire_date = $prli_link_meta->get_link_meta($link_id, 'expire_date', true);
|
182 |
-
$now_ts = strtotime(gmdate('c')); //Make sure it's UTC
|
183 |
-
$expire_ts = strtotime($expire_date); // Expire AFTER the date
|
184 |
-
$expired = ($now_ts > $expire_ts);
|
185 |
-
}
|
186 |
-
else if($expire_type=='clicks') {
|
187 |
-
$expire_clicks = $prli_link_meta->get_link_meta($link_id, 'expire_clicks', true);
|
188 |
-
$link = $prli_link->getOne($link_id, OBJECT, true);
|
189 |
-
$num_clicks = $link->uniques;
|
190 |
-
//echo "Num Clicks: {$num_clicks} / Expire Clicks: {$expire_clicks}"; exit;
|
191 |
-
$expired = ($num_clicks >= $expire_clicks);
|
192 |
-
}
|
193 |
-
|
194 |
-
if($expired) {
|
195 |
-
$enable_expired_url = $prli_link_meta->get_link_meta($link_id, 'enable_expired_url', true);
|
196 |
-
$expired_url = $prli_link_meta->get_link_meta($link_id, 'expired_url', true);
|
197 |
-
|
198 |
-
if(!empty($enable_expired_url)) {
|
199 |
-
return $expired_url;
|
200 |
-
}
|
201 |
-
else {
|
202 |
-
return 404;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
return false;
|
208 |
-
}
|
209 |
-
|
210 |
-
public static function is_link_time_redirect_active($link_id) {
|
211 |
-
global $prli_link_meta;
|
212 |
-
|
213 |
-
$time_urls = $prli_link_meta->get_link_meta($link_id, 'time_url');
|
214 |
-
$time_starts = $prli_link_meta->get_link_meta($link_id, 'time_start');
|
215 |
-
$time_ends = $prli_link_meta->get_link_meta($link_id, 'time_end');
|
216 |
-
|
217 |
-
$now = time();
|
218 |
-
foreach($time_urls as $i => $time_url) {
|
219 |
-
$time_start = strtotime($time_starts[$i]);
|
220 |
-
$time_end = strtotime($time_ends[$i]);
|
221 |
-
if($time_start <= $now && $time_end >= $now) {
|
222 |
-
return $time_url;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
|
226 |
-
return false;
|
227 |
-
}
|
228 |
-
|
229 |
-
/** Get link categories
|
230 |
-
*
|
231 |
-
* @param $link_id The id of the link we want to get categories for
|
232 |
-
*
|
233 |
-
* @return Array of strings -- category slugs
|
234 |
-
*/
|
235 |
-
public static function get_link_categories($link_id) {
|
236 |
-
return self::get_link_terms($link_id, PlpLinkCategoriesController::$ctax);
|
237 |
-
}
|
238 |
-
|
239 |
-
/** Get link tags
|
240 |
-
*
|
241 |
-
* @param $link_id The id of the link we want to get tags for
|
242 |
-
*
|
243 |
-
* @return Array of strings -- tag slugs
|
244 |
-
*/
|
245 |
-
public static function get_link_tags($link_id) {
|
246 |
-
return self::get_link_terms($link_id, PlpLinkTagsController::$ctax);
|
247 |
-
}
|
248 |
-
|
249 |
-
/** Get link terms
|
250 |
-
*
|
251 |
-
* @param $link_id The id of the link we want to get terms for
|
252 |
-
* @param $taxonomy The name of the taxonomy
|
253 |
-
*
|
254 |
-
* @return Array of strings -- term slugs
|
255 |
-
*/
|
256 |
-
private static function get_link_terms($link_id, $taxonomy) {
|
257 |
-
global $prli_link;
|
258 |
-
|
259 |
-
$link = $prli_link->getOne($link_id);
|
260 |
-
$terms = wp_get_object_terms(array($link->link_cpt_id), array($taxonomy));
|
261 |
-
|
262 |
-
if(is_wp_error($terms)) {
|
263 |
-
error_log('** Error in PlpUtils::get_link_terms: '. $terms->get_error_message());
|
264 |
-
$terms = array();
|
265 |
-
}
|
266 |
-
|
267 |
-
return array_map(
|
268 |
-
function ($term) {
|
269 |
-
return $term->slug;
|
270 |
-
},
|
271 |
-
$terms
|
272 |
-
);
|
273 |
-
}
|
274 |
-
|
275 |
-
} //End class
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|