PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/api-rest/wp-content/plugins/material-admin/site-stats/includes/mtrl-stats-pages.php

https://gitlab.com/neyberbz/suelos-ualm
PHP | 132 lines | 95 code | 25 blank | 12 comment | 3 complexity | e75d99d4ff3ee7ee8e3556c91bba30a0 MD5 | raw file
  1. <?php
  2. function wp_show_stats_pages() {
  3. global $wpdb;
  4. // get page data
  5. $totalPages = wp_count_posts('page');
  6. $totalPagesArray = (array)$totalPages;
  7. unset($totalPagesArray['auto-draft']);
  8. unset($totalPagesArray['inherit']);
  9. $countPages = array_sum($totalPagesArray);
  10. ?>
  11. <?php if($countPages > 0){
  12. $data_str = "";
  13. $data_obj = "";
  14. //if(isset($usersCount['avail_roles']) && sizeof($usersCount['avail_roles']) > 0){
  15. foreach ($totalPagesArray as $key => $value) {
  16. $data_str .= "'".ucfirst($key)."', ";
  17. if($value == '0'){ $value = "'-'";}
  18. $data_obj .= "{value: ".$value.", name:'".ucfirst($key)."'}, ";
  19. }
  20. $data_str = substr($data_str,0,-2);
  21. $data_str = "[".$data_str."]";
  22. $data_obj = substr($data_obj,0,-2);
  23. $data_obj = "[".$data_obj."]";
  24. // }
  25. ?>
  26. <?php
  27. $getcolor = mtrl_dashboard_widget_color();
  28. ?>
  29. <?php
  30. /*$getcolor = array();
  31. $getcolor[0] = "#E57373";
  32. $getcolor[1] = "#FFD54F";
  33. $getcolor[2] = "#F06292";
  34. $getcolor[3] = "#FFB74D";
  35. $getcolor[4] = "#FF8A65";
  36. $getcolor[5] = "#FFF176";*/
  37. ?>
  38. <div class="chartBox"><?php //echo "<pre>"; print_r($totalPagesArray); echo "Total Pages: ".$countPages; echo "</pre>"; ?>
  39. <div id="totalPages_wiseChart" style='height:180px;'></div>
  40. </div>
  41. <script type="text/javascript">
  42. // Initialize after dom ready
  43. var myChart7 = echarts.init(document.getElementById('totalPages_wiseChart'));
  44. var option = {
  45. color: ['<?php echo $getcolor[0]; ?>','<?php echo $getcolor[1]; ?>','<?php echo $getcolor[2]; ?>','<?php echo $getcolor[3]; ?>','<?php echo $getcolor[4]; ?>','<?php echo $getcolor[5]; ?>'],
  46. tooltip : {
  47. trigger: 'item',
  48. formatter: "{a} <br/>{b} : {c} ({d}%)"
  49. },
  50. legend: {
  51. x: 'left',
  52. orient:'vertical',
  53. padding: 0,
  54. data:<?php echo $data_str; ?>
  55. },
  56. toolbox: {
  57. show : true,
  58. color : ['#bdbdbd','#bdbdbd','#bdbdbd','#bdbdbd'],
  59. itemSize: 13,
  60. itemGap: 10,
  61. feature : {
  62. mark : {show: false},
  63. dataView : {show: false, readOnly: true},
  64. magicType : {
  65. show: true,
  66. type: ['pie', 'funnel'],
  67. option: {
  68. funnel: {
  69. x: '25%',
  70. width: '50%',
  71. funnelAlign: 'center',
  72. max: 1700
  73. },
  74. pie: {
  75. roseType : 'none',
  76. }
  77. }
  78. },
  79. restore : {show: false},
  80. saveAsImage : {show: true}
  81. }
  82. },
  83. calculable : true,
  84. series : [
  85. {
  86. name:'Page Count',
  87. type:'pie',
  88. radius : [20, '80%'],
  89. roseType : 'radius',
  90. center: ['50%', '45%'],
  91. width: '50%', // for funnel
  92. max: 40, // for funnel
  93. itemStyle : {
  94. normal : { label : { show : true }, labelLine : { show : true } },
  95. emphasis : { label : { show : false }, labelLine : {show : false} }
  96. },
  97. data:<?php echo $data_obj; ?>
  98. }
  99. ]};
  100. // Load data into the ECharts instance
  101. myChart7.setOption(option);
  102. jQuery(window).on('resize', function(){
  103. myChart7.resize();
  104. });
  105. </script>
  106. <?php } ?>
  107. <?php } ?>